Skip to main content

Align with supported Python versions - automated with endoflife.date

Project description

cogeol

Align with supported Python versions - automated with endoflife.date

Features 🚀 Quick start 📚 Documentation 🤝 Contribute 👍 Adopters 📜 Legal


Features

cogeol is a library which allows you to:

  • Manage Python versions in your projects: no more checking if a given Python version reached its end of life, cogeol will do it for you.
  • Align with Scientific Python SPEC0: cogeol will allow you to align your project to the three latest supported Python versions
  • Caching: cogeol reaches out to End of Life Date to check the latest supported Python versions, and caches the results on disk to avoid unnecessary network requests.
  • Based on cog: Manage versions of Python by statically generated code (see examples below!)

Quick start

Installation

> pip install cogeol

Usage

[!TIP] Check out the documentation for all available functionalities and public-facing API.

  1. Open pyproject.toml of your project and find necessary to have requires-python field.
  2. Update it as follows (comments are crucial!):
# [[[cog
# import cog
# import cogeol
#
# cycle = cogeol.scientific()[-1]["cycle"]
# cog.out(f'requires-python = ">={cycle}"')
# ]]]
requires-python = ">=3.9"
# [[[end]]]

Now run the following from the command line:

> cog -c -r pyproject.toml

Now your requires-python field will be updated to the latest supported Python version!

For example (Python 3.11 is the latest supported version at the time of writing):

# [[[cog
# import cog
# import cogeol
#
# cycle = cogeol.scientific()[-1]["cycle"]
# cog.out(f'requires-python = ">={cycle}"')
# ]]]
requires-python = ">=3.11"
# [[[end]]] (sum: uZEo+p96oZ)

[!NOTE] Please notice a checksum, which verifies consistency of the changes at each run

Examples

Specifying Python version classifiers (click me)  

You can automate the classifiers in your pyproject.toml file like this:

# [[[cog
# import cog
# import cogeol
#
# for version in reversed(cogeol.scientific()):
#     cycle = version["cycle"]
#     cog.outl(f'  "Programming Language :: Python :: {cycle}",')
# ]]]
"Programming Language :: Python :: 3.11",
# [[[end]]]

Now run the following from the command line:

> cog -c -r pyproject.toml

and you should see the following (notice all versions are present!):

# [[[cog
# import cog
# import cogeol
#
# for version in reversed(cogeol.scientific()):
#     cycle = version["cycle"]
#     cog.outl(f'  "Programming Language :: Python :: {cycle}",')
# ]]]
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
# [[[end]]] (sum: FeG7grp2Dw)
Caching (click me)  

Let's assume you have the following code snippet in github-workflow.yml:

...
jobs:
  tests-reusable:
    strategy:
      matrix:
        python:
          #
          #           DO NOT EDIT UNTIL end marker
          #
          # [[[cog
          # import cog
          # import cogeol
          #
          # for version in reversed(cogeol.scientific()):
          #     cycle = version['cycle']
          #     cog.outl(f'          - "{cycle}"')
          # ]]]
          - "3.11"
          # [[[end]]] (sum: l3d2zGv79j)

in addition to your code in pyproject.toml using cogeol.

Now, if you run:

> cog -c -r pyproject.toml github-workflow.yml

The following will happen:

  • Both files will be updated with appropriate Python versions
  • Only one call to End of Life Date will be made (the results are cached on disk)

Next time you run the same command, the results will be read from the cache

Advanced (click me)  

For more examples check out this project's:

  • pyproject.toml file (see here)
  • Tests of the last three versions in GitHub Actions workflow (see here)

Contribute

We welcome your contributions! Start here:

Legal

  • This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
  • This project is copyrighted by open-nudge - the appropriate copyright notice is included in each file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cogeol-0.1.3.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cogeol-0.1.3-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file cogeol-0.1.3.tar.gz.

File metadata

  • Download URL: cogeol-0.1.3.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for cogeol-0.1.3.tar.gz
Algorithm Hash digest
SHA256 29204f08efd664b4b025e6e62300c71922730b6fafcbb5cdc33946913872046d
MD5 95aa1a1b0fdf0b736c876222ff0bdb4d
BLAKE2b-256 0271453facbc0a9eae4e74e7917a391df3e148527272b62f68957abdad76c47f

See more details on using hashes here.

Provenance

The following attestation bundles were made for cogeol-0.1.3.tar.gz:

Publisher: release.yml on open-nudge/cogeol

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cogeol-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: cogeol-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for cogeol-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c29720b1b9b0f6b39ff59c055b342e35e36c51a81ec55f92c67089e76125ff90
MD5 5ef52a2bff5ad975a5819ce98b31bdbf
BLAKE2b-256 29fd37dca7b3e5c3d260fc9763fee20848374d02c82f56cccf836daa54a02218

See more details on using hashes here.

Provenance

The following attestation bundles were made for cogeol-0.1.3-py3-none-any.whl:

Publisher: release.yml on open-nudge/cogeol

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page