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 lock doesn't work with packages containing period in name #6832

Closed
jamesbraza opened this issue Aug 29, 2024 · 15 comments
Closed

uv lock doesn't work with packages containing period in name #6832

jamesbraza opened this issue Aug 29, 2024 · 15 comments
Assignees
Labels
question Asking for clarification or support

Comments

@jamesbraza
Copy link

jamesbraza commented Aug 29, 2024

I have a workspace that looks like this:

.
├── packages
│  └── seeds
│     ├── src
│     │  └── albatross
│     │     └── seeds
│     │        ├── __init__.py
│     │        ├── stub.py
│     │        ├── py.typed
│     │        └── version.py
│     └── pyproject.toml
├── src
│  └── albatross
│     ├── stub.py
│     ├── py.typed
│     └── version.py
├── pyproject.toml
└── uv.lock

And the name of the seeds package is albatross.seeds.

In my repo root's pyproject.toml, I have:

[tool.uv.sources]
albatross = {workspace = true}
"albatross.seeds" = {workspace = true}

Running uv lock, it:

  • Contains albatross-seeds not albatross.seeds
  • Running pip list I don't see albatross-seeds or albatross.seeds anywhere

Here's a subset of the uv.lock:

version = 1

[manifest]
members = [
    "albatross",
    "albatross-seeds",
]

[[package]]
name = "albatross"
version = "0.1.dev7+gbe81ca2.d20240829"
source = { editable = "." }
dependencies = []

[package.dev-dependencies]
dev = [
    { name = "pytest" },
]

[package.metadata]
requires-dist = []

[package.metadata.requires-dev]
dev = [
    { name = "pytest", specifier = ">=8" },
]

[[package]]
name = "albatross-seeds"
version = "0.1.dev7+ga33449c"
source = { editable = "packages/seeds" }
dependencies = [
    { name = "albatross" },
]

[package.metadata]
requires-dist = [
    { name = "albatross", editable = "." },
]
@charliermarsh
Copy link
Member

It’s normal for us to normalize the name like that. (Those are equivalent names from the perspective of the standards — they map to the exact same package.) Though it’s confusing that you aren’t seeing it in the environment at all? I’ll try to repro.

@jamesbraza
Copy link
Author

It’s normal for us to normalize the name like that.

Sounds good, though ideally the names exactly match for debugging ease.

Though it’s confusing that you aren’t seeing it in the environment at all? I’ll try to repro.

Yeah when I run uv sync the name albatross-seeds does not show up. I have to manually uv pip install it for it to work

@charliermarsh
Copy link
Member

Oh sorry, just to clarify, is albatross.seeds declared as a dependency of albatross? You might be missing this from the albatross pyproject.toml:

[project]
name = "albatross"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["albatross.seeds"]

@jamesbraza
Copy link
Author

jamesbraza commented Aug 30, 2024

is albatross.seeds declared as a dependency of albatross?

Yeah it is included as a dependency 👍 thanks for checking. That's not it in this case

@charliermarsh
Copy link
Member

Ok thanks! I’ll take a look tomorrow.

@charliermarsh
Copy link
Member

Does packages/seeds/pyproject.toml contain a build system? Do you mind sharing that section?

@jamesbraza
Copy link
Author

Does packages/seeds/pyproject.toml contain a build system? Do you mind sharing that section?

Yes it does, here's a minimal packages/seeds/pyproject.toml:

[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=64", "setuptools_scm>=8"]

[project]
dependencies = ["albatross"]
dynamic = ["version"]
name = "albatross.seeds"

[tool.ruff]
extend = "../../pyproject.toml"

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools_scm]
root = "../.."
version_file = "src/seeds/albatross/version.py"

@charliermarsh
Copy link
Member

Thanks. Sorry for all the back-and-forth, I'm just having trouble reproducing:

