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

Support private virtualenvs and locks for workspace members #4574

Open
idlsoft opened this issue Jun 26, 2024 · 7 comments
Open

Support private virtualenvs and locks for workspace members #4574

idlsoft opened this issue Jun 26, 2024 · 7 comments
Labels
needs-decision Undecided if this should be done needs-design Needs discussion, investigation, or design

Comments

@idlsoft
Copy link
Contributor

idlsoft commented Jun 26, 2024

Workspace members currently share a single uv.lock and .venv, which comes with a couple of side-effects:

  • there can't be two packages with conflicting dependencies, even if they are independent executables.
  • you can accidentally reference code from any workspace member without having to declare a dependency, and unit-tests or linters are unlikely to notice.

This is unlike most languages, but usually no big deal, and having one .venv is convenient for most use-cases.

But it isn't for everyone, and I think it would be useful to introduce a distinct kind of member, which:

  • will be excluded from the shared uv.lock/.venv
  • will have its own uv.lock/.venv, with only itself and its dependencies (workspace and otherwise).

I have tried to achieve this with one simple change, and it mostly works, but it's clunky and I think it could be much better.

Let's say we have this tree:

monorepo
├── apps
│   ├── app1
│   └── app2
└── libs
    ├── lib1
    └── lib2

And let's say we're ok with libraries using the default shared lock, but apps should not.

The workspace could be defined as

[tool.uv.workspace]
members = ["libs/*"]
private-members = ["apps/*"]

This is both explicit and efficient because workspace discovery won't have to read individual pyproject.toml files.
Wrote a basic implementation with a sample workspace.

Hope this makes sense.

@mjclarke94
Copy link

This would be a really clean solution to the refactor I'm trying to do.

It also seems like a lightweight change that unlocks a lot of the what Pants can do (finding the minimum set of dependencies required for each project, although that works per file and is a lot more powerful).

@zanieb zanieb added needs-design Needs discussion, investigation, or design needs-decision Undecided if this should be done labels Jun 27, 2024
idlsoft added a commit to idlsoft/uv that referenced this issue Jun 28, 2024
idlsoft added a commit to idlsoft/uv that referenced this issue Jun 28, 2024
idlsoft added a commit to idlsoft/uv that referenced this issue Jun 28, 2024
idlsoft added a commit to idlsoft/uv that referenced this issue Jun 28, 2024
idlsoft added a commit to idlsoft/uv that referenced this issue Jun 28, 2024
idlsoft added a commit to idlsoft/uv that referenced this issue Jun 28, 2024
idlsoft added a commit to idlsoft/uv that referenced this issue Jun 28, 2024
idlsoft added a commit to idlsoft/uv that referenced this issue Jun 28, 2024
@charliermarsh
Copy link
Member

How does this differ from excluding the projects from the workspace?

@idlsoft
Copy link
Contributor Author

idlsoft commented Jun 28, 2024

How does this differ from excluding the projects from the workspace?

Excluded projects cannot use workspace dependencies, these can.
And they're allowed to have conflicting dependencies because they use private uv.lock and .venv directories and aren't included in members_as_requirements

@charliermarsh
Copy link
Member

It's an interesting idea... I understand the motivation but needs some thought / discussion before committing to it.

@idlsoft
Copy link
Contributor Author

idlsoft commented Jun 28, 2024

needs some thought / discussion before committing to it.

Yesterday I couldn't resist trying to implement it, it turned out to be a lot more straightforward than I expected.
Created #4610 as a POC.

idlsoft added a commit to idlsoft/uv that referenced this issue Oct 9, 2024
idlsoft added a commit to idlsoft/uv that referenced this issue Oct 9, 2024
idlsoft added a commit to idlsoft/uv that referenced this issue Oct 10, 2024
idlsoft added a commit to idlsoft/uv that referenced this issue Oct 10, 2024
idlsoft added a commit to idlsoft/uv that referenced this issue Oct 11, 2024
idlsoft added a commit to idlsoft/uv that referenced this issue Oct 11, 2024
idlsoft added a commit to idlsoft/uv that referenced this issue Oct 14, 2024
idlsoft added a commit to idlsoft/uv that referenced this issue Oct 15, 2024
idlsoft added a commit to idlsoft/uv that referenced this issue Oct 15, 2024
idlsoft added a commit to idlsoft/uv that referenced this issue Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-decision Undecided if this should be done needs-design Needs discussion, investigation, or design
Projects
None yet
Development

No branches or pull requests

5 participants