Skip to content

Move create_venv.py to script folder and make it more robust.#865

Merged
spoorcc merged 9 commits intomainfrom
cleanup-tooling
Dec 15, 2025
Merged

Move create_venv.py to script folder and make it more robust.#865
spoorcc merged 9 commits intomainfrom
cleanup-tooling

Conversation

@ben-edna
Copy link
Copy Markdown
Contributor

@ben-edna ben-edna commented Nov 29, 2025

Summary by CodeRabbit

  • Chores

    • Updated Python requirement to 3.13 across dev environments, container config, and build settings.
    • Improved virtual environment setup with runtime version checks, recommended-version warnings, and project-root based path handling.
    • Moved and reorganized development helper scripts; updated command examples and batch workflow invocations to reflect new locations.
  • Documentation

    • Revised contribution and build docs to reflect updated setup paths, commands, and Python version.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 29, 2025

Walkthrough

Move helper scripts into script/, update venv creation to use project-root-aware paths and add Python version enforcement/warnings, change examples and batch invocations to reference script/, and bump Python references from 3.12 to 3.13 across configs and docs.

Changes

Cohort / File(s) Summary
Documentation updates
doc/contributing.rst
Update examples and references to use script/ prefix, change dependency group from doc to docs, and bump Python mention from 3.12 to 3.13.
Venv creation script
script/create_venv.py
Replace shebang with #!/usr/bin/env python3; add pathlib/sys; introduce PROJECT_ROOT, MIN_VERSION (3,9) and RECOMMENDED_VERSION (3,13); enforce minimum Python version and warn if not recommended; use PROJECT_ROOT for venv and extra-requirements resolution; default extras changed to include docs.
Batch & test runner scripts
tests/run_tests.bat, script/check_quality.bat, script/create_docs.bat
Update invocations to call scripts under script/ (use py launcher where changed); adjust venv activation paths to ..\venv\Scripts\activate.bat for scripts located in script/.
Environment config
.devcontainer/Dockerfile, .readthedocs.yml
Bump Python references from 3.12 to 3.13 (local lib path in devcontainer, Read the Docs build Python version).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Inspect script/create_venv.py for correct PROJECT_ROOT computation across platforms and for expected exit codes/behavior when Python version checks trigger.
  • Verify batch files (tests/run_tests.bat, script/check_quality.bat, script/create_docs.bat) paths and py vs python invocations function in CI and Windows shells.
  • Confirm documentation (doc/contributing.rst) and .readthedocs.yml align with packaging/requirements and CI builder expectations.
  • Check .devcontainer/Dockerfile path change matches devcontainer Python image/layout.

Poem

🐰 I hopped through scripts now neatly stacked,
Moved to script/ where paths are tracked,
Three‑thirteen sun warms the venv root,
Extras tuned and version checks astute,
Thump-thump, carrots for the commit!

Pre-merge checks and finishing touches

✅ 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 accurately summarizes the main changes: moving create_venv.py to the script folder and making it more robust with version checks and improved path handling.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cleanup-tooling

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.

Copy link
Copy Markdown
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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
script/create_venv.py (1)

1-68: project_root is derived robustly, but pip -e . still depends on CWD—confirmed issue

The review comment is accurate. When the script is double-clicked from Windows Explorer (as documented in doc/contributing.rst line 13), the working directory will be script/, not the project root. The editable install on line 38 uses -e ., which resolves relative to the current working directory. This causes pip to look for pyproject.toml in script/ instead of the project root, resulting in installation failure.

The batch files (create_docs.bat, check_quality.bat, tests/run_tests.bat) all change to the project root before invoking the script, so they work. However, the documented double-click usage path does not.

The proposed fix is necessary and correct: moving PROJECT_ROOT to module scope and using an absolute path in the editable install aligns both the venv location and package installation with the script's actual location, making the behavior independent of CWD.

🧹 Nitpick comments (1)
script/create_venv.py (1)

1-5: Consider a more generic shebang for portability

Pinning the shebang to #!/usr/bin/env python3.12 enforces a specific minor version and will fail on systems that only expose python3 (or a different 3.x) on PATH. Since the Windows entry points already use py, you might consider a more generic shebang like python3 (or even leaving it unused if the script is always invoked via py/python).

Not critical, but it can make the script more portable on Unix‑like systems.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7b2be88 and 140ea62.

📒 Files selected for processing (5)
  • check_quality.bat (1 hunks)
  • create_docs.bat (1 hunks)
  • doc/contributing.rst (1 hunks)
  • script/create_venv.py (2 hunks)
  • tests/run_tests.bat (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (17)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: DevContainer Build & Test
  • GitHub Check: build (windows-latest)
  • GitHub Check: test (windows-latest, 3.12)
  • GitHub Check: test (macos-latest, 3.14)
  • GitHub Check: test (windows-latest, 3.9)
  • GitHub Check: test (windows-latest, 3.14)
  • GitHub Check: test (macos-latest, 3.9)
  • GitHub Check: test (windows-latest, 3.10)
  • GitHub Check: test (windows-latest, 3.13)
  • GitHub Check: test (macos-latest, 3.13)
  • GitHub Check: test (windows-latest, 3.11)
  • GitHub Check: test (macos-latest, 3.11)
  • GitHub Check: test (macos-latest, 3.10)
  • GitHub Check: test
  • GitHub Check: test-cygwin
🔇 Additional comments (4)
doc/contributing.rst (1)

13-20: Docs now match script path and extras – just keep pyproject extras in sync

The reference to script/create_venv.py and the development,test,docs extras matches the current script defaults. Please just double‑check that the extras section in pyproject.toml is actually named docs so this text and the tooling stay consistent over time.

tests/run_tests.bat (1)

6-6: Launcher and script path update look correct; confirm py availability

Using py script/create_venv.py from cd %~dp0.. correctly targets the repo root and the new script location, and activation still wires python to the venv for pytest. Please confirm that relying on the Python launcher (py) is acceptable for all Windows contributors (no environments where only python is available).

check_quality.bat (1)

6-6: Consistent venv setup for quality checks; same py assumption

Calling py script/create_venv.py --extra_requirements "development" from the repo root is consistent with the new script layout and venv location. As with tests/run_tests.bat, please confirm that all target Windows environments have the py launcher available.

create_docs.bat (1)

6-6: Docs build script aligned with new extras and layout; verify py + docs extra

The switch to py script/create_venv.py --extra_requirements "docs" matches the new script location and the renamed docs extra. Please verify that:

  • The docs extra exists in pyproject.toml, and
  • Using the py launcher is acceptable on all Windows setups you care about.

Copy link
Copy Markdown
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: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e3b955 and 06abcce.

📒 Files selected for processing (7)
  • .devcontainer/Dockerfile (1 hunks)
  • .readthedocs.yml (1 hunks)
  • doc/contributing.rst (3 hunks)
  • script/check_quality.bat (1 hunks)
  • script/create_docs.bat (1 hunks)
  • script/create_venv.py (3 hunks)
  • tests/run_tests.bat (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • .devcontainer/Dockerfile
  • tests/run_tests.bat
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: test
  • GitHub Check: test (macos-latest, 3.12)
  • GitHub Check: test (ubuntu-latest, 3.13)
  • GitHub Check: test (macos-latest, 3.13)
  • GitHub Check: test (windows-latest, 3.9)
  • GitHub Check: test (macos-latest, 3.10)
  • GitHub Check: test (windows-latest, 3.10)
  • GitHub Check: test (windows-latest, 3.13)
  • GitHub Check: test (windows-latest, 3.14)
  • GitHub Check: test (ubuntu-latest, 3.10)
  • GitHub Check: test-cygwin
  • GitHub Check: DevContainer Build & Test
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (ubuntu-latest)
🔇 Additional comments (7)
script/create_docs.bat (1)

1-10: LGTM!

The path adjustments correctly account for the script's new location in script/. Using py launcher is more robust on Windows as it handles version selection automatically.

script/check_quality.bat (1)

1-14: LGTM!

The changes are consistent with create_docs.bat and correctly adjust paths for the new script/ location.

doc/contributing.rst (3)

13-22: LGTM!

Documentation correctly updated to reflect the new script paths and Python 3.13 version. The dependency group change from doc to docs aligns with the default in create_venv.py.


52-52: LGTM!

Path correctly updated to script/check_quality.bat.


91-91: LGTM!

Path correctly updated to script/create_docs.bat.

script/create_venv.py (2)

11-22: Good addition of version guards and PROJECT_ROOT.

The PROJECT_ROOT calculation correctly navigates from script/ to the project root. The version guards provide clear feedback for unsupported Python versions.


76-87: LGTM!

The venv is now correctly created at PROJECT_ROOT / "venv", ensuring consistent behavior regardless of the current working directory when running the script.

Comment thread .readthedocs.yml
Comment thread script/create_venv.py Outdated
Copy link
Copy Markdown
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: 0

🧹 Nitpick comments (2)
script/create_venv.py (2)

14-27: Version gating is clear; consider avoiding import‑time side effects

The min/recommended version checks are straightforward and the messages read well. If you ever expect MyEnvBuilder to be imported from other tooling (rather than run purely as a script), consider moving the version checks under the if __name__ == "__main__": guard to avoid raising RuntimeError at import time in older interpreters.


54-59: Editable install from PROJECT_ROOT removes CWD dependency

Switching the editable install target to f"{PROJECT_ROOT}{self.extra_requirements}" correctly installs the top‑level project regardless of the current working directory, and the extras syntax is preserved. If you want to make the intent slightly clearer, you could explicitly cast the path, e.g. f"{PROJECT_ROOT!s}{self.extra_requirements}", but the current form is functionally fine.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 06abcce and 809873c.

📒 Files selected for processing (1)
  • script/create_venv.py (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: Publish Python distribution 📦 to TestPyPI
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: test (windows-latest, 3.12)
  • GitHub Check: test (macos-latest, 3.11)
  • GitHub Check: test (windows-latest, 3.14)
  • GitHub Check: test (macos-latest, 3.13)
  • GitHub Check: test (windows-latest, 3.11)
  • GitHub Check: test (windows-latest, 3.9)
  • GitHub Check: test (ubuntu-latest, 3.11)
  • GitHub Check: test (windows-latest, 3.10)
  • GitHub Check: test (macos-latest, 3.9)
  • GitHub Check: test (macos-latest, 3.10)
  • GitHub Check: test (ubuntu-latest, 3.14)
  • GitHub Check: test (windows-latest, 3.13)
  • GitHub Check: test
  • GitHub Check: test-cygwin
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: build (windows-latest)
  • GitHub Check: DevContainer Build & Test
🔇 Additional comments (2)
script/create_venv.py (2)

1-11: Shebang and PROJECT_ROOT handling improve portability

Using #!/usr/bin/env python3 and deriving PROJECT_ROOT from __file__ makes the script robust to being invoked from arbitrary working directories and across platforms. No issues spotted here.


76-87: CLI defaults and venv location align with project layout

Defaulting --extra_requirements to "development,test,docs" and creating the venv at PROJECT_ROOT / "venv" matches the repo‑root‑based tooling and should make editor/CI integration more predictable. Looks good.

Copy link
Copy Markdown
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: 0

🧹 Nitpick comments (3)
script/create_venv.py (3)

1-15: Shebang, PROJECT_ROOT, and version constants are well-chosen

Using /usr/bin/env python3 plus a runtime MIN_VERSION check is portable, and computing PROJECT_ROOT from __file__ avoids cwd-related surprises. Consider, long term, driving RECOMMENDED_VERSION from a single source (e.g., pyproject.toml or config) so it cannot drift from other tooling/docs.


37-46: Editable install via PROJECT_ROOT improves robustness; docstring could be updated

Using PROJECT_ROOT for the editable install target is a good robustness improvement over cwd-relative paths, and the extras handling is consistent with the CLI argument. The only mismatch is the class docstring still referencing a requirements.txt-driven flow; you may want to update it to mention the editable install with optional extras instead.


70-79: Version gating and warning behavior are correct; consider tiny readability tweaks

The minimum-version guard and recommended-version warning behave as intended and make the script’s expectations explicit. If you want to tighten things up, you could cache current = sys.version_info[:2] to avoid repetition, or switch to sys.exit() for a slightly cleaner error message when the version is too old, but that’s purely cosmetic.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 809873c and efadd1d.

📒 Files selected for processing (1)
  • script/create_venv.py (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: test (windows-latest, 3.13)
  • GitHub Check: test (windows-latest, 3.10)
  • GitHub Check: test (windows-latest, 3.11)
  • GitHub Check: test (windows-latest, 3.12)
  • GitHub Check: test (windows-latest, 3.14)
  • GitHub Check: test (macos-latest, 3.14)
  • GitHub Check: test (windows-latest, 3.9)
  • GitHub Check: test (ubuntu-latest, 3.12)
  • GitHub Check: test (macos-latest, 3.9)
  • GitHub Check: test-cygwin
  • GitHub Check: DevContainer Build & Test
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: test
🔇 Additional comments (2)
script/create_venv.py (2)

81-85: Project-root-based venv path aligns with the tooling/docs changes

Targeting PROJECT_ROOT / "venv" ensures the environment is created consistently at the repo root regardless of where the script is invoked from, which lines up with the PR’s restructuring of scripts and docs.


64-67: All default extras are properly defined in pyproject.toml

The extras development, test, and docs are all present in [project.optional-dependencies] and will install without issues when the venv script runs.

Copy link
Copy Markdown
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: 0

🧹 Nitpick comments (1)
script/create_venv.py (1)

61-79: CLI default extras and version checks are sensible; consider cleaner error UX.

The default --extra_requirements=development,test,docs and the min/recommended version checks are well-structured and do what they intend. If you want a slightly cleaner CLI experience, you could consider using sys.exit(<message>) instead of raising RuntimeError for the unsupported-version case to avoid showing a full stack trace for what is essentially a user-facing compatibility error.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between efadd1d and 3153962.

📒 Files selected for processing (1)
  • script/create_venv.py (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: test (windows-latest, 3.14)
  • GitHub Check: test (windows-latest, 3.10)
  • GitHub Check: test (windows-latest, 3.13)
  • GitHub Check: test (windows-latest, 3.9)
  • GitHub Check: test (windows-latest, 3.12)
  • GitHub Check: test (macos-latest, 3.9)
  • GitHub Check: test (windows-latest, 3.11)
  • GitHub Check: test (ubuntu-latest, 3.9)
  • GitHub Check: test (ubuntu-latest, 3.13)
  • GitHub Check: test (macos-latest, 3.10)
  • GitHub Check: test (ubuntu-latest, 3.14)
  • GitHub Check: test (ubuntu-latest, 3.10)
  • GitHub Check: test-cygwin
  • GitHub Check: DevContainer Build & Test
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (windows-latest)
  • GitHub Check: test
🔇 Additional comments (3)
script/create_venv.py (3)

1-15: PROJECT_ROOT and version constants look good; ensure they stay aligned with supported matrix.

The PROJECT_ROOT resolution and the MIN_VERSION / RECOMMENDED_VERSION tuple approach are solid and clear. Just make sure these version constants stay in sync with pyproject.toml’s requires-python and your CI matrix so users don’t see contradictory support vs. tooling messages.


35-44: Editable install via PROJECT_ROOT improves robustness.

Switching to PROJECT_ROOT in post_setup() so pip installs -e <abs_project_root>[extras] is a nice robustness improvement (no dependency on CWD) and keeps extras handling straightforward. No issues from my side here.


81-85: Venv location tied to PROJECT_ROOT is a good hardening step.

Targeting PROJECT_ROOT / "venv" makes the environment creation independent of the caller’s working directory and should behave more predictably across tooling and docs. This change looks correct.

@spoorcc spoorcc merged commit 890d635 into main Dec 15, 2025
35 of 36 checks passed
@spoorcc spoorcc deleted the cleanup-tooling branch December 15, 2025 20:54
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