Skip to content

Use hatchling rather than versioneer#239

Merged
jan-janssen merged 4 commits intomainfrom
hatchling
Aug 9, 2025
Merged

Use hatchling rather than versioneer#239
jan-janssen merged 4 commits intomainfrom
hatchling

Conversation

@jan-janssen
Copy link
Copy Markdown
Member

@jan-janssen jan-janssen commented Aug 9, 2025

Summary by CodeRabbit

  • Chores

    • Migrated build and versioning tools from setuptools/versioneer to hatchling/hatch-vcs.
    • Updated environment and workflow configuration files to support the new build system.
    • Added and updated dependencies in environment files for compatibility with hatchling.
    • Added IntelliJ IDEA project configuration files for improved IDE support.
  • Refactor

    • Simplified version management by replacing dynamic version computation with static version variables.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Aug 9, 2025

Walkthrough

The project’s build and versioning system was migrated from setuptools and versioneer to hatchling and hatch-vcs. This involved updating configuration files, modifying CI/CD workflows, and replacing dynamic version computation with static version variables. All references to versioneer were removed, and hatchling-based build steps and dependencies were introduced throughout.

Changes

Cohort / File(s) Change Summary
Build System Migration
pyproject.toml
Switched build backend from setuptools/versioneer to hatchling/hatch-vcs. Updated [build-system] requirements and backend, migrated packaging and versioning configuration to [tool.hatch] sections, and removed all setuptools/versioneer configuration.
CI/CD Workflow Updates
.github/workflows/deploy.yml,
.github/workflows/pipeline.yml
Updated GitHub Actions workflows to remove all uses of versioneer. Replaced setuptools build commands with hatchling equivalents in deploy workflow. Removed installation of versioneer from pipeline jobs and updated build commands accordingly.
Environment Configuration
.ci_support/environment.yml,
.ci_support/environment-old.yml,
binder/environment.yml
Removed setuptools and added hatchling and hatch-vcs as dependencies in CI and Binder environment files, specifying versions in Binder environment.
Version File Overhaul
pyiron_lammps/_version.py
Entirely replaced dynamic, versioneer-based version extraction logic with a static version file declaring only version strings and tuples, as generated by setuptools-scm/hatch-vcs.
Version Import Update
pyiron_lammps/__init__.py
Changed import of _version from relative to absolute. Updated __version__ assignment to use the new static version string.
IDE Configuration Addition
.idea/.gitignore, .idea/inspectionProfiles/profiles_settings.xml, .idea/misc.xml, .idea/modules.xml, .idea/pyiron_lammps.iml, .idea/vcs.xml
Added new IntelliJ IDEA project configuration files including .gitignore, inspection profiles, project settings, module definitions, and VCS mappings to support development environment setup.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant GitHub Actions
    participant Hatchling
    participant PyPI

    Developer->>GitHub Actions: Push code / PR / Tag
    GitHub Actions->>Hatchling: Run `hatchling build -t sdist -t wheel`
    Hatchling->>GitHub Actions: Build distributions using VCS version
    GitHub Actions->>PyPI: Publish built distributions
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Poem

🐇
A hop from old to shiny new,
Versioneer’s gone, hatchling flew!
Static numbers, builds that sing,
CI/CD on a lighter wing.
Now with hatch-vcs we stride,
In tidy files our versions hide—
Oh what a modern rabbit ride!

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bfba963 and 8cce0ec.

⛔ Files ignored due to path filters (10)
  • pyiron_lammps/__pycache__/__init__.cpython-312.pyc is excluded by !**/*.pyc
  • pyiron_lammps/__pycache__/_version.cpython-312.pyc is excluded by !**/*.pyc
  • pyiron_lammps/__pycache__/output.cpython-312.pyc is excluded by !**/*.pyc
  • pyiron_lammps/__pycache__/structure.cpython-312.pyc is excluded by !**/*.pyc
  • pyiron_lammps/__pycache__/units.cpython-312.pyc is excluded by !**/*.pyc
  • tests/.DS_Store is excluded by !**/.DS_Store
  • tests/__pycache__/test_output.cpython-312.pyc is excluded by !**/*.pyc
  • tests/__pycache__/test_structure.cpython-312.pyc is excluded by !**/*.pyc
  • tests/__pycache__/test_units.cpython-312.pyc is excluded by !**/*.pyc
  • tests/static/.DS_Store is excluded by !**/.DS_Store
📒 Files selected for processing (8)
  • .ci_support/environment-old.yml (1 hunks)
  • .idea/.gitignore (1 hunks)
  • .idea/inspectionProfiles/profiles_settings.xml (1 hunks)
  • .idea/misc.xml (1 hunks)
  • .idea/modules.xml (1 hunks)
  • .idea/pyiron_lammps.iml (1 hunks)
  • .idea/vcs.xml (1 hunks)
  • binder/environment.yml (1 hunks)
✅ Files skipped from review due to trivial changes (7)
  • .ci_support/environment-old.yml
  • .idea/vcs.xml
  • .idea/.gitignore
  • .idea/pyiron_lammps.iml
  • .idea/modules.xml
  • .idea/misc.xml
  • .idea/inspectionProfiles/profiles_settings.xml
🚧 Files skipped from review as they are similar to previous changes (1)
  • binder/environment.yml
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hatchling

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.
  • 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.

Support

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

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 generate unit tests to generate unit tests for 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.

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.17%. Comparing base (0ca6fec) to head (8cce0ec).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #239   +/-   ##
=======================================
  Coverage   95.17%   95.17%           
=======================================
  Files           4        4           
  Lines         497      497           
=======================================
  Hits          473      473           
  Misses         24       24           

☔ 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
Copy Markdown

@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: 5

🔭 Outside diff range comments (1)
.github/workflows/deploy.yml (1)

21-29: Fetch full history for hatch-vcs to see tags.

hatch-vcs needs tags to compute versions. Configure checkout to fetch tags/history.

Add this to the checkout step:

- uses: actions/checkout@v4
  with:
    fetch-depth: 0
    fetch-tags: true
🧹 Nitpick comments (5)
.ci_support/environment.yml (1)

4-5: Build-time tools in test environment.

Adding hatchling and hatch-vcs here is fine if CI builds artifacts. If they’re not needed for runtime/tests, consider moving them to a dedicated build env (workflow step) to keep CI lean.

pyiron_lammps/__init__.py (1)

1-1: Absolute import is fine; consider exposing version.

Importing pyiron_lammps._version is OK. Optionally add "__version__" to __all__ for convenience when users do from pyiron_lammps import *.

binder/environment.yml (2)

10-11: EOF newline missing; YAML lint failure.

YAMLlint reports missing trailing newline at EOF. Add a newline to satisfy linters and tooling.

Minimal fix: ensure the file ends with a newline character.


10-11: Do we need build backend in Binder?

Pinning hatchling and hatch-vcs in Binder increases image size. If Binder sessions don’t build distributions, consider removing them.

pyproject.toml (1)

51-55: Consolidate hatch build configuration to avoid duplication

You define includes in three places: [tool.hatch.build].include, [tool.hatch.build.targets.sdist].include, and [tool.hatch.build.targets.wheel].packages. This duplication is easy to get out of sync.

Suggestion: Drop the top-level [tool.hatch.build] include and keep only the target-specific sections.

-[tool.hatch.build]
-include = [
-    "pyiron_lammps"
-]

This keeps sdist/wheel configuration as the single source of truth.

Also applies to: 59-63, 64-67

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0ca6fec and bfba963.

📒 Files selected for processing (7)
  • .ci_support/environment.yml (1 hunks)
  • .github/workflows/deploy.yml (1 hunks)
  • .github/workflows/pipeline.yml (1 hunks)
  • binder/environment.yml (1 hunks)
  • pyiron_lammps/__init__.py (2 hunks)
  • pyiron_lammps/_version.py (1 hunks)
  • pyproject.toml (2 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
binder/environment.yml

[error] 11-11: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (2)
pyiron_lammps/__init__.py (1)

16-16: Ensure dynamic version injection instead of relying on a committed stub

The line

__version__ = pyiron_lammps._version.__version__

will always read the static _version.py checked into source control unless your build process overwrites it. Please verify that:

  • The repository does not ship a stale _version.py stub.
  • Your project configuration (e.g. pyproject.toml or hatch.toml) enables the hatch-vcs (or equivalent) plugin to auto-generate/write the correct version at build time.
  • Installing or building the package via pip install . or hatch build injects the intended version into _version.py.

If not already in place, consider removing _version.py from VCS and configuring hatch-vcs to write the version file during setup. Would you like a patch for that change?

pyproject.toml (1)

56-57: VCS versioning setup verified ✅

  • pyiron_lammps/_version.py defines
    __version__ = version = "0.0.1"
  • pyiron_lammps/__init__.py imports and surfaces it via
    __version__ = pyiron_lammps._version.__version__

No further changes needed here.

Comment on lines +35 to +36
git update-index --assume-unchanged pyproject.toml pyiron_lammps/_version.py
hatchling build -t sdist -t wheel
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Fragile Git index hack; prefer proper VCS-versioning setup.

git update-index --assume-unchanged is a local hack that doesn’t affect sdist contents and can hide real changes. Also, hatchling build is likely not the intended CLI; typically use hatch build or python -m build.

Proposed changes in this step:

-        git update-index --assume-unchanged pyproject.toml pyiron_lammps/_version.py
-        hatchling build -t sdist -t wheel
+        # Ensure a clean state; no index hacks needed
+        # Build using the front-end or hatch CLI
+        python -m pip install --upgrade build
+        python -m build --sdist --wheel

If you prefer Hatch:

  • Add hatch to the environment and run hatch build.
📝 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
git update-index --assume-unchanged pyproject.toml pyiron_lammps/_version.py
hatchling build -t sdist -t wheel
# Ensure a clean state; no index hacks needed
# Build using the front-end or hatch CLI
python -m pip install --upgrade build
python -m build --sdist --wheel
🤖 Prompt for AI Agents
In .github/workflows/deploy.yml at lines 35-36, remove the fragile git index
hack using 'git update-index --assume-unchanged' as it does not affect sdist
contents and can hide changes. Replace the 'hatchling build -t sdist -t wheel'
command with 'hatch build' after ensuring 'hatch' is installed in the
environment. This aligns with proper VCS-versioning and standard build
practices.

shell: bash -l {0}
run: |
pip install versioneer[toml]==0.29 tomlkit
pip install tomlkit
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Ensure hatch build backend is available when using --no-build-isolation

With the migration to hatchling/hatch-vcs, pip install . --no-build-isolation requires both hatchling and hatch-vcs to be preinstalled in the environment. This step only installs tomlkit. Please verify they’re present in .ci_support/environment*.yml; otherwise, the build can fail at sdist/wheel build time.

Run this to confirm the environment includes the hatch backend tools:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Checking .ci_support/environment.yml and environment-old.yml for hatch tooling..."
for f in .ci_support/environment.yml .ci_support/environment-old.yml; do
  if [ -f "$f" ]; then
    echo "File: $f"
    rg -n 'hatchling|hatch-vcs' "$f" || echo "NOT FOUND in $f"
  else
    echo "Missing: $f"
  fi
done

Length of output: 829


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Searching for environment YAML references in .github/workflows/pipeline.yml..."
rg -n 'environment(-old)?\.yml' .github/workflows/pipeline.yml || echo "No environment file references found."

Length of output: 738


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Context around the pip install tomlkit step in pipeline.yml:"
rg -n -C5 'pip install tomlkit' .github/workflows/pipeline.yml

echo
echo "Context around the environment-old.yml reference in pipeline.yml:"
rg -n -C5 'environment-old\.yml' .github/workflows/pipeline.yml

Length of output: 1172


Add hatchling & hatch-vcs to the old CI environment

The Python 3.9 job in .github/workflows/pipeline.yml (lines ~190–200) uses .ci_support/environment-old.yml and then runs:

pip install tomlkit
…
pip install . --no-deps --no-build-isolation

Since you’ve migrated to hatchling/hatch-vcs, both backends must be preinstalled for a no-build-isolation install. While .ci_support/environment.yml already lists hatchling and hatch-vcs, the old environment file does not. Please add:

- hatchling
- hatch-vcs

to .ci_support/environment-old.yml to prevent sdist/wheel build failures.

🤖 Prompt for AI Agents
In .github/workflows/pipeline.yml around line 135, the old CI environment used
by the Python 3.9 job lacks hatchling and hatch-vcs in its dependencies, causing
build failures during no-build-isolation installs. To fix this, add "hatchling"
and "hatch-vcs" to the dependencies list in the .ci_support/environment-old.yml
file so these backends are preinstalled before running pip install commands.

Comment thread pyiron_lammps/_version.py
Comment on lines +1 to +2
# file generated by setuptools-scm
# don't change, don't track in version control
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Header contradicts PR goal (setuptools-scm vs hatch-vcs).

This file claims to be generated by setuptools-scm, but the PR migrates to hatchling + hatch-vcs. Align the source of truth to avoid confusion.

Suggested actions:

  • If using hatch-vcs, remove this file from VCS and let hatch-vcs write the version at build time.
  • Or at least update the header to reflect hatch-vcs if you decide to keep a stub.
🤖 Prompt for AI Agents
In pyiron_lammps/_version.py at lines 1 to 2, the header incorrectly states the
file is generated by setuptools-scm, conflicting with the PR's migration to
hatchling and hatch-vcs. To fix this, either remove this file from version
control entirely so hatch-vcs can generate the version at build time, or update
the header comment to accurately reflect that hatch-vcs is now the source of
version information if you choose to keep the file as a stub.

Comment thread pyiron_lammps/_version.py Outdated
Comment on lines 19 to 20
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Hard-coded version defeats VCS-based versioning.

__version__ = "0.0.1" is static. With hatch-vcs, version should come from tags; a committed stub risks shipping the wrong version.

Recommended:

  • Remove this file and configure hatch-vcs to write the version during build (e.g., using the hatch-vcs write-to option).
  • Alternatively, keep a minimal placeholder guarded for type-checkers only and ensure runtime builds always overwrite it.
🤖 Prompt for AI Agents
In pyiron_lammps/_version.py at lines 19-20, the version is hard-coded which
conflicts with hatch-vcs dynamic versioning from tags. To fix this, remove this
file entirely and configure hatch-vcs to write the version during the build
process using its write-to option. Alternatively, keep only a minimal
placeholder version string guarded by type-checking conditions and ensure the
actual version is overwritten at runtime by hatch-vcs.

Comment thread pyproject.toml
Comment on lines +2 to +10
requires = [
"ase",
"numpy",
"h5py",
"pandas",
"scipy",
"hatchling==1.27.0",
"hatch-vcs==0.5.0",
]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Move runtime dependencies out of [build-system].requires (PEP 517 compliance)

[build-system].requires must list only the build backend and its immediate requirements. Including runtime deps (ase, numpy, h5py, pandas, scipy) here forces heavy/unnecessary installs during build and leaks optional deps (e.g., h5py) into every build.

Apply:

 [build-system]
 requires = [
-    "ase", 
-    "numpy", 
-    "h5py", 
-    "pandas", 
-    "scipy", 
     "hatchling==1.27.0",
     "hatch-vcs==0.5.0",
 ]
 build-backend = "hatchling.build"

Note: Keep runtime deps under [project.dependencies]/extras only.

🤖 Prompt for AI Agents
In pyproject.toml lines 2 to 10, the runtime dependencies (ase, numpy, h5py,
pandas, scipy) are incorrectly listed under [build-system].requires. To fix
this, remove these runtime dependencies from [build-system].requires and instead
list only the build backend and its immediate requirements there. Then, add the
runtime dependencies under the [project.dependencies] section or appropriate
extras section to comply with PEP 517 and avoid unnecessary installs during
build.

@jan-janssen jan-janssen merged commit ec09edc into main Aug 9, 2025
20 checks passed
@jan-janssen jan-janssen deleted the hatchling branch August 9, 2025 07:26
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.

1 participant