Reputation: 3017
I have a pyproject.toml
file with some python packages.
It has a section like:
dependencies = [
'pandas == 1.4.3',
'streamlit == 1.11.1',
...
]
I then usually install these dependencies using
python -m pip install .[dependencies]
I need to install a new package that has a conflict in one of its dependencies. I checked, and the "conflict" is superficial - ie. the maintainers of the new package just "forgot" to update the requirements.txt to allow pandas>=1.4.
I can do this by running python -m pip install {new_package} --no-deps
But is there any way to do this within the pyproject.toml
file?
Upvotes: 13
Views: 755
Reputation: 746
pip
's direct references with the --no-deps flag, inside pyproject.toml
directly.Your dependencies entry should look something like:
dependencies = [
'pandas == 1.4.3',
'streamlit == 1.11.1',
'{{NEW_PACKAGE}} @ git+https://github.com/{{USER}}/{{NEW_PACKAGE}}.git#egg={{NEW_PACKAGE}} --no-deps',
]
A more robust solution albeit more involed woulde be to define the problematic deps separatelly using optional-dependencies:
[project]
dependencies = [
'pandas == 1.4.3',
'streamlit == 1.11.1',
]
[project.optional-dependencies]
main = [
'pandas == 1.4.3',
'streamlit == 1.11.1',
]
problematic = [
'new-package'
]
and then installing them separatelly:
> python -m pip install .[main]
> python -m pip install .[problematic] --no-deps
For convenience, you could wrapp both install commands in a custom bash/ps1 script:
python -m pip install .[main] && python -m pip install .[problematic] --no-deps
python -m pip install .[main]; python -m pip install .[problematic] --no-deps
Upvotes: 0