Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
eef04fe
Add support for workspaces
ofek Jun 2, 2024
0058046
Merge remote-tracking branch 'refs/remotes/origin/master' into worksp…
cjames23 Sep 22, 2025
9fc0f41
Fix not all reqs convert to deps issue
cjames23 Sep 22, 2025
c0152b2
Additional fixes for Requirements to Dependency conversion, fix tests…
cjames23 Sep 25, 2025
4dc4339
Fixing tests and typing issues found during workspaces dev.
cjames23 Sep 26, 2025
203b30e
Fix failing tests, handle subprocess buffering causing output issues …
cjames23 Sep 26, 2025
ef09d2a
Remove unused type-ignore comments
cjames23 Sep 26, 2025
9079b2a
Remove 3.8 from test workflows.
cjames23 Sep 26, 2025
83b119d
Drop 3.8 in classifiers and add changelogs to history docs.
cjames23 Sep 26, 2025
74d0daa
Fix requires-python for hatch
cjames23 Sep 26, 2025
4260722
Fix history doc for unreleased changes
cjames23 Sep 27, 2025
f448239
Fix: self test needed to have an additional arg, history doc formatting
cjames23 Sep 27, 2025
9c7a880
Update docs/history/hatch.md
cjames23 Sep 27, 2025
9d83042
Update docs/history/hatchling.md
cjames23 Sep 27, 2025
0a4b9af
Fix: formatting
cjames23 Sep 27, 2025
6215222
Merge remote-tracking branch 'origin/master'
cjames23 Sep 27, 2025
00f6c98
Merge remote-tracking branch 'origin/master' into workspaces
cjames23 Sep 27, 2025
6f07123
Add Workspace config model and tests for workspace support.
cjames23 Oct 3, 2025
e089124
Add workspace aware project discovery
cjames23 Oct 3, 2025
49640c1
Add support for workspaces
ofek Jun 2, 2024
2e82dc2
Fix not all reqs convert to deps issue
cjames23 Sep 22, 2025
1251148
Additional fixes for Requirements to Dependency conversion, fix tests…
cjames23 Sep 25, 2025
405a31b
Fixing tests and typing issues found during workspaces dev.
cjames23 Sep 26, 2025
29d8169
Drop 3.8 in classifiers and add changelogs to history docs.
cjames23 Sep 26, 2025
53f0a70
Fix history doc for unreleased changes
cjames23 Sep 27, 2025
ecb2bad
Fix: self test needed to have an additional arg, history doc formatting
cjames23 Sep 27, 2025
a81b13e
Fix: formatting
cjames23 Sep 27, 2025
6d3bd15
Add Workspace config model and tests for workspace support.
cjames23 Oct 3, 2025
c76dcd5
Add workspace aware project discovery
cjames23 Oct 3, 2025
5146231
Formatting changes and minor clean up
cjames23 Oct 5, 2025
ba36be5
Clean up merge conflicts with rebase and formatting
cjames23 Oct 5, 2025
98cd0e6
Merge remote-tracking branch 'origin/workspaces' into workspaces
cjames23 Oct 5, 2025
91e117c
Fix circular dependency, add properties to WorkspaceConfig,
cjames23 Oct 8, 2025
176faee
Utilize new workspace support for CI
cjames23 Oct 8, 2025
7c48bf9
Fix broad exception issue and other ruff errors
cjames23 Oct 8, 2025
8be9965
Change type for WorkspaceMember last_modified
cjames23 Oct 8, 2025
fa5272a
Move to using hatch env create to dogfood workspace support
cjames23 Oct 8, 2025
2ebe183
Revert workflow changes.
cjames23 Oct 8, 2025
88138e5
Fix member discovery issues.
cjames23 Oct 9, 2025
8416d4a
Fix formatting for dependencies block
cjames23 Oct 9, 2025
da10a4f
Handle case where project level workspace is not configured only envi…
cjames23 Oct 9, 2025
9a54b4d
Fix docs missing reference, update doc dependencies to handle depreca…
cjames23 Oct 9, 2025
af09e9a
Dogfooding workspaces with CI
cjames23 Oct 10, 2025
8261fce
Dogfood testing workspaces in CI
cjames23 Oct 10, 2025
aaa232c
Remove unnecessary scripts for dogfooding
cjames23 Oct 10, 2025
56e809b
Fix to ensure env creation happens before verifying hatchling
cjames23 Oct 10, 2025
89d105e
Revert changes for CI
cjames23 Oct 10, 2025
5502734
Change error type to enable dogfooding workspaces in CI
cjames23 Oct 14, 2025
1a5d7ae
Add back dependency on hatchling
cjames23 Oct 14, 2025
f55f61a
Add conflict logic for workspace members that are also declared depen…
cjames23 Oct 22, 2025
a136f72
Fix formatting for changes
cjames23 Oct 22, 2025
718be5e
Fix typing issues for project config
cjames23 Oct 22, 2025
b140f13
Fix bug for logic handling conflicts
cjames23 Oct 22, 2025
36570a8
Chore: Formatting
cjames23 Oct 22, 2025
07b4b90
Merge branch 'master' into workspaces
cjames23 Oct 22, 2025
b042bb5
Refactor to be configured at the environment level and including docu…
cjames23 Oct 30, 2025
35b258c
Fix dogfooding workspace
cjames23 Oct 31, 2025
65470c7
Fix implementation and tests to handle env var expansion, matrix vari…
cjames23 Oct 31, 2025
01b2900
Remove dead code not needed for per env workspace config, run fmt, ad…
cjames23 Nov 4, 2025
d5a4f96
Revert changes for xdist
cjames23 Nov 4, 2025
f0e243e
Fix members function to use original path logic. Address doc section …
cjames23 Nov 7, 2025
f19c01e
Format changes.
cjames23 Nov 7, 2025
7de70da
Add workspace docs to how-to nav
cjames23 Nov 7, 2025
25b5194
revert accidental re-formatting
ofek Nov 7, 2025
a969e08
remove unused properties
ofek Nov 7, 2025
9065415
properly enable workspace tests
ofek Nov 7, 2025
3272015
fixed docs formatting
ofek Nov 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-hatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
run: |-
uv pip install --system build
uv pip install --system .
uv pip install --system ./backend
hatch env create
# Windows installers don't accept non-integer versions so we ubiquitously
# perform the following transformation: X.Y.Z.devN -> X.Y.Z.N
Expand Down Expand Up @@ -166,7 +166,7 @@ jobs:
- name: Install Hatch
run: |-
uv pip install --system -e .
uv pip install --system -e ./backend
hatch env create
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ jobs:
- name: Install ourself
run: |
uv pip install --system .
uv pip install --system ./backend

