@wizhut_tech/practical-uv
v0.1.0
Published
Convert a pip project (requirements.txt) into a uv project, from the command line — the conversion behind the Practical UV VS Code extension
Maintainers
Readme
practical-uv
Convert a pip project into a uv project from the command line. It does the same conversion as UV: Convert requirements.txt to uv project in the Practical UV VS Code extension, and plans its commands with the same code.
npx @wizhut_tech/practical-uv convertRun it in the project folder. It prints the exact commands, asks once, then runs them:
uv init --barewhen there is nopyproject.tomlyet. That createspyproject.tomland nothing else: no sample code, build backend, README,.python-versionor git repository.uv add -r requirements.txt, which imports the requirements into the project's dependencies, writesuv.lockand installs.venv.
Your requirements files are read, never changed.
Development requirements
npx @wizhut_tech/practical-uv convert requirements-dev.txtA file whose name marks it as development requirements (dev, test, lint, docs or local in the name, such as requirements-dev.txt, requirements_test.txt or requirements/dev.txt) goes into uv's dev group with uv add --dev -r.
Most of these files start with -r requirements.txt, and uv follows that line, so a dev-group import alone would copy every runtime package into the dev group too. The conversion imports the included runtime file into the project's dependencies first, then the development file into the dev group, then takes the included packages back out with uv remove --dev. One command migrates both files.
--main and --dev override what the file name says.
Options
practical-uv convert [requirements-file] [options]
requirements-file defaults to requirements.txt in the project folder
-C, --project <dir> the project folder, where pyproject.toml is (default: .)
--dev import into uv's dev group
--main import into the project's dependencies
-n, --dry-run print the commands, run nothing
-y, --yes run without asking (required when not in a terminal)
-h, --help show the help
-V, --version show the versionconvert can be left out: npx @wizhut_tech/practical-uv requirements-dev.txt works too.
Requirements
- Node.js 18 or newer, for
npx. - uv 0.5.29 or newer on
PATH(uv init --bare).
uv sets requires-python from the Python it finds.
As a library
The planning functions are exported, with no runtime dependencies:
const { classifyRequirementsFile, convertCommands } = require('@wizhut_tech/practical-uv');
classifyRequirementsFile('requirements-dev.txt'); // 'dev'
convertCommands({ hasPyproject: false, requirementsPath: 'requirements.txt', target: 'main' });
// [ 'uv init --bare', 'uv add -r requirements.txt' ]License
MIT
