jazzband / pip-tools

A set of tools to keep your pinned Python dependencies fresh.
https://pip-tools.rtfd.io
BSD 3-Clause "New" or "Revised" License
7.6k stars 607 forks source link

Preserve relative paths for editable dependencies in output #2087

Closed macro1 closed 2 months ago

macro1 commented 2 months ago

Accomplishes preservation of relative dependency paths by reverting back to input requirements definition for editable dependencies.

There are a couple prior attempts of this. The two I read through treated this like a formatting problem, I'm not sure it is. The issue, as has been pointed out in #204 is that paths are converted into urls in the form of absolute paths within pip.

If we maintain knowledge of the original relative paths within pip-tools, the values will be maintained more faithfully, and the complexity should be lower.

This PR accomplishes it by forcing the return value from parse_requirements() to give the values we need elsewhere. A better approach may be to return something different than InstallRequirement or preserve the relationship with the parsed requirement and provide both where it makes sense.

Contributor checklist
Maintainer checklist
chrysle commented 2 months ago

The change looks good to me (we'll need a unit test, though). The CI failure is unrelated, I'll look into it.

A better approach may be to return something different than InstallRequirement

Do you have anything in mind?

macro1 commented 2 months ago

The change looks good to me (we'll need a unit test, though). The CI failure is unrelated, I'll look into it.

A better approach may be to return something different than InstallRequirement

Do you have anything in mind?

I was mainly thinking we could add a new structure containing the InstallRequirement and any other attributes pip-tools may need to track. However, I understand that it would impact many internal interfaces, which could pose some challenges.

chrysle commented 2 months ago

Ah yes, I love Windows, too. Will review soon.

chrysle commented 2 months ago

@macro1 Could you look into fixing the linting errors?