❯ uv sync
Using Python 3.12.1
Creating virtualenv at: .venv
Resolved 2 packages in 2ms
Installed 2 packages in 1ms
 + albatross==0.1.0 (from file:///Users/crmarsh/workspace/puffin/scripts/workspaces/albatross-root-workspace)
 + albatross-seeds==0.1.dev0+d20240830 (from file:///Users/crmarsh/workspace/puffin/scripts/workspaces/albatross-root-workspace/packages/seeds)

❯ uv pip list
Package         Version            Editable project location
--------------- ------------------ ------------------------------------------------------------------------------------------
albatross       0.1.0              /Users/crmarsh/workspace/puffin/scripts/workspaces/albatross-root-workspace
albatross-seeds 0.1.dev0+d20240830 /Users/crmarsh/workspace/puffin/scripts/workspaces/albatross-root-workspace/packages/seeds

Are you using pip list or uv pip list?

@jamesbraza
Copy link
Author

jamesbraza commented Aug 30, 2024

Both pip list and uv pip list don't show albatross.seeds or albatross-seeds.

Here is my albatross's pyproject.toml:

[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=64", "setuptools_scm>=8"]

[project]
dependencies = []
dynamic = ["version"]
name = "albatross"

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools_scm]
version_file = "src/albatross/version.py"

[tool.uv]
dev-dependencies = [
    "build",  # TODO: remove after https://github.com/astral-sh/uv/issues/6278
    "pytest>=8",  # Pin to keep recent
]

[tool.uv.sources]
"albatross.seeds" = {workspace = true}
albatross = {workspace = true}

[tool.uv.workspace]
members = ["packages/*"]

Does that help?

What I can do to force the install is:

uv sync
uv pip install -e packages/seeds

@charliermarsh
Copy link
Member

Try this:

[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=64", "setuptools_scm>=8"]

[project]
dependencies = ["albatross.seeds"]
dynamic = ["version"]
name = "albatross"

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools_scm]
version_file = "src/albatross/version.py"

[tool.uv]
dev-dependencies = [
    "build",  # TODO: remove after https://github.com/astral-sh/uv/issues/6278
    "pytest>=8",  # Pin to keep recent
]

[tool.uv.sources]
"albatross" = { workspace = true }
"albatross.seeds" = { workspace = true }

[tool.uv.workspace]
members = ["packages/*"]

@charliermarsh
Copy link
Member

I believe you're missing dependencies = ["albatross.seeds"] in albatross/pyproject.toml

@jamesbraza
Copy link
Author

Oh but albatross doesn't depend on albatross.seeds, just albatross.seeds depends on albatross. So that was not it

If you can't repro, I can add you to the private repo to take a look. Are you open to that?

@charliermarsh
Copy link
Member

Sure, I'm happy to take a look!

Can you clarify which command you're running, and from which directory, that you expect to get albatross.seeds into the environment? Running uv sync from the root will not install albatross.seeds if the root doesn't depend on it. You'd need to run uv sync --package albatross.seeds or uv sync from the seeds directory.

@jamesbraza
Copy link
Author

Running uv sync from the root will not install albatross.seeds if the root doesn't depend on it. You'd need to run uv sync --package albatross.seeds or uv sync from the seeds directory.

Ahhhhh okay that was my misunderstanding, I was thinking for workspaces that uv sync would automatically pull in the entire workspace.

Do you think:

  • uv sync should pull in the full workspace by default? This seems intuitive to me
  • Can we add a boolean flag to tool.uv.sources that marks workspaces to be included in a bare uv sync

Or we should document in the workspaces docs that uv sync doesn't pull in all workspaces by default.


Two workaround are:

  • Using --package arg to uv sync (as you suggest): uv sync --package albatross.seeds
  • Adding albatross.seeds to main package's dev-dependencies

@charliermarsh
Copy link
Member

On that first question, see: #5727. I just reopened it since it's now come up a few times.

@charliermarsh charliermarsh self-assigned this Sep 3, 2024
@charliermarsh charliermarsh added the question Asking for clarification or support label Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for clarification or support
Projects
None yet
Development

No branches or pull requests

2 participants