Skip to main content

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.

Metadata

Release files for poetry-python-downgrader 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for poetry-python-downgrader 0.1.6
File Size Uploaded
poetry_python_downgrader-0.1.6.tar.gz 8.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for poetry-python-downgrader 0.1.6
File Interpreter ABI Platform
poetry_python_downgrader-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 18.7 kB

Release files / poetry_python_downgrader-0.1.6.tar.gz

Download URL poetry_python_downgrader-0.1.6.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4ef1219089ad2988323d1e271efa5dc51121b2c052acbe17668643297bc7b2b5
BLAKE2b-256 checksum
How to use checksums
2f06884b4c40e96238e6b19894c4ac43f2a24b7314f9a496ed1fb04b7502298d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.4 Linux/6.9.9-zen1-1-zen

Release files / poetry_python_downgrader-0.1.6-py3-none-any.whl

Download URL poetry_python_downgrader-0.1.6-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c9ae96e84683b49bfc2962c527ea088128ed73cec1895269d7ebc08b3bca80d
BLAKE2b-256 checksum
How to use checksums
c8d5515ccdb45346707f885360b19f32b1635e0b54b65d5866bdc33209da2a9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.4 Linux/6.9.9-zen1-1-zen

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page