#python-packages #package-manager #python #uv #package-management #poetry #migration

bin+lib uv-migrator

Tool for converting various python package soltutions to use the uv solution by astral

29 stable releases

new 2024.7.4 Nov 20, 2024
2024.7.3 Nov 15, 2024
2024.3.3 Oct 27, 2024

#408 in Development tools

Download history 956/week @ 2024-10-07 22/week @ 2024-10-14 301/week @ 2024-10-21 44/week @ 2024-10-28 226/week @ 2024-11-04 1391/week @ 2024-11-11 245/week @ 2024-11-18

2,016 downloads per month

MIT license

43KB
884 lines

UV Migrator

UV Migrator is a Rust-based tool designed to facilitate the migration of Python projects from various dependency management systems (like pip or poetry) to the UV package manager. This tool automates the process of creating a new UV-based project structure while preserving existing dependencies.

Disclaimer

This project is not associated with astral or the uv project in anyway, please use at your own risk and keep backups of your dependency declarations for reference

Features

  • Supports migration from Poetry and PEP 621 project structures
  • Creates a new virtual environment using UV
  • Automatically transfers dependencies from the existing pyproject.toml or requirements.txt to the new UV-based project
  • Attempts to migrate all [tool.*] configs to the new pyproject.toml file
  • By default, if using dependency groups in poetry or requirements-some_group_name.txt with req files they will be translated into uv dependency groups otherwise they will use the main and --dev conventions
  • Handles both main and development dependencies
  • Provides detailed logging for transparency and debugging
  • Supports importing extra index URLs from global pip configuration
  • Allows specifying additional index URLs during migration
  • By default, doesn't pin the python version via a .python-versions file in case the user uses asdf/mise and .tool-versions files

Prerequisites

Before you begin, ensure you have the following installed:

  • Rust (latest stable version)
  • UV package manager

Installation

Install to .local/bin

curl https://uv-migrator.stvnksslr.com/install.sh | bash

Install via Cargo

cargo install uv-migrator

The compiled binary will be available in the target/release directory.

Supported Package Managers

  • poetry
  • pip (requirements.txt)

In Progress

  • pdm
  • hatch
  • pipenv
  • Open Issues for more!

Usage

Run the UV Migrator with the path to your existing project directory:

uv-migrator path/to/your/project

or

1. cd /to/project
2. uv-migrator .

Additional Options

  • --import-global-pip-conf: Import extra index URLs from ~/.pip/pip.conf

    uv-migrator path/to/your/project --import-global-pip-conf
    
  • --import-index: Specify additional index URLs to import (can be used multiple times)

    uv-migrator path/to/your/project --import-index https://custom.pypi.org/simple/
    
  • --help: Display comprehensive help information

    uv-migrator --help
    
  • --self-update: Update UV Migrator to the latest version

    uv-migrator --self-update
    

Dependencies

~20–36MB
~573K SLoC