[Distutils] A portable version of pip

Paul Moore p.f.moore at gmail.com
Mon Oct 21 12:39:51 CEST 2013


With all of the current interest in bundling pip with the Python
distribution, I had a sudden thought. Vinay has developed a package
called pyzzer (https://pypi.python.org/pypi/pyzzer) that bundles up
Python modules into runnable single-file executables.

Using a command

    pyzzer -m pip:main -l t64 -o pipsa.exe -s "#!python" -r <path-to-pip>\pip

you can build a single-file executable version of pip that can install
wheels (it can't install sdists until setuptools is installed, because
installing sdists depends on having setuptools at install time).

The -s "#!python" is not needed on Unix as the default is
"#!/usr/bin/env python". Also the -l t64 is a Windows requirement to
get an exe - you can produce a cross-platform pyz archive without it
(see the pyzzer docs for details).

This requires the latest development version of pip (which contains a
fix for running pip from an uninstalled zipfile) and the following
patch to pip\__init__.py:

Change:

from pip import cmdoptions

to:

import pip.cmdoptions
cmdoptions = pip.cmdoptions

This fixes a recursive-import issue - I'll update pip "real soon now"
(TM) for this.

This is just an experiment at the moment - I've done minimal testing
but it seems to work as I'd expect. It may be worth thinking about,
though - either as an alternative to bundling (a bit late, I know) or
as a way of providing pip for earlier versions of Python.

Hope this is of interest.

Paul


More information about the Distutils-SIG mailing list