The convert_poetry2uv.py script is meant to easily convert the pyproject.toml to be consumed by uv instead of poetry.
Poetry v2 came out after this tool. The tool has been modified to work with poetry v2 format as well. Please create an issue/PR if you find any issues.
It has a dry-run flag, to have a temporary file to validate the output. When not running the dry-run the original file is saved with a .org extension.
uv run convert_poetry2uv.py <path to file> [-n]
You may need to make some manual changes. The layout might not be exactly to your liking. I would recommend using Even better toml in VSCode. Just open the newly generated toml file and save. It will format the file according to the toml specification.
- If you were using the poetry build-system, it is removed in the generated pyproject.toml.
- if you had optional dev groups, the dev group libraries will be used, the optional flag is removed
The script can be run as a tool using uvx
uvx convert-poetry2uv --help
Once the pyproject.toml is converted, you can use uv to manage your project. To start fresh, the .venv directory is removed followed by the creation and sync of the .venv directory.
rm -rf .venv
uv venv # or 'uv venv -p 3.12' to specify a python version
uv sync
With this you are good to go and are able to validate the migration was a success.
The script is also available on pypi as convert-poetry2uv
pip install convert-poetry2uv
Though I've tried to make it as complete as possible, it is not guaranteed to work for all cases. Feel free to contribute to the code or create an issue with the toml file that is not converted correctly.
The version is automatically updated with python-semantic-release. Take note of the pyproject.toml to see which keywords can be added to the commit message to ensure the correct version is released. The release is created when merged to main.
Note to self: When a new github workflow is required, don't forget to add the new workflow to the trusted publisher list.