I'm developing a CLI tool in python using docopt and packaging via wheels.
I can build and install the wheel package locally with the following:
python setup.py sdist bdist_wheel
pip install dist/mypackage.whl
I can then test my package from the command line
mypackage --v
This works fine, but does not provided a very practical dev / test loop. In order to view any changes I need to uninstall the package, rebuild it and reinstall it.
Is there a more practical way to easily test and run changes locally during development?
Failing any better solution I have simply combined uninstall, build and install into a make task:
reload:
pip uninstall -y mypkg && python setup.py sdist bdist_wheel && pip install dist/mypkg.whl
Now simply running make reload will achieve what I need.
and by using
pip install --editable . in your dev folder?
You will have your package installed in editable mode, and continue to develop without having to resinstall all.
Related
While I'm developing a python package, a common loop for me is to edit a few files, then reinstall the package in my virtual environment and re-run tests:
python setup.py install && pytest tests
The python setup.py install part runs in 0.696 seconds.
I feel like I should be using pip for this, which also works but is MUCH slower than the previous command:
pip install . && pytest tests
Here pip install . runs in 42.006 seconds.
Is there any way to speed up a local development install of pip install . so it's on the order of python setup.py install?
It is slow because it makes a full copy of the entire directory, including possibly big hidden dirs like .git, .hg, .idea, .vagrant etc.
See this open issue: https://github.com/pypa/pip/issues/2195
I bundle my package as a sdist zip file , after that i can import my package anywhere using pip install , but i want to run some post install commands automatically after calling pip install.
I cannot use python setup.py install because it is a sdist and i am using pip to install it . I do have a PostInstall class but nothing runs after pip install package. Is there a way to automatically run a script after pip install package.
I have tried using postinstall but it doesnt work and also i am not sure how to use the scripts atrib in the setup method.
This is my setup.py file :
Setup.py
I cannot use python setup.py install because it is a sdist and i am using pip to install it . I do have a MyInstall class but nothing run after pip install package.
I tried to install a python package using setup.py but failed.
Any idea about that? I am on Ubuntu 14.04.
pip install setup.py
You just mixed up something.Have a look at pip install usage and Installing Python Modules.
If you want to download a module source distribution and install it, you should unpack the archive into a similarly-named directory: foo-1.0. Additionally, the distribution will contain a setup script setup.py,and then run this command from a terminal:
python setup.py install
You can use pip install if you want to install packages from:
PyPI (and other indexes) using requirement specifiers.
VCS project urls.
Local project directories.
Local or remote source archives.
Hope this helps.
Use the following:
python setup.py install
Try this python setup.py install
Navigate to the folder containing the package
eg: cd /Desktop/packages/foo-1.0/
you can install the package either by
python setup.py install
or by
pip install ./
in Linux use
sudo python3 setup.py install
Instead of doing
python setup.py install
we can do
pip install .
But, it does not build the library rather installs the egg without building.
Is there any command to build from pip which works similar to
python setup.py build
?
pip install -e .
It builds and then installs.
Simple Question ;)
Is there a way to simply install the package using pip once you build it. Using easy_install I would simply build my package it (python setup.py build), then if I was happy do a easy_install . and this would dump the resulting egg into the right place. How do I do this using pip?
pip install -e . will install from a local source like easy_install . would.
Most of pip's commands and functionality are designed around installing from source repositories or PyPI package listings, or maintaining consistently versioned dependencies though.
If you are going through the steps of building the package yourself, are you sure you don't want to python setup.py install manually after you are satisfied with the build?