This is simple migration script, migrate pipenv to uv.
$ uv tool install pipenv-uv-migrate
# -- or --
$ pipx install pipenv-uv-migrate
$ uv init
To migrate Pipfile
to pyproject.toml
.
$ pipenv-uv-migrate -f Pipfile -t pyproject.toml
When want to run dry-run mode:
$ pipenv-uv-migrate -f Pipfile -t pyproject.toml -n
Dry-run mode is pyproject.toml
file does not overwrite, results are displayed on standard output.
Note
If the dependency already exists in the project dependency and you want to re-migrate it, please use the --re-migrate
option.
However, if the dependency is removed from pipenv, the project dependency will not be removed.
$ pipenv-uv-migrate -f Pipfile -t pyproject.toml --re-migrate
$ uv lock
If there is already a uv.lock
file, remove it first.
To install the defined dependencies for your project.
$ uv sync
This is an example of a Pipfile to be migrated.
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[packages]
requests = "*"
[dev-packages]
pytest = ">=5.2"
Migrate the above file to the following pyproject.toml.
[project]
name = "migrate-sample"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
authors = [
{ name = "Yoshiyuki HINO", email = "[email protected]" }
]
requires-python = ">=3.9"
dependencies = []
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
By executing this script, pyproject.toml is rewritten as follows.
[project]
name = "migrate-sample"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
authors = [
{ name = "Yoshiyuki HINO", email = "[email protected]" }
]
requires-python = ">=3.9"
dependencies = [
"requests",
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[dependency-groups]
dev = [
"pytest>=5.2",
]
Note
If the version of the dependent package is not specified, it will also be migrated. but the following warning will be displayed when lock or sync is performed with uv.
warning: Missing version constraint (e.g., a lower bound) for `requests`.
Please specify the version after migration.
- Fork and clone the repository, and create the development branch.
- Run
uv pip install -U -r pyproject.toml
to setup your develop environment. - Do your code.
- Run
bash scripts/test.sh
to check that your test passed. - Run
bash scripts/format.sh
andbash scripts/lint.sh
to check that you haven't warnings. - Open a PR on GitHub.
Test cases are in tests/testdata/toml
, update Pipfile
with additional entries and expect_pyproject.toml
with expected output.