Skip to main content

Create a complete self contained virtualenv bootstrap file by enbed 'get-pip.py'

Project description

bootstrap_env

Experimental project to create a complete self contained virtualenv bootstrap file. See: packaging-problems issues 55

Fork and contribute! ;)

Compatible Python Versions (see also .travis.yml):

  • 2.7, 3.4, 3.5

  • PyPy (Python v2 and v3)

Status on travis-ci.org

travis-ci.org/jedie/bootstrap_env

Status on appveyor.com

ci.appveyor.com/project/jedie/bootstrap-env

Coverage Status on coveralls.io

coveralls.io/r/jedie/bootstrap_env

Status on landscape.io

landscape.io/github/jedie/bootstrap_env/master

Requirements Status on requires.io

requires.io/github/jedie/bootstrap_env/requirements/

info

Since virtualenv v1.10 you a virtualenv bootstrap file is not runnable without the pip and setuptools wheel files. There must be created a virtualenv_support with the wheels.

e.g.:

/bootstrap.py
/virtualenv_support/
        pip-1.5.6-py2.py3-none-any.whl
        setuptools-3.6-py2.py3-none-any.whl

With this project this is not needed. The current solution embed get_pip.py into the bootstrap file and call it after env creation.

There are also some helpers to parse pip requirement files and install packages after virtualenv creation. Look into “boot bootstrap_env” project below.

the example

There is a simple example.

To test it, create first the bootstrap file by running create_example.py for it: e.g.:

/path/to/bootstrap-env$ python example_bootstrap/create_example.py

Generate bootstrap file: '/path/to/bootstrap-env/boot_example_env.py'...

Read code from: '.../src/bootstrap-env/example_bootstrap/extend_parser.py'...
Read code from: '.../src/bootstrap-env/example_bootstrap/adjust_options.py'...
Read code from: '.../src/bootstrap-env/example_bootstrap/after_install.py'...
Read code from: '.../src/bootstrap-env/bootstrap_env/bootstrap_install_pip.py'...
Request: 'https://raw.githubusercontent.com/pypa/pip/22baf0ca29325e848010c44a0fec0db64e8d1edb/contrib/get-pip.py'...
Request: 'https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py'...
Requested content of 'get-pip.py' is up-to-date, ok.
get-pip.py SHA256: '51ef604ed2852f6b57b675ebefc4b807cffd2300bfc885761365988d19d227ad', ok.

'/path/to/bootstrap-env/boot_example_env.py' written.

After the first call, the requested get-pip.py file will be cached into the default temp and reused from there. So it is fast to generate it again:

/path/to/bootstrap-env$ python example_bootstrap/create_example.py

Generate bootstrap file: '/path/to/bootstrap-env/boot_example_env.py'...

Read code from: '.../src/bootstrap-env/example_bootstrap/extend_parser.py'...
Read code from: '.../src/bootstrap-env/example_bootstrap/adjust_options.py'...
Read code from: '.../src/bootstrap-env/example_bootstrap/after_install.py'...
Read code from: '.../src/bootstrap-env/bootstrap_env/bootstrap_install_pip.py'...
Use '/tmp/get-pip.py'
get-pip.py SHA256: '51ef604ed2852f6b57b675ebefc4b807cffd2300bfc885761365988d19d227ad', ok.

'/path/to/bootstrap-env/boot_example_env.py' written.

Running this looks like:

/path/to/bootstrap-env$ python boot_example_env.py ~/example_env

The additional example extend_parser() code is called.
The additional example adjust_options() code is called.

Using real prefix '/usr'
Path not in prefix '/home/jens/PyLucid_env/include/python3.4m' '/usr'
New python executable in /home/jens/example_env/bin/python
Install pip...
call '/home/jens/example_env/bin/python /home/jens/PyLucid_env/src/bootstrap-env/boot_example_env.py --install-pip /home/jens/example_env'
install pip from self contained 'get_pip.py'
Collecting pip
  Using cached pip-7.0.3-py2.py3-none-any.whl
Collecting setuptools
  Using cached setuptools-17.0-py2.py3-none-any.whl
Collecting wheel
  Using cached wheel-0.24.0-py2.py3-none-any.whl
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-7.0.3 setuptools-17.0 wheel-0.24.0

The additional example after_install() code is called.

The example hook code stored separated files in example_bootstrap directory looks like this:

def extend_parser(parser):
    # --- CUT here ---
    sys.stdout.write("\nThe additional example extend_parser() code is called.\n")
def adjust_options(options, args):
    # --- CUT here ---
    sys.stdout.write("The additional example adjust_options() code is called.\n\n")
def after_install(options, home_dir):
    # --- CUT here ---
    sys.stdout.write("\nThe additional example after_install() code is called.\n\n")

usage

To create you own bootstrap file, is easy. Just copy the example or boot_bootstrap_env code and change it for your needs.

Projects that use bootstrap_env are:

Missing project? Do you use it? Just send me a mail: bootstrap_env AT jensdiemer DOT de or use IRC/Jabber (see below)

boot bootstrap_env

To create a fresh virtualenv with boot.py do the following:

# Download 'boot_bootstrap_env.py' from github:
/home/FooBar$ wget https://raw.githubusercontent.com/jedie/bootstrap_env/master/bootstrap_env/boot.py

# Create virtualenv and use read-only GIT:
/home/FooBar$ python3 boot.py ~/my_bootstrap_env --install_type git_readonly

The created virtualenv is under ~/my_bootstrap_env/ ;)

If you would like to use PyPi packages do this:

# Create virtualenv and use read-only GIT:
/home/FooBar$ python3 boot.py ~/my_bootstrap_env --install_type pypi

The boot.py will be created by create_boot.py this is stored here: /bootstrap_env/boot_bootstrap_env/

This also work under Windows. e.g:

C:\> C:\Python34\python.exe d:\downloads\boot.py --install_type=pypi d:\my_bootstrap_env

There is also a maybe helpful batch file: bootstrap_env/boot.cmd

Request get_pip.py notes

The script file bootstrap_env/create_bootstrap.py will request get_pip.py from https://github.com/pypa/pip/blob/develop/contrib/get-pip.py It verify the content via SHA256 hash. This hash is hardcoded in create_bootstrap.py You will get a warning if a newer get_pip.py was commited. Looks like this:

Request: 'https://raw.githubusercontent.com/pypa/get-pip/8481822bfacd435888cab6a0103fb041a2634bfb/get-pip.py'...
Request: 'https://bootstrap.pypa.io/get-pip.py'...
WARNING: 'get-pip.py' master changed! Maybe a new version was commited?
Please check:
    https://github.com/pypa/get-pip/commits/master/get-pip.py
And report here:
    https://github.com/jedie/bootstrap_env/issues
get-pip.py SHA256: 'f982ad4fc7baa8a6b03d000df349ac9c27d8a695f12d955225e9c25ff1897934', ok.

'../boot_bootstrap_env.py' written.

backward incompatible changes

v0.4 -> v0.5

bootstrap_env.**create_bootstrap** was renamed to: bootstrap_env.**generate_bootstrap**

e.g. new:

from bootstrap_env.generate_bootstrap import generate_bootstrap

if __name__ == '__main__':
    generate_bootstrap(
        #...
    )

old:

from bootstrap_env.create_bootstrap import generate_bootstrap

if __name__ == '__main__':
    generate_bootstrap(
        #...
    )

History

  • v0.6.2 - 20.07.2016:

  • v0.6.1 - 04.04.2016:

  • v0.6.0 - 26.12.2015:

    • Remove old v0.4 API warnings

  • v0.5.4 - 26.07.2015:

    • Bugfix for PyPy2 under Windows by a more flexible solution to find ‘bin’ and executeables.

  • v0.5.3 - 24.07.2015 - update to pip 7.1.2

  • v0.5.2 - 24.07.2015 - Made add_extend_parser, add_adjust_options and add_after_install optional in generate_bootstrap()

  • v0.5.1 - 18.07.2015 - Update to pip 7.1.0

  • v0.5.0 - 05.06.2015 - Add unittests, refactor sourcecode layout. (Please notice ‘backward incompatible changes’ above!)

  • v0.4.6 - 03.06.2015 - Update to pip 7.0.3

  • v0.4.5 - 26.05.2015 - Update to pip 7.0.1, cut filepath in generated boot file comments

  • v0.4.4 - 14.04.2015 - Update to pip 6.1.1 (upload again as v0.4.4 with wheel, too.)

  • v0.4.2 - 07.02.2015 - Update to pip 6.0.8

  • v0.4.1 - 29.01.2015 - Update for pip 6.0.7 and pin requested url.

  • v0.4.0 - 28.01.2015 - Updates for pip 6.0.6 changes

  • v0.3.5 - 28.01.2015 - Update SHA256 for get-pip.py v6.0.6

  • v0.3.4 - 14.11.2014 - Bugfix: if os.environ['SYSTEMROOT'] not exists.

  • v0.3.3 - 14.11.2014 - Add version number into generated bootstrap file.

  • v0.3.2 - 14.11.2014 - Add ‘boot bootstrap_env’ and bugfixes for running under Windows.

  • v0.3.1 - 14.11.2014 - Bugfix for “error: no such option:” while pip install, if own optional options are used.

  • v0.3.0 - 13.11.2014 - typo: rename all bootstrip to bootstrap ;)

  • v0.2.0 - 09.10.2014 - add prefix and suffix argument to generate_bootstrap()

  • v0.1.0 - 09.10.2014 - initial release

donation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bootstrap_env-0.6.2.tar.gz (1.3 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

bootstrap_env-0.6.2-py3.4.egg (1.3 MB view details)

Uploaded Egg

bootstrap_env-0.6.2-py2.py3-none-any.whl (1.3 MB view details)

Uploaded Python 2Python 3

File details

Details for the file bootstrap_env-0.6.2.tar.gz.

File metadata

  • Download URL: bootstrap_env-0.6.2.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for bootstrap_env-0.6.2.tar.gz
Algorithm Hash digest
SHA256 33fe6bd29110afd5e0824f46a93285504b2a0245809e2eab0c772a5423ca2aed
MD5 5b5753b0870e98489681f894bada1caf
BLAKE2b-256 ba931d6a15f9f2f0f103cf4354eae19d0c4e71911b27224c95d6536c7c87f88a

See more details on using hashes here.

File details

Details for the file bootstrap_env-0.6.2-py3.4.egg.

File metadata

File hashes

Hashes for bootstrap_env-0.6.2-py3.4.egg
Algorithm Hash digest
SHA256 bdc59cab307be8e83b36085a44be6548787fd89d9a31aa2ec41e41e0a735532b
MD5 1b95c47a69d8427f0f7a2f01e3b469e9
BLAKE2b-256 6e7686f0f8ea1c5534688fd2d6c55132eeee14f715ec0a55578ea14a758e4473

See more details on using hashes here.

File details

Details for the file bootstrap_env-0.6.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for bootstrap_env-0.6.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4a3ca1d53229dc6a171f1f5aa25b044eac93a863a05f4593587470ab24cf6eac
MD5 2d99136881e724ff25403519058e068c
BLAKE2b-256 ca8b9c6691adf91d07ab086e951c9a6634861cbadc298f1dcf420c71aabb48a7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page