How to avoid installing an "install_requires" package of a pip requirement? - pip

When installing with pip from a requirements.txt file, is there a way to override a requirement's dependencies which are installed due to being listed under install_requires in setup.py of the package?
My specific case is south being installed as a dependency of django-paypal, even though I'm using Django 1.8 so I don't want south installed - it just confuses django's own migrate command.

Related

Does pip only use PyPI or does it use other domains to find packages?

I know that by default, pip uses PyPI to look for packages. I would like to know if there are other domains other than PypI that pip uses.
PIP Can install from
PyPI
VCS project URL
Local project directories
Local or remote source archives
to run from a local passage you can input pip install /opt/mypackage
Finally, run pip install --help to see all installation options
PIP can install from many different sources. You can find the whole list here
You can also setup your own Python package repository and configure pip to install from there.

installation of Neuraxle package with dependancies conflicts

Trying to install Neuraxle, i am facing to conflict caused by dependancies :
neuraxle 0.8.1 depends on markupsafe==2.0.1
jinja2 3.1.2 depends on MarkupSafe superior or =2.0
werkzeug 2.2.2 depends on MarkupSafe superior or =2.1.1.
Is it possible to force dependancies configuration files to end installation ?
Trying to update each package with pip processus manually.
thanks
The jinja2 and werkzeug packages are not required to run most features of Neuraxle, only the REST API serving feature.
There is a way to install a library on pip without all of its dependencies. See here:
https://stackoverflow.com/a/12759996/2476920
--no-deps, --no-dependencies
Ignore package dependencies
So you can run pip with a --no-dependencies flag.
If you want to manually install the other dependencies, you can find them here: https://github.com/Neuraxio/Neuraxle/blob/af917c984241178436a759be3b830e6d8b03245f/setup.py#L93

pip install from local directory doesnt add [build-system] dependencies

In our project (Locust) we use setuptools_scm for versioning, so it is needed for all installations from local directory.
We used to have this specified in setup.py:
setup(
setup_requires=["setuptools_scm>=6.2"],
...
)
But we have upgraded to use setup.cfg and pyproject.toml
[build-system]
requires = ["setuptools_scm>=6.2", ...]
This works nicely in most cases, but it does not install setuptools_scm if someone does pip install -e . (it doesnt work for pip install . either but that is less important)
With no setuptools_scm installed the local version becomes 0.0.0:
~/git/locust pip install -e .
Looking in indexes: https://pypi.org/simple
...
Running setup.py develop for locust
Successfully installed locust-0.0.0
... and that makes me very sad.
What is the appropriate way make pip install setuptools_scm when installing from source?
I could of course add it as a regular dependency in setup.cfg, but that would make thousands of users download setuptools_scm even when it is not needed (when installing from PyPi)

Make `pip install <package>` programatically install a different version of <package> depending on the other packages the user has installed?

I'm a Python package developer looking to distribute my to some users. Within these users, some of them are using JupyterLab 2.0, and some are using JupyterLab 3.0.
I'm wondering if it's possible if I can change some settings (or code in setup.py) so that, depending on what version of JupyterLab users have, a different version of my is installed when the user runs pip install <package>.
For example:
User 1 has JupyterLab 2.0 installed. When they run pip install <package>, it installs package version 0.1.1.
User 2 has JupyterLab 3.0 installed. When they run pip install <package>, it installs package version 0.2.1.
Thanks for any information!
In your setup.py, you can just use conditional statements to check the current version like below and set the correct installation version you want to install
import jupyterlab
version = jupyterlab.__version__
if version.startswith("2"):
install_version="0.0.1"
elif version.startswith("3"):
install_version="0.0.2"
Note: Don't forget to use exception handling to check if jupyterlab is at least installed
NOTE: This will not work if its used with pip. This will only work with source distribution and installed using pip install setup.py

Installing Python Package to Conda Env Without Using Conda

I have a fresh Anaconda environment in which I would like to install the latest release of mysql-connector-python (v2.1.3). I'm on a CentOS6 system. The problem is, the newest Conda-hosted package is 2.0.3 and because the connector is not currently hosted on PyPI, it cannot be installed via Pip. (Pip's --allow-external option has been deprecated.)
I know that I can easily install the package via yum install, but I believe that will install it outside of the Conda environment.
Is there any way, using yum or otherwise, to isolate this package solely to this particular Conda environment?
Turns out this is surprisingly simple. Just download the source for the Python package that is not available on PyPI and pip install at the source directory. Just remember to have the Conda environment you want to install to active and Pip will correctly isolate the install to env scope.
I was unaware of Pip's install from local options, so big thanks to the folks on the Anaconda mailing list for their help with this.

Resources