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

Allow reading package description/summary from Python file #10

Closed
ntninja opened this issue Mar 23, 2021 · 5 comments
Closed

Allow reading package description/summary from Python file #10

ntninja opened this issue Mar 23, 2021 · 5 comments

Comments

@ntninja
Copy link

ntninja commented Mar 23, 2021

See flit's usage guide for prior-art on this. It's a small thing, but it saves duplicating the summary line between the module docs and the pyproject file.

Also currently converting a project from flit to pdm (as I did) results in the project description being empty, with this feature it could instead be converted to a dynamic reference to the project's __init__.py file.

I'm thinking that using the tokenize module would be the best way to implement this (re won't really cut it). I can whip a PoC of this if you are interested. Cheers!

@frostming
Copy link
Contributor

frostming commented Mar 24, 2021

We are not likely to add this support in pdm-pep517. Ideally, per the spirit of PEP 621, Python files are not going to keep any metadata, as they should be stored in pyproject.toml ONLY. But I am happy to improve the format converter in pdm so that such usage in flit can be imported to PEP 621 correctly.

@frostming
Copy link
Contributor

Make sure that foobar’s docstring starts with a one-line summary of what the module is

In fact, I even didn't notice this line. IMO that is way too much assumption of what the main file should be like.

@frostming
Copy link
Contributor

frostming commented Mar 24, 2021

Closed by the linked PR above

@ntninja
Copy link
Author

ntninja commented Mar 24, 2021

Hmm… OK. Does that mean your looking to remove version = { from = "…" } longer term as well?

Also your PR doesn't account for the common idiom of from .version import __version__ in main. Many projects use (used?) this to be able to do execfile(os.path.dirname(__file__) + "/name/version.py") in their setuptools and sphinx configuration files for retrieving the just version number without importing everything. If your planning on keeping version.from then implementing this may be worthwhile since it allows to losslessly convert the version discovery logic from flit to pdm, otherwise emitting a warning when the version number is not found or found but now hard-coded into pyproject.toml would be helpful. Moved to PR discussion.

@ntninja
Copy link
Author

ntninja commented Mar 24, 2021

(Slighly sad that the description wasn't actually added, but not a big deal. It's probably not worth the hassle of keeping the code around in the long run.)

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