Relative/local paths for file:// -based dependencies #4221
-
I am trying to list a dependency that is located in a local directory named [project]
name = "bar"
dependencies = [
"foo @ file://./deps/foo", # Does not work
"foo @ deps/foo", # Does not work (violates PEP508
{name="foo", path="deps/foo"}, # Does not work (you can do something very similar using poetry)
"foo @ file://$PWD/deps/foo", # Does not work, unless you use substenv, but that also becomes a mess
"foo @ {root:uri}/deps/foo", # Does not work unless you use hatch, but the last thing we need is another project management system on top of our project management system
"foo @ file:///full/path/to/deps/foo", # Works, but falls apart unless all employees have the same username, os and directory structure
] This feels like a regression from ...
install_requires=[f"foo @ file://{os.getwd()}/deps/foo"]
... I understand that there may be some problems related to if you install the package using either: cd bar/
python3 -m pip install .
# versus
cd ../
python3 -m pip install ./bar But that could be "solved" by saying that all relative paths specified in the So my question is: Are there any plans on supporting either:
Edit: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
Hi @sillydan1, right now this is a bit complicated because the As far as I understand, the workarounds that you mentioned (template expansion as in
This means that If anyone in the community wants to champion changes and go through the PEP process, I think that Alternatively, if there is interest by the community and people are willing to contribute, we can consider a different approach via the Note however that while Footnotes
|
Beta Was this translation helpful? Give feedback.
-
@sillydan1 and you should. Except you don't really have to pre-compile wheels in this case. Though, let's take a step back and talk about your initial motivation. You didn't explicitly spell it out, but it sounds like you're either making (1) an application or (2) a library that depends on some other library that is a part of your ecosystem and is probably under your control too, being developed on the same machine, even. Perhaps, the development of the pair of projects is coupled more than it should be. Please, correct me if I guessed something wrong here. Let's say your project is A and the dependency is B. And you want to make an environment where you develop A (possibly with simultaneous changes to B). I suppose you want to use that virtual environment for development and testing. So you want a set of packages installed there that satisfy your needs a.k.a your project dependency specifiers combined with your testing and development tooling. The requirements can be declared in many ways, some with loose versions, some with pins, and maybe even, there would be an entry Putting such a specification in a project metadata is plain wrong. You don't really describe a package but the environment around it (that may, or may not also include that package). So you're looking to describe a virtualenv. In the pip world, the best place to do so is a requirements file combined with a constraints file (the latter can be generated from the former under your target OS+Python+arch using In a more complicated setup, you'd probably have a cascade of requirement+constraint files included in one another. To implement repeatable venv provisioning, it's common to use "workflow tools", such as tox or nox, or even GNU/make. These allow you defining short commands that would call the underlying tooling, so you don't have to. They are also reusable in CI and other dev machines. The above is a pip-centric approach, other tools provide slightly different (but the same in spirit) ways of doing this. Finally, people often want to put those dependency sets into P.S. I complained about the packaging concept confusions in a related project just a few month ago (jazzband/pip-tools#1326 (comment)). And this entire situation with misunderstandings makes it hard to document them properly in PyPUG even (pypa/packaging.python.org#1427). If you want to help disentangling this — you're welcome to participate in more packaging discussions... |
Beta Was this translation helpful? Give feedback.
Hi @sillydan1, right now this is a bit complicated because the
setuptools
project does not have control over thepyproject.toml
specification and any significant change need to go through a PEP approval process (the same is valid for the dependency specifier syntax started by PEP508).As far as I understand, the workarounds that you mentioned (template expansion as in
{root:uri}
or$PWD
) are technically forbidden by thepyproject.toml
standard. In particular, the spec says: