This is a quick and dirty tool used to move (rename) directories created by virtualenv and/or venv.
The script replaces the current path with the destination path in all of the important files. This includes the contents of the activate scripts (e.g. bin/activate
, bin/activate.csh
, bin/activate.fish
), the shebang on scripts (e.g. bin/easy_install
, bin/easy_install-3.4
, bin/pip
, bin/pip3
, bin/pip3.4
, bin/wheel
) and the records within RECORD
files (e.g. lib/python3.4/site-packages/wheel-0.24.0.dist-info/RECORD
, lib/python3.4/site-packages/setuptools-18.2.dist-info/RECORD
, lib/python3.4/site-packages/pip-7.1.2.dist-info/RECORD
). It also fixes absolute paths in .pth files and relinks dangling symlinks (where appropriate).
It does not update the SHA256 hashes stored in RECORD for files that have had their shebangs modified. These hashes are only verified during installation. So far as I can tell, they serve no further purpose. See PEP-0427.
It also has some basic error handling and will attempt to restore a backup of the virtualenv in the event of an error.
A few things on the wish list: submit the package to PyPi for easy installation via pip
and consider the ability to repair virtualenvs that have already been moved incorrectly.
To install virtualenv-mv
for the current user (assuming directory is on your PATH):
install <(curl -sS https://raw.githubusercontent.com/brbsix/virtualenv-mv/master/virtualenv-mv) ~/.local/bin/virtualenv-mv
Or, if you're in the cloned repository:
install virtualenv-mv ~/.local/bin
To install virtualenv-mv
for all users:
sudo install virtualenv-mv /usr/local/bin
Use virtualenv-mv
like you would use a simple implementation of mv
(without any options).
Usage: virtualenv-mv [OPTION]... SOURCE DEST
or: virtualenv-mv [OPTION]... SOURCE... DIRECTORY
Rename SOURCE to DEST, or move SOURCE to DIRECTORY.
Note that this tool cannot currently help if you've already moved the directory away from the directory it was created in with another tool.
Copyright (c) 2015-2016 Six brbsix@gmail.com
Licensed under the GPLv3 license.