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

uv add pkg adds extraneous new lines in project.dependencies if the pyproject.toml has CRLF ending #7621

Closed
Ravencentric opened this issue Sep 22, 2024 · 2 comments · Fixed by #7640
Assignees
Labels
bug Something isn't working good first issue Good for newcomers help wanted Contribution especially encouraged windows Specific to the Windows platform

Comments

@Ravencentric
Copy link

Ravencentric commented Sep 22, 2024

I encountered this when I ported my existing pyproject.toml to use uv on Windows 11. Here's the reproduction with powershell on Windows 11:

❯ uv --version
uv 0.4.15 (0d81bfbc6 2024-09-21)

Setup a dummy project:

❯ uv init hello-world
Initialized project `hello-world` at `C:\Users\raven\Documents\GitHub\hello-world`
❯ cd .\hello-world\
❯ uv add pydantic httpx tomli requests typing-extensions wheel importlib-metadata
Using Python 3.12.4 interpreter at: C:\Users\raven\AppData\Local\Programs\Python\Python312\python.exe
Creating virtual environment at: .venv
Resolved 19 packages in 19ms
Installed 18 packages in 50ms
 + annotated-types==0.7.0
 + anyio==4.6.0
 + certifi==2024.8.30
 + charset-normalizer==3.3.2
 + h11==0.14.0
 + httpcore==1.0.5
 + httpx==0.27.2
 + idna==3.10
 + importlib-metadata==8.5.0
 + pydantic==2.9.2
 + pydantic-core==2.23.4
 + requests==2.32.3
 + sniffio==1.3.1
 + tomli==2.0.1
 + typing-extensions==4.12.2
 + urllib3==2.2.3
 + wheel==0.44.0
 + zipp==3.20.2

Everything looks fine here, uv created pyproject.toml file ends with LF on windows:

❯ cat .\pyproject.toml
[project]
name = "hello-world"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
    "httpx>=0.27.2",
    "importlib-metadata>=8.5.0",
    "pydantic>=2.9.2",
    "requests>=2.32.3",
    "tomli>=2.0.1",
    "typing-extensions>=4.12.2",
    "wheel>=0.44.0",
]

Add another dep, still fine, still ends with LF.

❯ uv add pyyaml
Resolved 20 packages in 20ms
Installed 1 package in 9ms
 + pyyaml==6.0.2
❯ cat .\pyproject.toml
[project]
name = "hello-world"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
    "httpx>=0.27.2",
    "importlib-metadata>=8.5.0",
    "pydantic>=2.9.2",
    "pyyaml>=6.0.2",
    "requests>=2.32.3",
    "tomli>=2.0.1",
    "typing-extensions>=4.12.2",
    "wheel>=0.44.0",
]

Change LF to CRLF:

$text = Get-Content .\pyproject.toml
❯ echo $text > .\pyproject.toml

Check again:

❯ cat .\pyproject.toml
[project]
name = "hello-world"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
    "httpx>=0.27.2",
    "importlib-metadata>=8.5.0",
    "pydantic>=2.9.2",
    "pyyaml>=6.0.2",
    "requests>=2.32.3",
    "tomli>=2.0.1",
    "typing-extensions>=4.12.2",
    "wheel>=0.44.0",
]

Add a new dep

❯ uv add attrs
Resolved 21 packages in 229ms
Prepared 1 package in 168ms
Installed 1 package in 11ms
 + attrs==24.2.0

Extraneous new lines got added and the ending got changed to LF

❯ cat .\pyproject.toml
[project]
name = "hello-world"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [

    "attrs>=24.2.0",

    "httpx>=0.27.2",

    "importlib-metadata>=8.5.0",

    "pydantic>=2.9.2",

    "pyyaml>=6.0.2",

    "requests>=2.32.3",

    "tomli>=2.0.1",

    "typing-extensions>=4.12.2",

    "wheel>=0.44.0",
]
@charliermarsh
Copy link
Member

Oh interesting, thank you for this.

@charliermarsh charliermarsh added bug Something isn't working windows Specific to the Windows platform good first issue Good for newcomers help wanted Contribution especially encouraged labels Sep 23, 2024
@my1e5
Copy link
Contributor

my1e5 commented Sep 23, 2024

This bug also affects tool.uv.dev-dependencies in the same way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Contribution especially encouraged windows Specific to the Windows platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants