Skip to content

Transition from setuptools to hatchling #657

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

Merged
merged 4 commits into from
May 22, 2025
Merged

Transition from setuptools to hatchling #657

merged 4 commits into from
May 22, 2025

Conversation

jan-janssen
Copy link
Member

@jan-janssen jan-janssen commented May 22, 2025

Summary by CodeRabbit

  • Chores
    • Updated build and packaging system from setuptools/versioneer to hatchling/hatch-vcs.
    • Updated configuration files and dependencies to reflect the new build and versioning tools.
    • Removed dynamic version computation, now using a static version declaration.
    • Cleaned up related environment and workflow files to remove old dependencies and scripts.

Copy link
Contributor

coderabbitai bot commented May 22, 2025

Walkthrough

This update migrates the project's build and versioning system from setuptools and versioneer to hatchling and hatch-vcs. All related configuration files, environment definitions, and workflow scripts are updated to remove versioneer and setuptools, add hatchling and hatch-vcs, and adjust version handling to use static variables and hatch-vcs integration.

Changes

File(s) Change Summary
.ci_support/environment-docs.yml Added hatchling and hatch-vcs to documentation CI dependencies.
.ci_support/environment-integration.yml
.ci_support/environment-mini.yml
.ci_support/environment-mpich.yml
.ci_support/environment-old.yml
.ci_support/environment-openmpi.yml
.ci_support/environment-win.yml
binder/environment.yml
Removed setuptools and/or versioneer dependencies; added hatchling and hatch-vcs with specified versions to environment files.
.github/workflows/deploy.yml Replaced setuptools/versioneer build commands with hatchling-based build commands and updated git index handling in the PyPI release workflow.
.github/workflows/pipeline.yml Removed all installations of versioneer from CI jobs and updated environment file references accordingly.
.readthedocs.yml Removed installation of versioneer from pre-build steps.
executorlib/init.py Changed version import from function-based to module-based; now assigns __version__ from _version.__version__.
executorlib/_version.py Replaced dynamic version computation logic with static variables: __version__, version, __version_tuple__, and version_tuple. Removed all previous versioneer logic.
pyproject.toml Switched build backend from setuptools/versioneer to hatchling/hatch-vcs; removed setuptools and versioneer config sections, added hatchling and hatch-vcs config with VCS versioning.
setup.py Deleted the setuptools/versioneer-based setup script.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant GitHub Actions
    participant Hatchling
    participant executorlib/_version.py

    Developer->>GitHub Actions: Push code/update version
    GitHub Actions->>Hatchling: Build package (hatchling build)
    Hatchling->>executorlib/_version.py: Read static version variables
    executorlib/_version.py-->>Hatchling: Provide __version__, version_tuple
    Hatchling-->>GitHub Actions: Package built with static version
Loading

Possibly related PRs

Poem

🐇
Goodbye to old eggs in the setup.py nest,
Now hatchling and friends will handle the rest!
Static versions hop in, dynamic ones out,
With hatch-vcs magic, there’s no room for doubt.
The CI gardens are tidy and clean—
Oh, what a hoppy new build routine!

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 30th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented May 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.81%. Comparing base (312eb8b) to head (40660a3).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #657   +/-   ##
=======================================
  Coverage   96.81%   96.81%           
=======================================
  Files          29       29           
  Lines        1288     1288           
=======================================
  Hits         1247     1247           
  Misses         41       41           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
executorlib/__init__.py (1)

14-21: Consider exporting __version__ in __all__
Including "__version__" in __all__ would make it available for wildcard imports, e.g. from executorlib import *.

 __all__: list[str] = [
     "get_cache_data",
     "FluxJobExecutor",
     "FluxClusterExecutor",
     "SingleNodeExecutor",
     "SlurmJobExecutor",
     "SlurmClusterExecutor",
+    "__version__",
 ]
executorlib/_version.py (1)

8-11: Use tuple instead of Tuple for type annotations.

The static analysis tool correctly identified that typing.Tuple is deprecated. Use tuple instead for type annotations.

-    from typing import Tuple
+    from typing import Union
-    VERSION_TUPLE = Tuple[Union[int, str], ...]
+    VERSION_TUPLE = tuple[Union[int, str], ...]
🧰 Tools
🪛 Ruff (0.11.9)

8-8: typing.Tuple is deprecated, use tuple instead

(UP035)


11-11: Use tuple instead of Tuple for type annotation

Replace with tuple

(UP006)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 831451b and 40660a3.

📒 Files selected for processing (15)
  • .ci_support/environment-docs.yml (1 hunks)
  • .ci_support/environment-integration.yml (1 hunks)
  • .ci_support/environment-mini.yml (1 hunks)
  • .ci_support/environment-mpich.yml (1 hunks)
  • .ci_support/environment-old.yml (1 hunks)
  • .ci_support/environment-openmpi.yml (1 hunks)
  • .ci_support/environment-win.yml (1 hunks)
  • .github/workflows/deploy.yml (1 hunks)
  • .github/workflows/pipeline.yml (5 hunks)
  • .readthedocs.yml (0 hunks)
  • binder/environment.yml (1 hunks)
  • executorlib/__init__.py (2 hunks)
  • executorlib/_version.py (1 hunks)
  • pyproject.toml (2 hunks)
  • setup.py (0 hunks)
💤 Files with no reviewable changes (2)
  • .readthedocs.yml
  • setup.py
🧰 Additional context used
🪛 Ruff (0.11.9)
executorlib/_version.py

8-8: typing.Tuple is deprecated, use tuple instead

(UP035)


11-11: Use tuple instead of Tuple for type annotation

Replace with tuple

(UP006)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: benchmark (ubuntu-latest, 3.13, .ci_support/environment-openmpi.yml)
  • GitHub Check: benchmark (ubuntu-latest, 3.13, .ci_support/environment-mpich.yml)
  • GitHub Check: notebooks_integration
🔇 Additional comments (18)
.ci_support/environment-old.yml (1)

14-15: Add hatchling and hatch-vcs dependencies
This correctly replaces the previous setuptools/versioneer entries with hatchling and hatch-vcs (v1.27.0 and v0.4.0) per the PR objectives, ensuring the new build backend is available in the CI environment.

.ci_support/environment-win.yml (1)

14-15: Add hatchling and hatch-vcs dependencies
These additions align the Windows CI environment with the transition to Hatch’s tooling. Pinning to 1.27.0 and 0.4.0 respectively maintains reproducibility.

.ci_support/environment-mpich.yml (1)

15-16: Add hatchling and hatch-vcs dependencies
This update completes the MPICH CI setup by including the required Hatch build/versioning packages. Version pins are appropriate for stability.

.ci_support/environment-openmpi.yml (1)

15-16: Add hatchling and hatch-vcs dependencies
The OpenMPI CI environment now correctly includes Hatch’s build backend and VCS plugin, consistent with the other environment files.

.ci_support/environment-integration.yml (1)

12-13: Add hatchling and hatch-vcs dependencies
This completes the integration environment’s migration away from versioneer to hatchling/hatch-vcs, matching the project-wide build system overhaul.

binder/environment.yml (1)

12-13: Pinned hatchling and hatch-vcs versions
The explicit version pins (1.27.0 and 0.4.0) match other CI environments, ensuring consistency.

.ci_support/environment-mini.yml (1)

8-9: Pinned hatchling and hatch-vcs dependencies
Adding hatchling =1.27.0 and hatch-vcs =0.4.0 aligns this minimal CI environment with the new build tooling.

executorlib/__init__.py (2)

12-12: Switch to static version module import
Importing the _version module directly replaces the dynamic Versioneer logic, matching the new hatch-vcs approach.


23-23: Assign __version__ from static _version
Using __version__ = _version.__version__ correctly surfaces the static version declared in _version.py.

.github/workflows/deploy.yml (2)

35-36: Update build commands to use Hatchling
Replacing python setup.py and Versioneer with hatchling build -t sdist -t wheel aligns the release workflow with the new build backend.


33-36:

✅ Verification successful

Verify environment-old.yml includes the new dependencies
The workflow copies .ci_support/environment-old.yml before building; ensure it has hatchling and hatch-vcs to avoid missing tooling.


🏁 Script executed:

#!/bin/bash
# Check that environment-old.yml has hatchling & hatch-vcs pinned
rg -nE 'hatchling|hatch-vcs' .ci_support/environment-old.yml

Length of output: 119


#!/bin/bash
set -euo pipefail

# Safely search for hatchling and hatch-vcs in the old environment file
grep -En 'hatchling|hatch-vcs' .ci_support/environment-old.yml || echo "No matches found"

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Ensure the file exists
if [[ ! -f .ci_support/environment-old.yml ]]; then
  echo "ERROR: .ci_support/environment-old.yml not found"
  exit 1
fi

# Search for hatchling and hatch-vcs entries in the YAML dependencies list
grep -En '^\s*-\s*(hatchling|hatch-vcs)' .ci_support/environment-old.yml || echo "No matches found"

Length of output: 184


Confirmed dependencies in environment-old.yml
Verified that .ci_support/environment-old.yml includes:

  • hatchling =1.27.0 (line 14)
  • hatch-vcs =0.4.0 (line 15)

No changes required.

.github/workflows/pipeline.yml (3)

97-97: LGTM: Simplified dependency installation.

The versioneer package has been removed from the installation step as part of transitioning from setuptools/versioneer to hatchling/hatch-vcs.


206-207: LGTM: Removed versioneer dependency from environment file.

The versioneer package is correctly removed from the environment file as it's no longer needed with the new build system.


237-238: LGTM: Removed versioneer dependency from environment file.

The versioneer package is correctly removed from the environment file, keeping only the necessary dependencies for testing.

executorlib/_version.py (1)

1-22: LGTM: Simplified version management with static declaration.

The file has been completely rewritten from a complex dynamic versioning implementation to a simple static version declaration that will be managed by hatch-vcs. This aligns with the migration from versioneer to hatchling/hatch-vcs.

🧰 Tools
🪛 Ruff (0.11.9)

8-8: typing.Tuple is deprecated, use tuple instead

(UP035)


11-11: Use tuple instead of Tuple for type annotation

Replace with tuple

(UP006)

pyproject.toml (3)

1-8: LGTM: Successfully migrated build system to hatchling.

The build system has been properly updated to use hatchling and hatch-vcs instead of setuptools and versioneer. The specified versions for the dependencies provide reproducible builds.


103-120: LGTM: Proper hatchling build configuration.

The build configuration for hatchling is correctly set up to include only the necessary package and specify build targets for sdist and wheel.


121-123: LGTM: Correct hatch-vcs versioning configuration.

The versioning configuration is properly set up to use VCS as the source and points to the version file. This completes the migration from versioneer to hatch-vcs for version management.

Comment on lines +4 to +5
- hatchling
- hatch-vcs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Pin hatchling and hatch-vcs versions for reproducibility
Unpinned dependencies can drift and lead to inconsistencies across CI runs. Please specify explicit versions (e.g., align with other environments at hatchling =1.27.0 and hatch-vcs =0.4.0).

- - hatchling
- - hatch-vcs
+ - hatchling =1.27.0
+ - hatch-vcs =0.4.0
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- hatchling
- hatch-vcs
- hatchling =1.27.0
- hatch-vcs =0.4.0
🤖 Prompt for AI Agents
In .ci_support/environment-docs.yml around lines 4 to 5, the dependencies
'hatchling' and 'hatch-vcs' are listed without version pins. To ensure
reproducibility and consistency across CI runs, update these entries to specify
explicit versions, such as 'hatchling=1.27.0' and 'hatch-vcs=0.4.0', matching
the versions used in other environments.

@jan-janssen jan-janssen merged commit a629ff4 into main May 22, 2025
30 checks passed
@jan-janssen jan-janssen deleted the hatch branch May 22, 2025 10:55
@coderabbitai coderabbitai bot mentioned this pull request Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants