Skip to content

Adjust how the version is specified#565

Merged
ilaflott merged 28 commits intoNOAA-GFDL:mainfrom
underwoo:fun.with.version
Aug 8, 2025
Merged

Adjust how the version is specified#565
ilaflott merged 28 commits intoNOAA-GFDL:mainfrom
underwoo:fun.with.version

Conversation

@underwoo
Copy link
Member

@underwoo underwoo commented Jul 30, 2025

This is an idea on how to use pyproject.toml and a dynamic version number. I did not run any real tests, as I don't have a good build environment set up. I'll leave that to someone else.

This also now has a configuration for cspell.

underwoo and others added 4 commits July 30, 2025 13:09
This is ta allow the version to be dynamic, and easier to define in a single location.
@ilaflott ilaflott requested a review from Copilot July 30, 2025 21:49

This comment was marked as outdated.

Copy link
Member

@ilaflott ilaflott left a comment

Choose a reason for hiding this comment

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

for copilot:

  • this is going in the right direction, the installed verion # is 0.0.0, investigate that cause and fix
  • merge in changes from #552 or the pipeline will not pass
  • investigate the odd cmor oriented errors

@ilaflott
Copy link
Member

for copilot:

welp, just became my own todo, got it! 🤣

Also add cspell configuration and correct spelling in README.md
@underwoo underwoo changed the title Fun.with.version Adjust how the version is specified Jul 31, 2025
@codecov
Copy link

codecov bot commented Jul 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.45%. Comparing base (611fb0a) to head (ad0a816).
⚠️ Report is 804 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #565      +/-   ##
==========================================
+ Coverage   69.42%   69.45%   +0.03%     
==========================================
  Files          63       63              
  Lines        4285     4273      -12     
==========================================
- Hits         2975     2968       -7     
+ Misses       1310     1305       -5     
Flag Coverage Δ
unittests 69.45% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@ilaflott ilaflott requested a review from Copilot August 1, 2025 15:03

This comment was marked as outdated.

@ilaflott ilaflott requested a review from Copilot August 1, 2025 19:51
Copy link
Contributor

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 project's packaging approach by migrating from a traditional setup.py to a modern pyproject.toml configuration with dynamic versioning. The changes also introduce spell checking capabilities using cspell.

  • Migration from setup.py to pyproject.toml for project configuration
  • Implementation of dynamic versioning using environment variables instead of importlib.metadata
  • Addition of cspell configuration for automated spell checking

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
setup.py Completely removed the traditional setup configuration
pyproject.toml New modern project configuration with dynamic versioning
fre/init.py Simplified version handling using environment variables
docs/conf.py Updated to use dynamic copyright year and package version
docs/Makefile Changed source directory from 'source' to '.'
README.md Fixed various spelling errors in documentation
.github/workflows/spell_check.yml Added GitHub workflow for automated spell checking
.cspell/noaa-words.txt Custom dictionary for NOAA-specific terms
.cspell/conda-words.txt Custom dictionary for conda-related terms
.cspell.json Main cspell configuration file

@ilaflott ilaflott marked this pull request as ready for review August 8, 2025 20:52
@ilaflott
Copy link
Member

ilaflott commented Aug 8, 2025

this is about ready. the spell check workflow is allowed to fail (for now).

i think we should merge this and see what if any other issues come out of the cracks, and we put an agent on spelling errors

@ilaflott ilaflott added documentation Improvements or additions to documentation new functioning New feature or request tricky Likely to encounter significant friction to solution clean up labels Aug 8, 2025
@ilaflott
Copy link
Member

ilaflott commented Aug 8, 2025

Overview

makes significant changes to how version information is handled in the fre-cli project

Key Changes

  1. Version Management:

    • Migrated from setup.py to pyproject.toml for package configuration
    • Implemented dynamic versioning through git tags
    • Updated version retrieval in fre/__init__.py
    • Added version reference in docs/conf.py to maintain consistency
    • Using GIT_DESCRIBE_TAG environment variable with fallback to the previous version
  2. Documentation Infrastructure:

    • Updated the Sphinx documentation configuration
    • Fixed source directory path in the Makefile
    • Made copyright year dynamic based on current date
    • Updated .gitignore to exclude generated documentation files
  3. Code Quality Tools:

    • Added .cspell.json for spell checking
    • Added a custom dictionary in .cspell/ok-unknown-words.txt
    • Added GitHub workflow for spell checking in .github/workflows/spell_check.yml
    • The workflow is allowed to fail for now. We'll have an immediate follow up for spelling alone.

Code Analysis

Version Management

The approach to version management has been completely refactored:

# Before (fre/__init__.py)
import importlib.metadata
# versioning, turn xxxx.y into xxxx.0y
version_unexpanded = importlib.metadata.version('fre-cli')
# ... complex string manipulation ...

# After (fre/__init__.py)
import os
version = os.getenv("GIT_DESCRIBE_TAG", "2025.04")
__version__ = version

This is more straightforward and relies on environment variables, which is a common pattern in modern Python projects. The default fallback maintains compatibility.

Package Configuration

Moving from setup.py to pyproject.toml follows Python's current best practices (PEP 621):

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "fre-cli"
# ...

dynamic = [
    "version",
]

[tool.setuptools.dynamic]
version = {attr = "fre.__version__"}

The dynamic configuration allows version to be determined at build time from the package attribute. We've also retained the pip install .[docs] functionality required by the readthedocs workflow

@ilaflott
Copy link
Member

ilaflott commented Aug 8, 2025

... gonna do it!

@ilaflott ilaflott merged commit c7bbcd7 into NOAA-GFDL:main Aug 8, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clean up documentation Improvements or additions to documentation new functioning New feature or request tricky Likely to encounter significant friction to solution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants