1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How to read [project.urls] metadata inside a project's entry point?

Discussão em 'Python' iniciado por Stack, Julho 8, 2025.

  1. Stack

    Stack Membro Participativo

    Using pyproject.toml I wanted to read its [project.urls] from inside a script launched by one of the package's entry points. So using the full example pyproject.toml (altering the [build-system] to setuptools and wheel) how could (or should) I get https://example.com from the [project.urls]'s Homepage name programmatically inside a function of the spam:main_cli entry point?

    [build-system]
    requires = ["setuptools", "wheel"]
    build-backend = "setuptools.build_meta"

    [project]
    name = "spam-eggs"
    version = "2020.0.0"
    dependencies = [
    "httpx",
    "gidgethub[httpx]>4.0.0",
    "django>2.1; os_name != 'nt'",
    "django>2.0; os_name == 'nt'",
    ]
    requires-python = ">=3.8"
    authors = [
    {name = "Pradyun Gedam", email = "pradyun@example.com"},
    {name = "Tzu-Ping Chung", email = "tzu-ping@example.com"},
    {name = "Another person"},
    {email = "different.person@example.com"},
    ]
    maintainers = [
    {name = "Brett Cannon", email = "brett@example.com"}
    ]
    description = "Lovely Spam! Wonderful Spam!"
    readme = "README.rst"
    license = "MIT"
    license-files = ["LICEN[CS]E.*"]
    keywords = ["egg", "bacon", "sausage", "tomatoes", "Lobster Thermidor"]
    classifiers = [
    "Development Status :: 4 - Beta",
    "Programming Language :: Python"
    ]

    [project.optional-dependencies]
    gui = ["PyQt5"]
    cli = [
    "rich",
    "click",
    ]

    [project.urls]
    Homepage = "https://example.com"
    Documentation = "https://readthedocs.org"
    Repository = "https://github.com/me/spam.git"
    "Bug Tracker" = "https://github.com/me/spam/issues"
    Changelog = "https://github.com/me/spam/blob/master/CHANGELOG.md"

    [project.scripts]
    spam-cli = "spam:main_cli"

    [project.gui-scripts]
    spam-gui = "spam:main_gui"

    [project.entry-points."spam.magical"]
    tomatoes = "spam:main_tomatoes"

    Continue reading...

Compartilhe esta Página