-
Notifications
You must be signed in to change notification settings - Fork 26
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
move build configuration from setup.cfg
to pyproject.toml
#38
Conversation
docs for this PR are hosted at https://oa-packaging-guide-preview--38.org.readthedocs.build/en/38/: |
3a500aa
to
ac48dbe
Compare
@WilliamJamieson already did this transition for several Astropy related projects, so maybe he can help review if he is willing? 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Going to let @astrofrog have a look as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your work on this! This seems like a good idea and the changes look good to me though I did not try out the template.
I am going to merge this as-is and then tidy up any loose ends after |
Hi, I was trying out the new package template. To make the installation work, I had to put a bunch of double quotes around the name and description of the project, and my name and email. Also, I had to comment out the |
Thanks for the report, I am planning on getting back to this tomorrow and finishing up the cleanup in #27 Why did you have to remove |
@Cadair I attach the exact report for this error:
|
haha ok! 😆 |
The thing about the thought experiment is hilarious indeed :D |
Should be |
Yep, it works! |
docs = [ | ||
"sphinx", | ||
"sphinx-automodapi", | ||
"tomli; python_version <\"3.11\"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zacharyburnett Sorry to necrobump this, but why do we need this one for the docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no worries! If a package ever wants to read metadata from pyproject.toml
(for instance to set author
and version
for Sphinx), it needs a TOML reader; before Python 3.11, an external package tomli
provided that, but the reading functionality was folded into the builtins in 3.11 with tomllib
. Thus, if you add this to conf.py
:
https://github.com/spacetelescope/jwst/blob/970bac9ac635aed35c7c1934761d42cd5934d981/docs/conf.py#L20-L23
if sys.version_info < (3, 11):
import tomli as tomllib
else:
import tomllib
then you can read the metadata regardless of which package is installed:
https://github.com/spacetelescope/jwst/blob/970bac9ac635aed35c7c1934761d42cd5934d981/docs/conf.py#L71-L72
with open(Path(__file__).parent.parent / "pyproject.toml", "rb") as metadata_file:
metadata = tomllib.load(metadata_file)['project']
Now that I think of it, I imagine that this can be done simpler with a __future__
import.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the info. I think because we don't do that in this guide I will probably drop it for now 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good, sorry to include extra stuff!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries!
setuptools
now supports the[project]
table for project metadata, defined by PEP621.Additionally,
setuptools
now supports its own entry inpyproject.toml
called[tool.setuptools]
(pypa/setuptools#1688, https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#setuptools-specific-configuration); however, it comes with the following disclaimer:Reading
toml
is supported natively in Python 3.11 withtomllib
. Given this, we can consolidate the build configuration into a singlepyproject.toml
file that can possibly be read by other build systems in the future.