[Python] How to export dependencies to requirement.txt and requirements-dev.txt using...

Discussão em 'Python' iniciado por Stack, Maio 15, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using uv as my package manager in my Python project. My pyproject.toml file looks like this:

    [project]
    name = "some-name"
    version = "0.1.0"
    readme = "README.md"
    requires-python = ">=3.11"
    dependencies = [
    <some-dependencies>
    ]

    [dependency-groups]
    dev = [
    <some-dev-dependencies>
    ]


    I'm using uv-pre-commit to export dependencies in a requirement.txt file. But what I really need is to separate general and dev dependencies in separate files. Right now I have this in my .pre-commit-config.yaml:

    repos:
    - repo: https://github.com/astral-sh/uv-pre-commit
    # uv version.
    rev: 0.6.17
    hooks:
    - id: uv-export
    - id: uv-lock


    But this would export everything in one single requirement.txt file.

    from what I see in the documents, I can do something like this:

    - repo: https://github.com/astral-sh/uv-pre-commit
    # uv version.
    rev: 0.7.3
    hooks:
    # Run the pip compile
    - id: pip-compile
    name: pip-compile requirements.in
    args: [requirements.in, -o, requirements.txt]
    - id: pip-compile
    name: pip-compile requirements-dev.in
    args: [requirements-dev.in, -o, requirements-dev.txt]
    files: ^requirements-dev\.(in|txt)$


    But I'm not sure if this really fits in my case because I don't have *.in files. So I can't figure out how to deal with a pyproject.toml file in uv-pre-commit

    Does anyone have an idea how to separate it?

    Continue reading...

Compartilhe esta Página