I have a package I am developing. This package is already installed as an egg file parked in the site-packages directory, egg path added to easy-install.pth.
I now realized I have a bug in the package, so I invoked python setup.py develop
to hook up the development dir. The path of the source dir is correctly added to easy-install.pth, but it's added latest, meaning that the already installed egg will be chosen and imported first with I issue import mypackage
.
How can I have the development hook override the already installed package ?
Eventually, if I am doing it wrong, please explain what's the proper strategy to solve this use case.
If you are using pip,
sudo pip uninstall packagename
will prompt for all packages that are in the easy-install.pth and delete all of them, upon confirmation.
You can then do a setup.py develop
so that only the development branch is in the python path.
If you need multiple versions of the same library, the best option is to use virtualenv (and virtualenvwrapper as the bash helper).
Also worth mentioning, if you want the simplest solution without any network traffic (I can't imagine why), you might as well, just symlink from the site-packages, like:
sudo ln -fs ~/django_registration/registration /usr/lib/python2.6/dist-packages/django_registration
If you are using pip for package installation (why wouldn't you?) you can also get the developing version into the easy-install.pth by something like:
pip install -e hg+http://bitbucket.org/ubernostrum/django-registration/#egg=django_registration
Update, based on the comment:
If you want to use the new package only in the current module, you can manually modify the sys.path, like
sys.path.insert(1,'/path/to/package')
So, the import picks up from the right location.
You can ask pip
to override the current installed packages with --upgrade
and pip
can install from a local dir so:
easy_install pip # if you don't have pip installed
pip install /your/package --upgrade
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With