Skip to main content

script to clone virtualenvs.

Project description

virtualenv cloning script.

A script for cloning a non-relocatable virtualenv.

Virtualenv provides a way to make virtualenv’s relocatable which could then be copied as we wanted. However making a virtualenv relocatable this way breaks the no-site-packages isolation of the virtualenv as well as other aspects that come with relative paths and ‘/usr/bin/env’ shebangs that may be undesirable.

Also, the .pth and .egg-link rewriting doesn’t seem to work as intended. This attempts to overcome these issues and provide a way to easily clone an existing virtualenv.

It performs the following:

  • copies sys.argv[1] dir to sys.argv[2]

  • updates the hardcoded VIRTUAL_ENV variable in the activate script to the new repo location. (–relocatable doesn’t touch this)

  • updates the shebangs of the various scripts in bin to the new python if they pointed to the old python. (version numbering is retained.)

    it can also change ‘/usr/bin/env python’ shebangs to be absolute too, though this functionality is not exposed at present.

  • checks sys.path of the cloned virtualenv and if any of the paths are from the old environment it finds any .pth or .egg-link files within sys.path located in the new environment and makes sure any absolute paths to the old environment are updated to the new environment.

  • finally it double checks sys.path again and will fail if there are still paths from the old environment present.

NOTE: This script requires Python >= 2.5

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

virtualenv-clone-0.2.3.tar.gz (4.2 kB view details)

Uploaded Source

File details

Details for the file virtualenv-clone-0.2.3.tar.gz.

File metadata

File hashes

Hashes for virtualenv-clone-0.2.3.tar.gz
Algorithm Hash digest
SHA256 c03c7b719484f3901980fe0c04493315230292cc12a40ae6c9a65be77bbe8334
MD5 16394b2d0c47035ab1c3deb2dfb4d2e3
BLAKE2b-256 fc9e3445732b1ac053b01c8601cb7bf4b6828d3850fd7d0dbe5fc5fef007f840

See more details on using hashes here.

Supported by

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