pants
pants copied to clipboard
pants_requirements() does not play nicely with python_distribution()
Describe the bug
When trying to package a Pants plugin using python_distribution()
while also using pants_requirements()
for development of said plugin, the packaged plugin will include an install requirement on pantsbuild.pants
in the autogenerated setup.py
file.
While the fact that this is happening isn't strange (the generated python_requirement()
does provide the 3rd-party code your 1st-party code is using), this should in the best of worlds not be happening (since a Pants plugin will always have Pants available anyway).. but even if it was the expected behaviour, Pants refuses to install the plugin:
ERROR: Cannot install foobar-plugin==0.1.0 because these package versions have conflicting dependencies.
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
The conflict is caused by:
foobar-plugin 0.1.0 depends on pantsbuild.pants==2.21.0.dev1
The user requested (constraint) pantsbuild-pants==2.21.0.dev1
I've tried to work around the issue by explicitly excluding the pants_requirements()
dependency on both the python_distribution()
and the python_sources()
targets to no avail - the Pants dependency still manages to weasel its way into the generated setup.py
. It's also not possible to tweak install_requires
yourself on the python_artifact()
since Pants wants to own and control that key.
The only "solution" I've found is to not have Pants generate the setup.py
file for me.
Pants version 2.21.0dev1
OS MacOS
Root caused in https://github.com/pantsbuild/pants/issues/21050#issuecomment-2165039127