- name: Benchmark
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Install ourself
run: |
uv pip install --system -e .
uv pip install --system -e ./backend
hatch env create

- name: Configure Git for GitHub Actions bot
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Install ourself
run: |
uv pip install --system -e .
uv pip install --system -e ./backend
hatch env create

- name: Display full version
run: hatch version
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
Expand All @@ -40,7 +40,7 @@ jobs:
- name: Install ourself
run: |
uv pip install --system -e .
uv pip install --system -e ./backend
hatch env create

- name: Run static analysis
run: hatch fmt --check
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 4 additions & 0 deletions docs/history/hatchling.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

- Drop support for Python 3.8

***Changed:***

- Drop support for Python 3.8

## [1.27.0](https://github.com/pypa/hatch/releases/tag/hatchling-v1.27.0) - 2024-11-26 ## {: #hatchling-v1.27.0 }

***Added:***
Expand Down
302 changes: 302 additions & 0 deletions docs/how-to/environment/workspace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,302 @@
# How to configure workspace environments

-----

Workspace environments allow you to manage multiple related packages within a single environment. This is useful for monorepos or projects with multiple interdependent packages.

## Basic workspace configuration

Define workspace members in your environment configuration using the `workspace.members` option:

```toml config-example
[tool.hatch.envs.default]
workspace.members = [
"packages/core",
"packages/utils",
"packages/cli"
]
```

