Skip to content
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

requirements.txt allows editable paths to be quoted #3621

Open
charliermarsh opened this issue May 15, 2024 · 3 comments
Open

requirements.txt allows editable paths to be quoted #3621

charliermarsh opened this issue May 15, 2024 · 3 comments
Labels
compatibility Compatibility with a specification or another tool

Comments

@charliermarsh
Copy link
Member

It seems like requirements.txt allows you to put editable paths in quotes (single or double). It does not allow quotes elsewhere though:

# Ok
-e "./scripts/packages/black_editable"

# Not ok
"./scripts/packages/black_editable"
black @ "./scripts/packages/black_editable"
@charliermarsh charliermarsh added the compatibility Compatibility with a specification or another tool label May 15, 2024
@charliermarsh
Copy link
Member Author

Low-priority, maybe we fix if it comes up.

@Briandye1987
Copy link

Ok

-e "./scripts/packages/black_editable"

Not ok

"./scripts/packages/black_editable"
black @ "./scripts/packages/black_editable"

@nkitsaini
Copy link

I was poking into this and found some related compatibility issues, which might or might not make sense for uv to address. I am documenting them here as it might be efficient to batch together the implementation for these.

Case 1: Pip treats options similar to shell arguments

-c file\ name

# pip: reads `file name`
# uv: reads `file\ name` (including forward slash)

Case 2: Pip allows splitting requirements in multiple lines by using \

httpx \
  == 0.0.1

# pip: tries to install `httpx == 0.0.1`
# uv: errors out parsing forward slash

Case 3: Pip silently ignores some options

httpx == 0.0.1 -r ./requirement.txt

# pip: installs httpx and silently ignores `requirement.txt`
# uv: parsing error. (I feel this is the right thing to do here over maintaining compatibility)

Pip's behaviour

  1. Read file content
  2. Join lines depending on if they end with a forward slash
  3. Strip out comments (both inline and independent)
  4. replace environment variables
  5. For each line
    a. split line by the first occurrence of -
    b. The first part is treated as requirement definition and second part is treated as options (editable, constraints etc.).
    c. The first part (requirements) goes through a dedicated parser to split version, name, extras etc.
    d. The second part (options) is parsed by treating them similar to POSIX shell arguments.

Source: 1-4, 5.a-5.b, 5.c, 5.d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Compatibility with a specification or another tool
Projects
None yet
Development

No branches or pull requests

3 participants