Skip to main content

A tool to downgrade poetry packages for compatibility with specific Python versions.

Project description

Poetry Python Downgrader

A tool to downgrade Poetry packages for compatibility with specific Python versions.

Build Coverage Status License: MIT PyPI version As a github action

This project is also available as a GitHub Action!

Quickstart

downgrade-pyproject-for-python pyproject.toml 3.8 --in-place

This command will modify your pyproject.toml file to make it compatible with Python 3.8. I would not recommend using the generated pyproject.toml file for anything but testing whether your project can be made compatible with a specific python version - this is in no way reliable enough to publish.

Installation

Using pipx (recommended)

pipx install poetry-python-downgrader

How it works

Poetry Python Downgrader analyzes your pyproject.toml file and performs the following steps:

  • Reads the current dependencies and their version constraints.
  • For each dependency, it queries PyPI to find the highest version compatible with the target Python version.
  • Updates the pyproject.toml file with the new version constraints.
  • Removes dependencies that don't have a compatible version for the target Python version.
  • Updates the Python version requirement in the pyproject.toml file.

Usage examples

Basic usage

downgrade-pyproject-for-python pyproject.toml 3.8

This command will print the updated pyproject.toml content to stdout.

Save to a new file

downgrade-pyproject-for-python pyproject.toml 3.8 -o new_pyproject.toml

This will save the updated content to new_pyproject.toml.

Modify the original file

downgrade-pyproject-for-python pyproject.toml 3.8 --in-place

Pin versions

downgrade-pyproject-for-python pyproject.toml 3.8 --pin-versions

This will pin the versions to exact compatible versions instead of using caret ranges; as a result you'll have a guarantee of never having too new of a version installed, which is useful in CI.

Use a Custom PyPI Repository

downgrade-pyproject-for-python pyproject.toml 3.8 -r https://custom-pypi.example.com/pypi

This doesn't add the custom repository, but replaces pypi with it, so only dependencies available there will stay.

Backstory

This project was born out of a specific need in a complex Python project. The project was being developed for Python 3.10 and consisted of multiple independent components targeting different platforms. The goal was to continuously determine which components would work with Python 3.8 without manually downgrading each dependency every time.

The challenge was that some dependencies had Python 3.10 as the minimum requirement, and some were only compatible with 3.8 up to a specific version, making it impossible to simply run the tests on Python 3.8. The solution was to create a tool that could automatically downgrade all dependencies to be Python 3.8-compatible, remove incompatible dependencies.

This is the result, providing an automated way to adjust pyproject.toml files for compatibility with earlier Python versions.

Note on Using Poetry's Internal APIs

This project directly uses some of Poetry's internal APIs, which is generally not recommended for production use. While this approach works well for a small project like this, one that's not ever meant to be used in a production environment, be aware that future updates to Poetry might break compatibility. Use this tool with caution and feel free to open an issue if something breaks!

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

poetry_python_downgrader-0.1.6.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

poetry_python_downgrader-0.1.6-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file poetry_python_downgrader-0.1.6.tar.gz.

File metadata

  • Download URL: poetry_python_downgrader-0.1.6.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.4 Linux/6.9.9-zen1-1-zen

File hashes

Hashes for poetry_python_downgrader-0.1.6.tar.gz
Algorithm Hash digest
SHA256 4ef1219089ad2988323d1e271efa5dc51121b2c052acbe17668643297bc7b2b5
MD5 f946bacbb6d803555c0488bbf1b09b32
BLAKE2b-256 2f06884b4c40e96238e6b19894c4ac43f2a24b7314f9a496ed1fb04b7502298d

See more details on using hashes here.

File details

Details for the file poetry_python_downgrader-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for poetry_python_downgrader-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9c9ae96e84683b49bfc2962c527ea088128ed73cec1895269d7ebc08b3bca80d
MD5 5f95e581d693b26c9db7d35c5d958318
BLAKE2b-256 c8d5515ccdb45346707f885360b19f32b1635e0b54b65d5866bdc33209da2a9c

See more details on using hashes here.

Supported by

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