background preloader

PyInstaller

PyInstaller

VPython 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# So you want to release a Python script, library, framework, or application. Python 3 comes with a packaging framework called Distutils. 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 This version requires Python 3 or later; a Python 2 version is available separately.""") ☞chardet and httplib2 are open source, but there’s no requirement that you release your own Python libraries under any particular license. Things Distutils Can’t Do For You# Releasing your first Python package is a daunting process. Choose a license. Directory Structure# skip over this code listing

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

The ExeMaker Tool Updated October 12, 2004 | October 10, 2004 | Fredrik Lundh “Outstanding utility. It isn’t just neat, it’s indispensable. ” ExeMaker is a small tool that takes a Python script, copies it to a program directory, and creates a Windows EXE file in the same directory. > exemaker pythondoc.py c:/bin c:/bin/pythondoc.exe ok c:/bin/pythondoc.py ok > dir c:\bin\pythondoc* 2004-10-10 15:00 4 096 pythondoc.exe 2004-10-10 15:00 41 611 pythondoc.py 2 File(s) 45 707 bytes Assuming that c:/bin is on your path, you can now run the script as a normal command-line tool: > pythondoc PythonDoc 2.1b3 (c) 2002-2003 by Fredrik Lundh. In other words, ExeMaker lets you install command-line programs written in Python along with other utilities, and use them without having to bother with PY associations, BAT files, or other workarounds. Usage Syntax: exemaker [-i interpreter] script [directory] Copies the script to the directory, and adds an EXE loader to the same directory. Details #! The #! Downloads

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)

Tutorial - py2exe.org py2exe turns Python programs into packages that can be run on other Windows computers without needing to install Python on those computers. You must run py2exe on a Windows computer. Python is needed on the computer where py2exe itself is run because py2exe is a Python program and it includes parts of Python in the package that is built. To successfully complete this tutorial you'll need to know the basics of Python (you can get started at python.org's getting started page). You'll also need to know how to run Python programs from the command prompt. Install py2exe on your Windows computer using pip: pip install py2exe There are a few simple steps needed to use py2exe once you've installed it: 1. The biggest step is almost always the first one. It's important that you make sure everything is working before you use py2exe. The first example we'll use here is our old friend... hello.py We need to make sure it's working... C:\Tutorial>python hello.py Hello World! Looks good! 2. setup.py 3. 4. 5.

dependencies - Is there a good dependency analysis tool for Python setuptools - The PEAK Developers' Center Basic Use For basic use of setuptools, just import things from setuptools instead of the distutils. Here's a minimal setup script using setuptools: from setuptools import setup, find_packages setup( name = "HelloWorld", version = "0.1", packages = find_packages(), ) As you can see, it doesn't take much to use setuptools in a project. Of course, before you release your project to PyPI, you'll want to add a bit more information to your setup script to help people find or learn about your project. In the sections that follow, we'll explain what most of these setup() arguments do (except for the metadata ones), and the various ways you might use them in your own project(s). Specifying Your Project's Version Setuptools can work well with most versioning schemes; there are, however, a few special things to watch out for, in order to ensure that setuptools and EasyInstall can always tell what version of your package is newer than another version. Automatic Script Creation "Eggsecutable" Scripts

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

EasyInstall - The PEAK Developers' Center Installing "Easy Install" Please see the setuptools PyPI page for download links and basic installation instructions for each of the supported platforms. You will need at least Python 2.3.5, or if you are on a 64-bit platform, Python 2.4. An easy_install script will be installed in the normal location for Python scripts on your platform. Note that the instructions on the setuptools PyPI page assume that you are are installling to Python's primary site-packages directory. If this is not the case, you should consult the section below on Custom Installation Locations before installing. Note that easy_install normally works by downloading files from the internet. (Alternately, if you do not wish easy_install to actually download anything, you can restrict it from doing so with the --allow-hosts option; see the sections on restricting downloads with --allow-hosts and command-line options for more details.) Troubleshooting Windows Notes Downloading and Installing a Package Example 1. Example 2.

( 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. <!

Virtual Environments — The Hitchhiker's Guide to Packaging v1.0 documentation Creating a virtualenv We’ll be using virtualenv so our installation experiments are contained and don’t modify your system Python environment. If you aren’t already familiar with virtualenv, you may want to read up on it first. Create a virtualenv: $ virtualenv --no-site-packages pip_test_env We use the --no-site-packages flag to prevent this virtualenv from “seeing” your global Python “site-packages” directory, so that our experiments aren’t confused by any Python packages you happen to already have installed globally. Recent versions of virtualenv (1.4+) automatically install pip for you inside the virtualenv (there will already be a pip script in pip_test_env/bin/). Note If you are using Windows, executable scripts in the virtualenv will be located at pip_test_env\Scripts\ rather than pip_test_env/bin/. Let’s “activate” the virtualenv to put pip_test_env/bin on our default PATH, so we can just type pip instead of pip_test_env/bin/pip: $ . pip_test_env/bin/activate On Windows, this is:

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.

Related: