Skip to content

Modernize Python packaging using uv and pyproject.toml#225

Open
gdevenyi wants to merge 7 commits intomasterfrom
modernize-packaging-with-uv
Open

Modernize Python packaging using uv and pyproject.toml#225
gdevenyi wants to merge 7 commits intomasterfrom
modernize-packaging-with-uv

Conversation

@gdevenyi
Copy link
Member

@gdevenyi gdevenyi commented Feb 6, 2026

This PR updates the project to use modern Python packaging standards with uv as the package manager and drops Python 2 support.

Changes:

  • Add pyproject.toml with modern PEP 621 metadata
  • Replace setup.py, setup.cfg, requirements*.txt with pyproject.toml
  • Drop Python 2 support (requires Python 3.8+)
  • Remove 'future' dependency (no longer needed)
  • Migrate tests from nose to pytest
  • Remove Python 2 compatibility code from source files
  • Update .gitignore with modern Python/uv patterns

All 10 tests pass with pytest.

Summary by CodeRabbit

  • Chores

    • Project is Python‑3 only: legacy Python‑2 compatibility and related test deps removed.
    • Packaging migrated to a modern pyproject/Hatch build configuration; legacy packaging scripts removed.
    • CI and publishing workflow simplified and migrated to new build tooling; ignore patterns expanded and test dependency list cleaned.
  • Documentation

    • Added a new developer guidance document; updated project citation and removed the old CI badge.

This PR updates the project to use modern Python packaging standards
with uv as the package manager and drops Python 2 support.

Changes:
- Add pyproject.toml with modern PEP 621 metadata
- Replace setup.py, setup.cfg, requirements*.txt with pyproject.toml
- Drop Python 2 support (requires Python 3.8+)
- Remove 'future' dependency (no longer needed)
- Migrate tests from nose to pytest
- Remove Python 2 compatibility code from source files
- Update .gitignore with modern Python/uv patterns

All 10 tests pass with pytest.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ecd8ed4 and ad92960.

📒 Files selected for processing (2)
  • README.md
  • test/test_qbatch.py
💤 Files with no reviewable changes (1)
  • README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/test_qbatch.py

📝 Walkthrough

Walkthrough

This PR removes Python 2 compatibility shims, migrates packaging to Hatch via pyproject.toml (removing setup.py/setup.cfg flags), replaces Travis CI with an UV-based GitHub Actions publish workflow, adjusts requirements and .gitignore, and adds CLAUDE.md. No public API changes.

Changes

Cohort / File(s) Summary
Build System
setup.py, setup.cfg, pyproject.toml
Removed legacy setup.py and some setup.cfg packaging flags; added pyproject.toml using Hatch with project metadata, build targets, and console script qbatch = "qbatch:qbatchParser".
CI / Publish Workflow
.travis.yml, .github/workflows/publish.yml
Deleted .travis.yml; updated GitHub Actions publish workflow to use setup-uv / uv build / uv publish, adjusted action versions, cache and permissions.
Compatibility Cleanup
qbatch/__init__.py, qbatch/qbatch.py, test/test_qbatch.py
Removed __future__ imports and Python 2 compatibility/environment shims; simplified test imports and removed version-specific environment handling.
Dependencies & Requirements
requirements.txt, requirements-testing.txt, pyproject.toml
Removed future from requirements.txt; removed nose, future, and ushlex from testing requirements; testing deps declared under pyproject.toml (pytest-related).
Repository Metadata
CITATION.cff, README.md
Updated repository reference in CITATION.cff; removed Travis badge from README.md.
Ignore Patterns
.gitignore
Removed .eggs/ and qbatch.egg-info/ entries and expanded ignore rules for Python artifacts, virtualenvs, packaging, uv, IDE, and OS files.
Documentation
CLAUDE.md
Added CLAUDE.md with development and architecture guidance (dev commands, testing notes, compatibility, versioning).
Tests
test/test_qbatch.py
Removed Python 2 boilerplate; updated imports and repo URL in docstring to CoBrALab.

Sequence Diagram(s)

sequenceDiagram
  participant Dev as "Developer / Push"
  participant GH as "GitHub Actions"
  participant UV as "setup-uv / uv"
  participant Registry as "Package Registry"

  Dev->>GH: push tag / release
  GH->>GH: checkout repo
  GH->>UV: setup-uv (enable-cache)
  GH->>UV: run uv build
  UV->>Registry: uv publish
  Registry-->>GH: publish result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 I nibbled old shims and left them behind,
Hatch grew the packages—neat and refined.
Travis hopped off, UV hums the tune,
CLAUDE whispers notes beneath the moon.
A joyful bound — the repo’s light and kind.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Modernize Python packaging using uv and pyproject.toml' directly and accurately summarizes the main changes: adoption of uv tooling, pyproject.toml configuration, and modernization of the packaging approach.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch modernize-packaging-with-uv

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy link

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

🤖 Fix all issues with AI agents
In `@CLAUDE.md`:
- Around line 101-122: Update the README sections to match this PR’s
modernization: remove the entire "Python 2/3 Compatibility" section, change the
"Testing Notes" text to say tests use pytest instead of nosetests and drop any
mention of the `future` library, and update the "Version Management" section to
state that the project version is defined in pyproject.toml rather than
setup.py; edit the sections titled "Testing Notes", "Python 2/3 Compatibility"
(remove), and "Version Management" accordingly.
- Around line 23-39: Update the Build and Installation command examples in
CLAUDE.md to use the new pyproject/uv workflow instead of removed setup.py and
requirements-testing.txt: replace the "python setup.py sdist bdist_wheel" line
with "uv build", change "pip install -e ." under Build to "uv pip install -e .",
change "pip install ." under Installation to "uv pip install .", and replace the
"pip install -r requirements-testing.txt" test deps line with "uv sync --group
testing" (also adjust the accompanying comment to indicate dev/testing
dependencies).
- Around line 12-21: Update the testing examples in CLAUDE.md to use pytest
instead of nosetests: replace "nosetests test/test_qbatch.py" with "pytest
test/test_qbatch.py", change the specific-test syntax from "nosetests
test/test_qbatch.py:test_run_qbatch_local_piped_commands" to the pytest style
"pytest test/test_qbatch.py::test_run_qbatch_local_piped_commands", and update
the verbose example from "nosetests -v test/test_qbatch.py" to "pytest -v
test/test_qbatch.py"; ensure the three example lines referencing
test/test_qbatch.py are edited accordingly.

In `@pyproject.toml`:
- Around line 50-54: The [project.optional-dependencies] testing group still
lists legacy packages "nose>=1.0" and "ushlex"; remove that stale testing table
or replace its contents to match the modern pytest setup under
[dependency-groups] (testing) so that pip install qbatch[testing] pulls the
correct pytest dependencies—specifically delete or update the
[project.optional-dependencies] testing block to either be removed entirely or
to reference the same pytest packages declared in [dependency-groups] testing.

@gdevenyi gdevenyi assigned CMonnin and unassigned CMonnin Feb 6, 2026
@gdevenyi gdevenyi requested a review from CMonnin February 6, 2026 00:26
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@gdevenyi gdevenyi force-pushed the modernize-packaging-with-uv branch from 1d07e11 to cbb2f27 Compare February 6, 2026 17:23
The testing group referenced nose and ushlex, which are Python 2-era
packages no longer used. The correct pytest dependencies are already
declared in [dependency-groups] testing.

This addresses the remaining CodeRabbit comment on PR #225.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy link

@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

🤖 Fix all issues with AI agents
In @.github/workflows/publish.yml:
- Around line 19-24: Update the GitHub Actions step that currently uses
astral-sh/setup-uv@v4 (the "Install uv" step) to a newer major version by
replacing the pinned action version with at least `@v7` (preferably `@v7.3.0`); keep
the same inputs (enable-cache: true) and the subsequent "Build package" run step
that invokes uv build unchanged so the workflow uses the latest security fixes
and improvements.
🧹 Nitpick comments (2)
CLAUDE.md (2)

47-48: Hard-coded line count will go stale.

Line 47 references "777 lines" for qbatch.py. This will become inaccurate as the file evolves. Consider removing the exact count or replacing it with a qualitative description (e.g., "single large module").

Similarly, lines 52, 57, 64–68 reference specific line numbers for functions and templates — these will drift with edits.


32-39: Minor: Installation section shows both pip and uv pip without guidance on which to prefer.

Since this PR adopts uv as the package manager, consider indicating that uv pip install . is the preferred approach, or consolidate the two options with a brief note (e.g., "either works; uv is recommended").

Copy link
Member

@CMonnin CMonnin left a comment

Choose a reason for hiding this comment

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

small fixes/tweaks to publish.yml pushed in commit ecd8ed4

@@ -16,16 +16,11 @@ jobs:
id-token: write
steps:
- uses: actions/checkout@v4
Copy link
Member

Choose a reason for hiding this comment

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

checkout@v6

- name: Set up Python
uses: actions/setup-python@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
Copy link
Member

Choose a reason for hiding this comment

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

uv@v7

run: |
python setup.py sdist bdist_wheel # Could also be python -m build
run: uv build
- name: Publish package distributions to PyPI
Copy link
Member

Choose a reason for hiding this comment

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

could use uv publish

Copy link
Member Author

Choose a reason for hiding this comment

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

@copilot update this to use the uv publish workflow

@@ -16,16 +16,11 @@ jobs:
id-token: write
Copy link
Member

Choose a reason for hiding this comment

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

uv docs have
contents: read
too

Copy link

Copilot AI commented Feb 23, 2026

@gdevenyi I've opened a new pull request, #227, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes the repo’s Python packaging by moving to pyproject.toml (Hatchling) with uv-based workflows, while removing Python 2 compatibility code and legacy packaging/testing infrastructure.

Changes:

  • Replace legacy packaging files (setup.py, setup.cfg, requirements*.txt) with a PEP 621 pyproject.toml.
  • Remove Python 2 compatibility shims from the library and tests; drop future/ushlex/nose-era dependencies.
  • Update automation/docs/metadata (GitHub publish workflow, .gitignore, README links, citation metadata, new CLAUDE.md).

Reviewed changes

Copilot reviewed 12 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pyproject.toml Introduces modern project metadata, build backend (Hatchling), scripts, and dependency groups.
.github/workflows/publish.yml Switches release publishing to uv build / uv publish.
qbatch/qbatch.py Removes Python 2 compatibility imports and environment encoding workaround.
qbatch/__init__.py Drops Python 2 __future__ import.
test/test_qbatch.py Removes Python 2 compatibility setup and updates issue link.
.gitignore Expands ignores for common Python/venv/test/build artifacts and uv files.
README.md Updates Travis badge repository path.
CITATION.cff Updates repository URL.
CLAUDE.md Adds developer-oriented guidance and project architecture notes.
setup.py Removed legacy setuptools packaging entrypoint.
setup.cfg Removed legacy wheel/metadata config.
requirements.txt Removed legacy runtime dependency pin.
requirements-testing.txt Removed legacy test dependency list.
.travis.yml Removes Travis CI configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 18 to 19
version: "2.2"
date-released: 2020-03-12
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

repository-code was updated, but version/date-released still reflect the 2020 (2.2) release, which is inconsistent with the current package version in pyproject.toml (2.3.1). Please update these fields (or remove them) so the citation metadata matches the current release.

Suggested change
version: "2.2"
date-released: 2020-03-12

Copilot uses AI. Check for mistakes.
gdevenyi and others added 2 commits February 23, 2026 14:23
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

4 participants