Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Ability to get any of package's metadata fields from pyproject.toml (e.g. author) #8

Open
MarximusMaximus opened this issue Apr 13, 2022 · 3 comments

Comments

@MarximusMaximus
Copy link

I find myself wanting to fill out the rest of the dunder metadata variables for my package, but do not want to maintain the data in two places. I think(?) single-source is the correct answer, but it currently only handles version numbers.

@rabbit72
Copy link
Owner

hi @MarximusMaximus, thanks for your interest.
What kind of metadata from pyproject.toml are you interested in?

Probably you have some ideas of what code can look like. Code snippets can be very helpful.

@MarximusMaximus
Copy link
Author

I'd want the below fields in my package to be pulled from the field from pyproject.toml in parentheses and the importlib.metadata field in square brackets. This would be possible /just/ with using importlib.metadata but that fails if the project is being run directly as source from a git clone.

__author__ (authors) [Author + Author-email]
__authors__ (authors) [Author + Author-email]
__maintainer__ (maintainers) [Maintainer + Maintainer-email]
__maintainers__ (maintainers) [Maintainer + Maintainer-email]
__contact__ (maintainers) [Maintainer + Maintainer-email]
__license__ (license) [License]
__version__ (version) [Version]

maybe some others, but they seem a little less standardized in their dunder var naming like homepage and other urls

(also, for some reason, right now my test files via poetry are only grabbing the first value for list fields like author and urls...probably pebkac though)

@MarximusMaximus
Copy link
Author

Adding some references:
dunder metadata vars: https://stackoverflow.com/a/1523456
poetry pyproject.toml vars: https://python-poetry.org/docs/pyproject/
importlib.metadata vars: https://peps.python.org/pep-0345/

note to self: how to properly access multi-specify fields (arrays):

importlib.metadata.metadata("pytest_prefer_nested_dup_tests").get_all("Project-URL")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants