Discover workspaces without using them in resolution (#3585)

Add minimal support for workspace discovery, only used for determining
paths in the bluejay commands.

We can now discover the workspace structure, namely that the
`pyproject.toml` of a package belongs to a workspace `pyproject.toml`
with members and exclusion. The globbing logic is inspired by cargo. We
don't resolve `workspace = true` metadata declarations yet.
This commit is contained in:
konsti 2024-05-21 19:17:26 +02:00 committed by GitHub
parent 5205165d42
commit 2ffd453003
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
43 changed files with 1007 additions and 151 deletions

View file

@ -0,0 +1,11 @@
from albatross import fly
try:
from bird_feeder import use
raise RuntimeError("bird-feeder installed")
except ModuleNotFoundError:
pass
fly()
print("Success")

View file

@ -0,0 +1,10 @@
from bird_feeder import use
try:
from albatross import fly
raise RuntimeError("albatross installed")
except ModuleNotFoundError:
pass
print("Success")

View file

@ -0,0 +1,8 @@
[project]
name = "bird-feeder"
version = "1.0.0"
dependencies = ["anyio>=4.3.0,<5"]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

View file

@ -0,0 +1,5 @@
import anyio
def use():
print("squirrel")

View file

@ -0,0 +1,8 @@
[project]
name = "albatross"
version = "0.1.0"
dependencies = ["tqdm>=4,<5"]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

View file

@ -0,0 +1,9 @@
import tqdm
def fly():
pass
if __name__ == '__main__':
print("Caw")

View file

@ -0,0 +1,4 @@
from albatross import fly
fly()
print("Success")

View file

@ -0,0 +1,8 @@
[project]
name = "albatross"
version = "0.1.0"
dependencies = ["tqdm>=4,<5"]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

View file

@ -0,0 +1,2 @@
def fly():
pass

View file

@ -0,0 +1,10 @@
from bird_feeder import use
try:
from albatross import fly
raise RuntimeError("albatross installed")
except ModuleNotFoundError:
pass
print("Success")

View file

@ -0,0 +1,8 @@
[project]
name = "bird-feeder"
version = "1.0.0"
dependencies = ["anyio>=4.3.0,<5"]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

View file

@ -0,0 +1,5 @@
import anyio
def use():
print("squirrel")

View file

@ -0,0 +1,12 @@
[project]
name = "albatross"
version = "0.1.0"
dependencies = ["tqdm>=4,<5"]
[tool.uv.workspace]
members = ["packages/*"]
exclude = ["excluded/*"]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

View file

@ -0,0 +1,5 @@
import tqdm
from bird_feeder import use
print("Caw")
use()

View file

@ -0,0 +1,4 @@
from albatross import fly
fly()
print("Success")

View file

@ -0,0 +1,10 @@
from bird_feeder import use
try:
from albatross import fly
raise RuntimeError("albatross installed")
except ModuleNotFoundError:
pass
print("Success")

View file

@ -0,0 +1,11 @@
[project]
name = "bird-feeder"
version = "1.0.0"
dependencies = ["anyio>=4.3.0,<5", "seeds"]
[tool.uv.sources]
seeds = { workspace = true }
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

View file

@ -0,0 +1,5 @@
import anyio
def use():
print("squirrel")

View file

@ -0,0 +1,8 @@
[project]
name = "seeds"
version = "1.0.0"
dependencies = ["boltons==24.0.0"]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

View file

@ -0,0 +1,5 @@
import boltons
def seeds():
print("sunflower")

View file

@ -0,0 +1,14 @@
[project]
name = "albatross"
version = "0.1.0"
dependencies = ["bird-feeder", "tqdm>=4,<5"]
[tool.uv.sources]
bird-feeder = { workspace = true }
[tool.uv.workspace]
members = ["packages/*"]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

View file

@ -0,0 +1,11 @@
import tqdm
from bird_feeder import use
def fly():
pass
if __name__ == "__main__":
print("Caw")
use()

View file

@ -0,0 +1,4 @@
from albatross import fly
fly()
print("Success")

View file

@ -0,0 +1,11 @@
[project]
name = "albatross"
version = "0.1.0"
dependencies = ["bird-feeder", "tqdm>=4,<5"]
[tool.uv.sources]
bird-feeder = { workspace = true }
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

View file

@ -0,0 +1,11 @@
import tqdm
from bird_feeder import use
def fly():
pass
if __name__ == "__main__":
print("Caw")
use()

View file

@ -0,0 +1,10 @@
from bird_feeder import use
try:
from albatross import fly
raise RuntimeError("albatross installed")
except ModuleNotFoundError:
pass
print("Success")

View file

@ -0,0 +1,11 @@
[project]
name = "bird-feeder"
version = "1.0.0"
dependencies = ["anyio>=4.3.0,<5", "seeds"]
[tool.uv.sources]
seeds = { workspace = true }
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

View file

@ -0,0 +1,5 @@
import anyio
def use():
print("squirrel")

View file

@ -0,0 +1,8 @@
[project]
name = "seeds"
version = "1.0.0"
dependencies = ["boltons==24.0.0"]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

View file

@ -0,0 +1,5 @@
import boltons
def seeds():
print("sunflower")

View file

@ -0,0 +1,2 @@
[tool.uv.workspace]
members = ["packages/*"]