background preloader

PyInstaller

PyInstaller

VPython 1. An Introduction to Distutils — Python v2.7.5 documentation This document covers using the Distutils to distribute your Python modules, concentrating on the role of developer/distributor: if you’re looking for information on installing Python modules, you should refer to the Installing Python Modules chapter. 1.1. Concepts & Terminology Using the Distutils is quite simple, both for module developers and for users/administrators installing third-party modules. write a setup script (setup.py by convention)(optional) write a setup configuration filecreate a source distribution(optional) create one or more built (binary) distributions Each of these tasks is covered in this document. Not all module developers have access to a multitude of platforms, so it’s not always feasible to expect them to create a multitude of built distributions. 1.2. If all you want to do is distribute a module called foo, contained in a file foo.py, then your setup script can be as simple as this: Some observations: python setup.py bdist_wininst python setup.py bdist_rpm

Packaging Python Libraries - Dive Into Python 3 You are here: Home ‣ Dive Into Python 3 ‣ Difficulty level: ♦♦♦♦♢ ❝ You’ll find the shame is like the pain; you only feel it once. ❞— Marquise de Merteuil, Dangerous Liaisons Diving In# Real artists ship. All of these facets of Distutils center around the setup script, traditionally called setup.py. In this chapter, you’ll learn how the setup scripts for chardet and httplib2 work, and you’ll step through the process of releasing your own Python software. skip over this code listing Detects - ASCII, UTF-8, UTF-16 (2 variants), UTF-32 (4 variants) - Big5, GB2312, EUC-TW, HZ-GB-2312, ISO-2022-CN (Traditional and Simplified Chinese) - EUC-JP, SHIFT_JIS, ISO-2022-JP (Japanese) - EUC-KR, ISO-2022-KR (Korean) - KOI8-R, MacCyrillic, IBM855, IBM866, ISO-8859-5, windows-1251 (Cyrillic) - ISO-8859-2, windows-1250 (Hungarian) - ISO-8859-5, windows-1251 (Bulgarian) - windows-1252 (English) - ISO-8859-7, windows-1253 (Greek) - ISO-8859-8, windows-1255 (Visual and Logical Hebrew) - TIS-620 (Thai)

dependencies - Is there a good dependency analysis tool for Python First programs in PyQt4 toolkit HomeContents In this part of the PyQt4 tutorial we will learn some basic functionality. Simple example This is a simple example showing a small window. #! The above code shows a small window on the screen. import sys from PyQt4 import QtGui Here we provide the necessary imports. app = QtGui.QApplication(sys.argv) Every PyQt4 application must create an application object. w = QtGui.QWidget() The QtGui.QWidget widget is the base class of all user interface objects in PyQt4. w.resize(250, 150) The resize() method resizes the widget. w.move(300, 300) The move() method moves the widget to a position on the screen at x=300, y=300 coordinates. w.setWindowTitle('Simple') Here we set the title for our window. w.show() The show() method displays the widget on the screen. sys.exit(app.exec_()) Finally, we enter the mainloop of the application. The exec_() method has an underscore. Figure: Simple An application icon #! The previous example was coded in a procedural style. self.initUI() Figure: Icon Showing a tooltip

( f o o b a r . l u ) » Blog Archive » A comprehensive guide through Python packaging (a.k.a. setup scripts) One of the really useful things in python are the setup scripts. When doing “serious” business, you really should look into them. Setup scripts are amazingly powerful. But they don’t necessarily need to be complex. But because of this flexibility, the documentation around them seems like a lot to read. Additionally, the state of packaging has changed quite a bit over the years. This post attempts to summarize the important bits using a “Hello World” project and steeping through the process of creating the setup.py file: Creating a package distributionAutomatic generation of executablesVersion numbersDependency managementPublishing your package (thus also making it available for automatic dependency resolution)Some more food for thought. NOTE: The setup.py script we will construct in this post, will use two bits of code which may not work in all cases:importing the package itself (to centralize the version number)Reading the long_description content from a text-file This is mostly true. <!

Distutils/Tutorial I have recently used distutils for the first time and thought I would share what I have learned. Please note: I am not a pro. All this is based on my own hacking and struggling to get things to work. I am sure there will be alternative ways to do things and that I will make mistakes. Caveat Emptor. (Based on GNU/Linux) The layout of folders A proper layout of your files and folders can really save you trouble later on. top |-- package | |-- __init__.py | |-- module.py | `-- things | |-- cross.png | |-- fplogo.png | `-- tick.png |-- runner |-- MANIFEST.in |-- README `-- setup.py top - This is called the "Distribution Root". UPDATE: How to add other files, other data and directories I have a tentative solution for when you need extra files and folders in your distributed tarball. The files runner I assume that there will be a single script file that you will use to start your Python app. runner module.py Next is the package. module.py It shows that it can find the data files in the things folder.

An Introduction to Python Lists You can use the list type to implement simple data structures, such as stacks and queues. stack = [] stack.append(object) object = stack.pop() queue = [] queue.append(object) object = queue.pop(0) The list type isn’t optimized for this, so this works best when the structures are small (typically a few hundred items or smaller). Another data structure for which a list works well in practice, as long as the structure is reasonably small, is an LRU (least-recently-used) container. lru.remove(item) lru.append(item) If you do the above every time you access an item in the LRU list, the least recently used items will move towards the beginning of the list. Searching Lists The in operator can be used to check if an item is present in the list: if value in L: print "list contains" , value To get the index of the first matching item, use index : i = L.index(value) The index method does a linear search, and stops at the first matching item. try : i = L.index(value) except ValueError: i = -1 Sorting Lists

Regex replace (in Python) - a simpler way Python Regular Expressions A regular expression is a special sequence of characters that helps you match or find other strings or sets of strings, using a specialized syntax held in a pattern. Regular expressions are widely used in UNIX world. The module re provides full support for Perl-like regular expressions in Python. The re module raises the exception re.error if an error occurs while compiling or using a regular expression. We would cover two important functions, which would be used to handle regular expressions. The match Function This function attempts to match RE pattern to string with optional flags. Here is the syntax for this function − re.match(pattern, string, flags=0) Here is the description of the parameters: The re.match function returns a match object on success, None on failure. Example #! When the above code is executed, it produces following result − matchObj.group() : Cats are smarter than dogs matchObj.group(1) : Cats matchObj.group(2) : smarter The search Function re.search(pattern, string, flags=0)

regex - Python: use regular expression to remove the white space from all lines regex - How do I make this regular expression skip over a new line in Python syntax - How can I do a line break (line continuation) in Python

Related: