The problem I am facing is that setuptools overwrite the sub-package dependency requirements.
Example:
setup.py
import os
from setuptools import setup
setup(
name="test",
version="0.1",
author="myself",
author_email="info@example.com",
description="How to manage dependencies?",
license="MIT",
classifiers=[
"Development Status :: 3 - Alpha"
],
zip_safe=False,
install_requires=[
'dependency-injector',
]
)
Installation successful via python setup.py install
Output:
(venv) alex@ws:~$ pip freeze
dependency-injector==3.14.12
six==1.12.0
test==0.1
If you use the following setup.py including six as dependency (because you need it in your package), then you hit problems, because dependency-injector also needs the dependency though they have defined a fixed version range.
import os
from setuptools import setup
setup(
name="test",
version="0.1",
author="myself",
author_email="info@example.com",
description="How to manage dependencies?",
license="MIT",
classifiers=[
"Development Status :: 3 - Alpha"
],
zip_safe=False,
install_requires=[
'dependency-injector',
'six'
]
)
Output:
error: six 1.13.0 is installed but six<=1.12.0,>=1.7.0 is required by {'dependency-injector'}
(venv) alex@ws:~$ pip freeze
dependency-injector==3.14.12
six==1.13.0
test==0.1
For sure a working solution is just to repeat the same six version range which dependency-injector uses (see the requirements.txt file in their repo), though I would really like to avoid this duplicate definition of dependencies, because e.g. dependency-injector might upgrade the six version dependency and thus I need to also update my package. So I will always try to mimic their requirements which is bad practice.
I think actually the only clean solution would be that setuptools builds up a dependency tree and and then uses the versions matching the requirements of all dependencies. Is this realistic? How can it be achieved or what is the recommended best-practice in such a case as described above?