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.
Related
I'm trying to build a package with its dependencies and then install in a separate step.
I'm not using a requirements file I'm using setup.cfg and pyproject.toml.
pip download vendor --dest ./build/dependencies --no-cache-dir
python setup.py check
python setup.py bdist_wheel
python setup.py sdist
That seems to install dependencies into the ./build/dependencies folder, but I can't figure out how to install the wheel by looking in that folder for dependencies.
--find-links doesn't appear to work because I get "Could not find a version that satisfies the requirement.." errors when doing this:
python -m pip install --no-index $(ls dist/*.whl) --find-links="./build/dependencies"
It builds fine without --no-index fetching from the internet.
I also tried running pip install with --target like this,
pip install -e . --target=./build/dependencies
But get the same errors when trying to point to it with --find-links.
Is there a way, using setup.py, to install a python package as a wheel/pip-style package (i.e. dist-info) instead of the egg installation that setup.py does by default (i.e. egg-info)?
For example, if I have a python package with a setup.py script and I run the following command, it will install the package as an egg.
> python setup.py install
However, I can build a wheel first, and then use pip to install that wheel as a wheel/dist-info type installation
> python setup.py bdist_wheel
> pip install ./dist/package-0.1-py2-none-any.whl
Is there a way to install the package as a wheel/dist-info installation directly from setup.py? Or is the two-step process using both setuptools and pip necessary?
Update: Confirmed, this has landed in pip now. If you are still seeing .egg-info installs when pip installing from a directory, then just upgrade your pip installation. Note that --editable installs will still use egg-info.
Original answer below:
This feature is coming soon. This was issue #4611. Follow the trail and you will find PR 4764 to pip, merged into master approx a week ago. In the meantime, you can
pip wheel .
pip install ./mypackage.whl
For me the proposed solution still didn't work (even with pip 21.0.1), and due to versioning (package-name-XX.YY), I also didn't know the name of the .whl file. You can tell pip to look in the directory and take the .whl from there:
python setup.py bdist_wheel
pip install package-name --find-links dist/
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.
We are using pip -e . to install our package in editable/development mode, instead of using python setup.py develop. (We have to do so, because we pull packages from the public PyPi server and a private one. This did not worked for us using python setup.py develop.)
But pip -e . does not install test dependencies and I could not find some flag to force it to do so. How do I install test dependencies using pip?
I use extra_require in the setup.py as specified here. For example:
setup(
name="Project-A",
...
extras_require={
'develop': ["mock==2.0.0"],
}
)
And to execute it using pip install:
pip install -e .[develop]