pip build . similar to python setup.py build - python

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.

Related

Vendoring dependencies not working with --find-links

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.

Perform a command after pip install <package>

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.

Test python cli wheel package during local development

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.

How to use setup.py to install dependencies only?

I am not interested in installing my package itself but I am interested installing all the dependencies used by my package. Is there a way to do this using setup.py? It seems setup.py installs my package and all dependencies.
Use the -e flag on pip install
pip install -e .
The only way I've found to reliably do this in a straightforward manner is this:
pip install . && pip uninstall `python setup.py --name`
if you wan to do it from setup.py do:
python setup.py egg_info
pip install -r *.egg-info/requires.txt
rm -rf *.egg-info/
all of this ran from the project folder usually for me it's the root of my github where setup.py is.
credits: https://stackoverflow.com/a/53251585/1601580

How to tell pip to install test dependencies?

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]

Categories

Resources