[Python] How can I specify console_scripts that are to be installed for a "variant"?...

Discussão em 'Python' iniciado por Stack, Março 26, 2025.

  1. Stack

    Stack Membro Participativo

    The Setuptools documentation describes how to specify "optional dependencies" for what it calls a "variant" of a Python package.

    In pyproject.toml, we can enter something like the following:

    [project]
    name = "mypkg"
    # ...
    [project.optional-dependencies]
    PDF = ["ReportLab>=1.2", "RXP"]


    This enables installation like:

    $ pip install 'mypkg[PDF]'


    to include the optional dependencies.

    I would like to install some scripts only if the PDF variant is selected. For an unconditional installation we can do this to make my-script available after installation:

    [project.scripts]
    my-script = "mypkg.scripts.my_script:main"
    my-pdf-script = "mypkg.scripts.my_pdf_script:main"


    How can I specify that my-pdf-script should be installed only if the PDF variant is requested?

    Continue reading...

Compartilhe esta Página