Workspace members are automatically installed as editable packages in the environment.

## Pattern matching

Use glob patterns to automatically discover workspace members:

```toml config-example
[tool.hatch.envs.default]
workspace.members = ["packages/*"]
```

## Excluding members

Exclude specific packages from workspace discovery:

```toml config-example
[tool.hatch.envs.default]
workspace.members = ["packages/*"]
workspace.exclude = ["packages/experimental*"]
```

## Member-specific features

Install specific optional dependencies for workspace members:

```toml config-example
[tool.hatch.envs.default]
workspace.members = [
{path = "packages/core", features = ["dev"]},
{path = "packages/utils", features = ["test", "docs"]},
"packages/cli"
]
```

## Environment-specific workspaces

Different environments can include different workspace members:

```toml config-example
[tool.hatch.envs.unit-tests]
workspace.members = ["packages/core", "packages/utils"]
scripts.test = "pytest tests/unit"

[tool.hatch.envs.integration-tests]
workspace.members = ["packages/*"]
scripts.test = "pytest tests/integration"

[tool.hatch.envs.docs]
workspace.members = [
{path = "packages/core", features = ["docs"]},
{path = "packages/utils", features = ["docs"]}
]
```

## Test matrices with workspaces

Combine workspace configuration with test matrices:

```toml config-example
[[tool.hatch.envs.test.matrix]]
python = ["3.9", "3.10", "3.11", "3.12"]

[tool.hatch.envs.test]
workspace.members = ["packages/*"]
dependencies = ["pytest", "coverage"]
scripts.test = "pytest {args}"

[[tool.hatch.envs.test-core.matrix]]
python = ["3.9", "3.10", "3.11", "3.12"]

[tool.hatch.envs.test-core]
workspace.members = ["packages/core"]
dependencies = ["pytest", "coverage"]
scripts.test = "pytest packages/core/tests {args}"
```

## Performance optimization

Enable parallel dependency resolution for faster environment setup:

```toml config-example
[tool.hatch.envs.default]
workspace.members = ["packages/*"]
workspace.parallel = true
```

## Cross-member dependencies

Workspace members can depend on each other. When installed, pip or uv will resolve the dependency relationships:

```toml tab="packages/app/pyproject.toml"
[project]
name = "app"
dependencies = ["core", "utils"]
```

```toml tab="pyproject.toml"
[tool.hatch.envs.default]
workspace.members = [
"packages/core",
"packages/utils",
"packages/app"
]
```

All workspace members are installed as editable packages. Pip or uv handles resolving the dependencies between app, core, and utils during installation.

## Monorepo example

Complete configuration for a typical monorepo structure:

```toml config-example
# Root pyproject.toml
[project]
name = "my-monorepo"
version = "1.0.0"

[tool.hatch.envs.default]
workspace.members = ["packages/*"]
workspace.exclude = ["packages/experimental*"]
workspace.parallel = true
dependencies = ["pytest", "black", "ruff"]

[tool.hatch.envs.test]
workspace.members = [
{path = "packages/core", features = ["test"]},
{path = "packages/utils", features = ["test"]},
"packages/cli"
]
dependencies = ["pytest", "coverage", "pytest-cov"]
scripts.test = "pytest --cov {args}"

[tool.hatch.envs.lint]
detached = true
workspace.members = ["packages/*"]
dependencies = ["ruff", "black", "mypy"]
scripts.check = ["ruff check .", "black --check .", "mypy ."]
scripts.fmt = ["ruff check --fix .", "black ."]

[[tool.hatch.envs.ci.matrix]]
python = ["3.9", "3.10", "3.11", "3.12"]

[tool.hatch.envs.ci]
template = "test"
workspace.parallel = false # Disable for CI stability
```

## Library with plugins example

Configuration for a library with optional plugins:

```toml config-example
[tool.hatch.envs.default]
workspace.members = ["core"]
dependencies = ["pytest"]

[tool.hatch.envs.full]
workspace.members = [
"core",
"plugins/database",
"plugins/cache",
"plugins/auth"
]
dependencies = ["pytest", "pytest-asyncio"]

[tool.hatch.envs.database-only]
workspace.members = [
"core",
{path = "plugins/database", features = ["postgresql", "mysql"]}
]

[[tool.hatch.envs.plugin-test.matrix]]
plugin = ["database", "cache", "auth"]

[tool.hatch.envs.plugin-test]
workspace.members = [
"core",
"plugins/{matrix:plugin}"
]
scripts.test = "pytest plugins/{matrix:plugin}/tests {args}"
```

## Multi-service application example

Configuration for microservices development:

```toml config-example
[tool.hatch.envs.default]
workspace.members = ["shared"]
dependencies = ["pytest", "requests"]

[tool.hatch.envs.api]
workspace.members = [
"shared",
{path = "services/api", features = ["dev"]}
]
dependencies = ["fastapi", "uvicorn"]
scripts.dev = "uvicorn services.api.main:app --reload"

[tool.hatch.envs.worker]
workspace.members = [
"shared",
{path = "services/worker", features = ["dev"]}
]
dependencies = ["celery", "redis"]
scripts.dev = "celery -A services.worker.tasks worker --loglevel=info"

[tool.hatch.envs.integration]
workspace.members = [
"shared",
"services/api",
"services/worker",
"services/frontend"
]
dependencies = ["pytest", "httpx", "docker"]
scripts.test = "pytest tests/integration {args}"
```

## Documentation generation example

Configuration for generating documentation across packages:

```toml config-example
[tool.hatch.envs.docs]
workspace.members = [
{path = "packages/core", features = ["docs"]},
{path = "packages/cli", features = ["docs"]},
{path = "packages/plugins", features = ["docs"]}
]
dependencies = [
"mkdocs",
"mkdocs-material",
"mkdocstrings[python]"
]
scripts.serve = "mkdocs serve"
scripts.build = "mkdocs build"

[tool.hatch.envs.docs-api-only]
workspace.members = [
{path = "packages/core", features = ["docs"]}
]
template = "docs"
scripts.serve = "mkdocs serve --config-file mkdocs-api.yml"
```

## Development workflow example

Configuration supporting different development workflows:

```toml config-example
[tool.hatch.envs.dev]
workspace.members = ["packages/*"]
workspace.parallel = true
dependencies = [
"pytest",
"black",
"ruff",
"mypy",
"pre-commit"
]
scripts.setup = "pre-commit install"
scripts.test = "pytest {args}"
scripts.lint = ["ruff check .", "black --check .", "mypy ."]
scripts.fmt = ["ruff check --fix .", "black ."]

[tool.hatch.envs.feature]
template = "dev"
workspace.members = [
"packages/core",
"packages/{env:FEATURE_PACKAGE}"
]
scripts.test = "pytest packages/{env:FEATURE_PACKAGE}/tests {args}"

[[tool.hatch.envs.release.matrix]]
package = ["core", "utils", "cli"]

[tool.hatch.envs.release]
detached = true
workspace.members = ["packages/{matrix:package}"]
dependencies = ["build", "twine"]
scripts.build = "python -m build packages/{matrix:package}"
scripts.publish = "twine upload packages/{matrix:package}/dist/*"
```
1 change: 1 addition & 0 deletions docs/meta/authors.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
- Olga Matoula [:material-github:](https://github.com/olgarithms) [:material-twitter:](https://twitter.com/olgarithms_)
- Philip Blair [:material-email:](mailto:[email protected])
- Robert Rosca [:material-github:](https://github.com/robertrosca)
- Cary Hawkins [:material-github](https://github.com/cjames23)
1 change: 1 addition & 0 deletions docs/plugins/environment/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ All environment types should [offer support](#hatch.env.plugin.interface.Environ
- dependencies_in_sync
- sync_dependencies
- dependency_hash
- project_dependencies
- project_root
- sep
- pathsep
Expand Down
Loading
Loading