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

[FR] Automatically include setup.cfg file: files into the sdist #2821

Closed
1 task done
Sinclert opened this issue Oct 21, 2021 · 4 comments · Fixed by #3779
Closed
1 task done

[FR] Automatically include setup.cfg file: files into the sdist #2821

Sinclert opened this issue Oct 21, 2021 · 4 comments · Fixed by #3779

Comments

@Sinclert
Copy link
Contributor

Sinclert commented Oct 21, 2021

What's the problem this feature will solve?

When developers define a setup.cfg file instead of the classic setup.py file for setting the metadata for their packages, they have a small set of special directives (i.e. attr:, file:...) to take advantage of.

These directives cover a standardized use case of metadata building, which involves reading values from specific files in order to construct the package overall metadata. An example would be:

[metadata]
name = my-package
version = file: VERSION

All files being referenced with the file: directive are absolutely mandatory when building the package built distribution (as it includes the complete metadata), and still, they are not automatically included into the source distribution where they are supposed to be available for access.

This lack of "automatic inclusion of file: referenced files in the source distribution" forces developers to include those files to their projects MANIFEST.in, when it could be easily avoidable with a bit of intelligence on setuptools side.

Describe the solution you'd like

When defining a certain file within the file: setup.cfg directive, it should be automatically picked up when building the package's source distribution.

Alternative Solutions

Due to the lack of this feature, developers need to include those files into the MANIFEST.in:

### NOTE:
### Necessary to build a valid source distribution
include VERSION

Additional context

This issue comes from an internal conversation on the IRIS-HEP Slack channel, where @henryiii confirmed that what I just described is, indeed, a limitation, and that this was the correct repository to state the suggestion.

Code of Conduct

  • I agree to follow the PSF Code of Conduct
@Sinclert
Copy link
Contributor Author

👋🏻 Hey @abravalheri!

Just saw there has been some discussion regarding the dynamic metadata directives (attr: / file:). I would love to contribute a PR improving setup.cfg case handling, but I lack context of where to start. Do you know any piece of documentation covering how these directives are processed?

@abravalheri
Copy link
Contributor

Hi @Sinclert, the attr: and file: directives are handled in setuptools/config/setupcfg.py (for setup.cfg) and setuptools/config/pyprojecttoml.py (for pyproject.toml).

The description of how they are processed is given in https://setuptools.pypa.io/en/latest/userguide/declarative_config.html and https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#dynamic-metadata.

Setuptools basically resolve them when reading the configuration file and sets the corresponding attributes of a setuptools.dist.Distribution object, which inherits from distutils.dist.Distribution.

@Sinclert
Copy link
Contributor Author

Thanks for working on this @abravalheri

@abravalheri
Copy link
Contributor

Thank you very much for the initial push @Sinclert, I used a lot of your code/ideas in the process of creating this PR.

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