-
Notifications
You must be signed in to change notification settings - Fork 16
switch to dep groups (PEP 735) #145
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
base: main
Are you sure you want to change the base?
Changes from all commits
ed990be
47794f9
8d13d80
66f4bf1
3bef2e1
4c624bb
7e546ea
77e0622
93b4c3f
42500e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -69,21 +69,18 @@ Documentation = "{{ dev_platform_url }}/{{ username }}/{{ project_slug }}/blob/m | |||||
| {%- endif %} | ||||||
| Download = "https://pypi.org/project/{{ project_slug }}/#files" | ||||||
|
|
||||||
| {%- if not use_hatch_envs %} | ||||||
| [project.optional-dependencies] | ||||||
| # The groups below should be in the [development-groups] table | ||||||
| # They are here now because hatch hasn't released support for them but plans to | ||||||
| # in Mid November 2025. | ||||||
| # When not using hatch environments, we keep optional-dependencies for backward compatibility | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| dev = [ | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this entire section can get moved to development groups but i may be wrong! it's hard to wrap my head around a jinja template in a pr!! but dev definitely belongs in development-groups not optional-dependencies
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah they are really annoying to review w/o indents, aren't they? there's already an equivalent dep group for
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. they are!! |
||||||
| "hatch", | ||||||
| "pre-commit", | ||||||
| {%- if not use_hatch_envs %} | ||||||
| "{{ package_name }}[ | ||||||
| {%- if documentation!="" %}docs,{% endif -%} | ||||||
| {%- if use_test %}tests,{% endif -%} | ||||||
| {%- if use_lint %}style,{% endif -%} | ||||||
| {%- if use_types %}types,{% endif -%} | ||||||
| audit]", | ||||||
| {%- endif %} | ||||||
| ] | ||||||
|
|
||||||
| docs = [ | ||||||
|
|
@@ -104,7 +101,6 @@ docs = [ | |||||
|
|
||||||
| build = [ | ||||||
| "pip-audit", | ||||||
| "twine", | ||||||
| ] | ||||||
|
|
||||||
| {%- if use_test %} | ||||||
|
|
@@ -129,6 +125,67 @@ types = [ | |||||
| "mypy", | ||||||
| ] | ||||||
| {%- endif %} | ||||||
| {%- endif %} | ||||||
|
|
||||||
| {%- if use_hatch_envs %} | ||||||
| ################################################################################ | ||||||
| # Dependency Groups (PEP 735) | ||||||
| ################################################################################ | ||||||
|
|
||||||
| [dependency-groups] | ||||||
| # Development tools that are used across multiple environments | ||||||
| dev = [ | ||||||
| "hatch", | ||||||
| "pre-commit", | ||||||
| ] | ||||||
|
|
||||||
| {%- if documentation != "no" %} | ||||||
| docs = [ | ||||||
| {%- if documentation == "sphinx" %} | ||||||
| "sphinx~=8.0", | ||||||
| "myst-parser>=4.0", | ||||||
| "pydata-sphinx-theme~=0.16", | ||||||
| "sphinx-autobuild>=2024.10.3", | ||||||
| "sphinx-autoapi>=3.6.0", | ||||||
| "sphinx_design>=0.6.1", | ||||||
| "sphinx-copybutton>=0.5.2", | ||||||
| {%- elif documentation == "mkdocs" %} | ||||||
| "mkdocs-material ~=9.5", | ||||||
| "mkdocstrings[python] ~=0.24", | ||||||
| "mkdocs-awesome-pages-plugin ~=2.9", | ||||||
| {% endif %} | ||||||
| ] | ||||||
|
|
||||||
| {%- endif %} | ||||||
| build = [ | ||||||
| "pip-audit", | ||||||
| "twine", | ||||||
| ] | ||||||
|
|
||||||
| {%- if use_test %} | ||||||
| tests = [ | ||||||
| "pytest", | ||||||
| "pytest-cov", | ||||||
| "pytest-raises", | ||||||
| "pytest-randomly", | ||||||
| "pytest-xdist", | ||||||
| ] | ||||||
|
|
||||||
| {%- endif %} | ||||||
| {%- if use_lint %} | ||||||
| style = [ | ||||||
| "pydoclint", | ||||||
| "ruff", | ||||||
| ] | ||||||
|
|
||||||
| {%- endif %} | ||||||
| {%- if use_types %} | ||||||
| types = [ | ||||||
| "mypy", | ||||||
| ] | ||||||
|
|
||||||
| {%- endif %} | ||||||
| {%- endif %} | ||||||
|
|
||||||
|
|
||||||
| ################################################################################ | ||||||
|
|
@@ -276,9 +333,16 @@ installer = "uv" | |||||
| # This table installs the tools you need to test and build your package | ||||||
| [tool.hatch.envs.build] | ||||||
| description = """Test the installation the package.""" | ||||||
| features = [ | ||||||
| builder = true | ||||||
| dependency-groups = [ | ||||||
| "build", | ||||||
| ] | ||||||
| # Explicit dependencies are required as a workaround for dependency-groups | ||||||
| # not being installed in builder environments (see https://github.com/pypa/hatch/issues/2152) | ||||||
| # This ensures twine is available when scripts run | ||||||
| dependencies = [ | ||||||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this irks me |
||||||
| "twine", | ||||||
| ] | ||||||
|
Comment on lines
+340
to
+345
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need to test this again - the pr to fix this was merged, but when I tested this last, it worked as long as builder was set to true in the environment definition here. Let me do a sanity check on it - @mathematicalmichael, did you run through the template and try it with Hatch 1.16.2 without adding twine explicitly? I'm sorry if I missed a discussion of this, but I thought it worked, but you just had to make it a builder envt. it's possible i just had the newest commit/fix installed and didn't realize it but i thought that was the patch for now - builder=true.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yup. in commit history i tried to get rid of twine explicitly a few times and it kept failing. the only other workaround was to i only pushed up stuff that passed locally to CI. everything else failed. |
||||||
| detached = true | ||||||
|
|
||||||
| # This table installs created the command hatch run install:check which will build and check your package. | ||||||
|
|
@@ -293,7 +357,7 @@ check = [ | |||||
| {%- if use_test %} | ||||||
| [tool.hatch.envs.test] | ||||||
| description = """Run the test suite.""" | ||||||
| features = [ | ||||||
| dependency-groups = [ | ||||||
| "tests", | ||||||
| ] | ||||||
|
|
||||||
|
|
@@ -309,8 +373,8 @@ run = "pytest {args:--cov={{ package_name }} --cov-report=term-missing --cov-rep | |||||
| # This sets up a hatch environment with associated dependencies that need to be installed | ||||||
| [tool.hatch.envs.docs] | ||||||
| description = """Build or serve the documentation.""" | ||||||
| # Install optional dependency test for docs | ||||||
| features = [ | ||||||
| # Install dependency group for docs | ||||||
| dependency-groups = [ | ||||||
| "docs", | ||||||
| ] | ||||||
|
|
||||||
|
|
@@ -333,7 +397,7 @@ serve = ["sphinx-autobuild docs --watch src/{{ package_name }} {args:-b html doc | |||||
|
|
||||||
| [tool.hatch.envs.style] | ||||||
| description = """Check the code and documentation style.""" | ||||||
| features = [ | ||||||
| dependency-groups = [ | ||||||
| "style", | ||||||
| ] | ||||||
| detached = true | ||||||
|
|
@@ -349,7 +413,7 @@ check = ["docstrings", "code"] | |||||
|
|
||||||
| [tool.hatch.envs.audit] | ||||||
| description = """Check dependencies for security vulnerabilities.""" | ||||||
| features = [ | ||||||
| dependency-groups = [ | ||||||
| "build", | ||||||
| ] | ||||||
|
|
||||||
|
|
@@ -361,7 +425,7 @@ check = ["pip-audit"] | |||||
| #--------------- Typing ---------------# | ||||||
| [tool.hatch.envs.types] | ||||||
| description = """Check the static types of the codebase.""" | ||||||
| features = ["types"] | ||||||
| dependency-groups = ["types"] | ||||||
|
|
||||||
| [tool.hatch.envs.types.scripts] | ||||||
| check = "mypy src/{{ package_name }}" | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mathematicalmichael optional-dependencies are for optional features in a package. so they shouldn't be correlated with development-groups which are for development dependencies. I suggest we still include them/remove the conditional here and just add a comment about how they are used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm trying to find the end of this condition - but we may just need to move it down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 128
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!! yes i think project.optional-dependencies can just be empty in our pyproject.toml template with a comment that the user can use that for optional features if they have them. but it shouldn't correlate to hatch environments because it's just a core pyproject.toml feature and development groups just allow us to separate feature dependencies from development.
Please let me know if i'm missing your intention here!