Skip to main content

Convert requirements.txt to pyproject.toml

Project description

Poetry Import Plugin

PyPI version PyPI - Python Version GitHub issues pre-commit enable main semantic-release

poetry-import-plugin is a Python plugin for Poetry that simplifies the process of importing dependencies from requirements.txt files into a Poetry project. It allows you to integrate dependencies into specified dependency groups within the project's pyproject.toml file, optionally applying constraints from a constraints file. This plugin also supports updating the Poetry lock file and installing dependencies.

ps. It is renamed from Req2Toml

Features

  • Import dependencies from multiple requirements.txt files into specified groups.
  • Apply version constraints from a constraints file.

Installation

Please follow the official docs for the latest available methods.

Currently (as of 2024), poetry provides three ways to install the plugin:

With pipx inject

# To install
pipx inject poetry poetry-import-plugin

# To uninstall
pipx uninject poetry poetry-import-plugin

With pip

# To install
$POETRY_HOME/bin/pip install --no-cache-dir poetry-import-plugin

# To uninstall
$POETRY_HOME/bin/pip uninstall poetry-import-plugin

The self add command (not recommended for Windows users)

# To install
poetry self add poetry-import-plugin

# To uninstall
poetry self remove poetry-import-plugin

Usage

The import command can be used to import dependencies from requirements.txt files into your Poetry project. Below are the available options and arguments:

Arguments

  • files (optional, multiple): The requirements.txt files to import.

Options

  • --group, -g (optional, multiple): Specifies the dependency group(s) into which the dependencies will be imported. Multiple groups can be specified, each followed by a list of dependency files to import.
  • --constraint, -c (optional): Specifies a constraint file to apply version restrictions on dependencies during import.
  • --lock (optional): Updates the Poetry lock file without installing the packages.
  • --no-update (optional): Prevents updating the lock file when running the lock operation.
  • --install (optional): Runs a Poetry installation to install all dependencies defined in pyproject.toml.

Examples

  1. Import dependencies from requirements.txt into the default group:

    poetry import requirements.txt
    
  2. Import dependencies from multiple requirements.txt files into specific groups:

    poetry import -g dev dev-requirements.txt -g test test-requirements.txt
    
  3. Apply constraints from a constraints file during import:

    poetry import -c constraints.txt requirements.txt
    
  4. Update the Poetry lock file after importing dependencies:

    poetry import --lock requirements.txt
    
  5. Install all dependencies after importing:

    poetry import --install requirements.txt
    

Contact

For any questions or feedback, please open an issue on the GitHub repository or contact the author.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

poetry_import_plugin-3.0.0.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

poetry_import_plugin-3.0.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file poetry_import_plugin-3.0.0.tar.gz.

File metadata

  • Download URL: poetry_import_plugin-3.0.0.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.3 Linux/6.8.0-1021-azure

File hashes

Hashes for poetry_import_plugin-3.0.0.tar.gz
Algorithm Hash digest
SHA256 35ffdf6694f8c9f48c22206101212230addc5933732ba880b33478ff4a6bb538
MD5 b99726abf0de5af7e5f81ec4286b7bf1
BLAKE2b-256 37b3b2bd6337ce399f5a94a0e72fd63b0cf5c8caccf4842a37a90003d6580709

See more details on using hashes here.

File details

Details for the file poetry_import_plugin-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: poetry_import_plugin-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.3 Linux/6.8.0-1021-azure

File hashes

Hashes for poetry_import_plugin-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c29dd3f56f8986c0e1b088064391b5bd5e85366b4c8cbbeb72167c90603aae4
MD5 767227f849a40556bae212a936eb244a
BLAKE2b-256 d3284a5022b6d46f51190c78b7600e1e0f08e7f421aaf97693ecd9cf21a9ea87

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page