Dependencies with Extras (Optional Features)

Convert requirements.txt entries with extras like requests[security] or celery[redis,msgpack] to pyproject.toml format. Learn how extras work in Python packaging.

Advanced Features

Detailed Explanation

Extras (also called optional dependencies or feature flags) allow a package to declare optional dependency sets. When you install a package with extras, additional dependencies specific to that feature are included.

requirements.txt with extras:

requests[security]>=2.31
celery[redis,msgpack]>=5.3
sqlalchemy[asyncio]>=2.0
uvicorn[standard]>=0.24
boto3[crt]>=1.28

Converted to pyproject.toml:

[project]
dependencies = [
    "requests[security]>=2.31",
    "celery[redis,msgpack]>=5.3",
    "sqlalchemy[asyncio]>=2.0",
    "uvicorn[standard]>=0.24",
    "boto3[crt]>=1.28",
]

Common packages with useful extras:

  • requests[security] -- adds pyOpenSSL, cryptography, and certifi for enhanced TLS
  • celery[redis] -- adds redis as a broker backend for Celery
  • sqlalchemy[asyncio] -- adds async support with greenlet
  • uvicorn[standard] -- adds httptools, uvloop, and websockets for optimal performance
  • boto3[crt] -- adds AWS Common Runtime for faster S3 transfers

Multiple extras are specified as a comma-separated list inside square brackets: celery[redis,msgpack] installs both the Redis broker and MessagePack serialization support.

The syntax is identical in both requirements.txt and pyproject.toml; only the surrounding structure (flat lines vs. TOML array) changes. Extras are preserved as-is during conversion.

Use Case

Converting a microservice project that uses several packages with extras (e.g., Celery with Redis and msgpack, SQLAlchemy with async support) from requirements.txt to modern pyproject.toml.

Try It — Requirements ↔ Pyproject

Open full tool