-
-
Notifications
You must be signed in to change notification settings - Fork 611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pip-compile absolute links when given relative path #204
Comments
I ran into the same issue today. Why are relative paths are expanded? |
This has affected me too as I'm trying to install packages which are submodules of my project. It seems the issues arises here: https://github.com/pypa/pip/blob/develop/pip/req/req_install.py#L1131 I suspect it is hard to avoid as Which means that it is unlikely that we'd get the Personally, I'm going to try switching from using submodules and relative paths to having |
Looks like #325 is related |
I've been planning to move all of the requirements handling across all of our repos to using pip-tools and just realized it had this issue, which may completely shelve that plan. This is a pretty significant problem. |
So the core of this comes down to this function here, inside |
the relative paths should actually use |
as for why |
If your parrot is a git submodule, this works well: |
@rollcat almost works... except that we merged 2 repos so it is a slug and hardly speaks. |
I took another stab at trying to fix this in #702. |
I've been using the following post-processing step to get around the problem: #!/usr/bin/env python
import os
import re
import sys
pattern = re.compile(r"\s*-e\s+file://(?P<path>.*?)\n")
inputs = sys.stdin.readlines()
for line in inputs:
match = pattern.match(line)
if match:
path = match.group("path")
path = os.path.relpath(path)
line = f"-e {path}\n"
sys.stdout.write(line) |
A(nother) hacky solution, in
then to compile:
|
Ran into this issue as well. If I modify all my |
The workaround |
The
|
I'll note here that, without much guarantee, as long as it's pretty simple to do, I'll try to keep my relpaths branch updated. You can use $ pipx run --spec 'git+https://github.com/AndydeCleyre/pip-tools@feature/relpaths-post-6.8.0' pip-compile Doing so, you should be able to use the simple syntax: -e ./src/foo[extra] |
Hi! Thanks for this great tool. I'm stuck on using pip-tools with pyproject.toml since I have extras that include other extras, wanted to see if there are any updates on this. |
Do any pyproject.toml build backends support relative paths for dependencies? I don't think Poetry or Flit do. If my branch isn't working for certain extras configurations when using requirements.in please let me know, I'll try to reproduce and fix. |
The problem is not relative paths for me as it is that extra dependency groups that include other optional dependencies will be compiled to something with absotule paths. Example: # package_name is the name of the package itself
[project.optional-dependencies]
dev = ["package_name[test,tools]"]
tools = ["pip-tools"]
test = ["pytest""] The generated pip-compile for
Which is nonsensical to be honset. |
It looks like that's as intended based on discussion at #1685, and maybe @q0w or @atugushev can speak to the rationale. I personally don't like specifying a package as depending on itself, because that seems like an impossible infinite loop, but I now know it's commonly done. Instead I maintain dependency groups as So that example would be managed like:
$ pypc # inject deps according to above files into pyproject.toml, part of zpy, my wrapper of pip-tools
$ grep -A 3 optional-dependencies pyproject.toml [project.optional-dependencies]
dev = ["pip-tools", "pytest"]
tools = ["pip-tools"]
test = ["pytest"] |
I was using a mix of I was thinking of migrating to |
To be clear, the pypc here has nothing to do with the package of that name on PyPI, but is part of my project zpy (here on GitHub). You can check that implementation, but basically you can use tomlkit to inject the data without being hacky. |
@AndydeCleyre - I'm super grateful for all the time, energy, and patience you've invested into this issue. My team would certainly still love to see this get supported at some point, but we also understand the challenges involved and the resistance to the changes at this point in time. QUESTION: My question is related to the work-around. I was delighted to see that using FWIW, my goal is to have a lockfile that I can use locally during development within a monorepo, using relative paths to express dependencies on packages elsewhere in the monorepo. I also want the same lockfile to be used in a multi-stage Dockerfile where we copy a virtual environment between stages, but nothing else. Since Any input or advice would be greatly appreciated! |
I understand if this is not a suitable solution for your needs, but my It's been a while since I was testing out all the combinations of input and output observed with the $ ln -s ../package-name
$ echo 'file:./package-name' >>requirements.in |
Clever! That does seem to work! We'll consider using that as a short-term option. Many thanks! |
It's because how pip resolves recursive extras. When you do |
Using [options.extras_require]
test =
pytest
dev =
pip-tools
all =
%(dev)s
%(test)s |
|
Just to answer this question directly: Poetry does support relative paths for dependencies, I've tried it with a real example in one of my repos. |
I'm coming here from the #325 tl;dr. In pylint-dev/pylint-pytest@ I'm assuming that Dependabot does not pick up the two arguments to the pip-compile for some reason. Trying to use the #325 (comment) as a workaround (pylint-dev/pylint-pytest@b51c82f), then I get https://github.com/pylint-dev/pylint-pytest/actions/runs/7688457033/job/20949696021?pr=33#step:8:23
I want to require hashes (ofc), but it might be hard to get hashes from Any ideas? 😕 |
omg so happy to see this fixed ❤️ |
Unfortunately, the 24.3 release of pip seems to have re-raised this issue. To reproduce what I'm seeing, follow these steps:
Can we re-open this issue? As a temporary workaround, I'll use pip version 24.2. |
A new issue has been opened for this: #2131 Note from me: this problem does not occur if using uv (separate project with corresponding |
requirements.in:
compiles to:
It should compile to
It's not really useful for me to provide a requirements.txt file then to anybody unless they use a Mac and have the same name as me. Although if that person does exist, I would like to meet them.
The text was updated successfully, but these errors were encountered: