Skip to content

chore: use setup.cfg as main config file - #818

Merged
di merged 6 commits into
python:mainfrom
henryiii:chore/cfg
Feb 3, 2021
Merged

di merged 6 commits into
python:mainfrom
henryiii:chore/cfg

Conversation

@henryiii

@henryiii henryiii commented Jan 29, 2021 •

Copy link
Copy Markdown
Contributor

Followup to #817, related to #809.


I've split out the setup.cfg changes. I still would highly recommend setup.cfg, because:

  • It is a static, easily parsable file, which is highly superior to a Python file - for example, cibuildwheel should soon gain support for reading the Requires-Python metadata from the PEP 621 location or from setup.cfg, but setup.py is impossible to reliably parse.
  • It avoids many common issues, like opening files without with, encoding issues, and issues with accessing the version.
  • It keeps setup.py as just logic, making it clear what's "dynamic" and what's just regular metadata.
  • It's actually readable, much less boilerplate
  • Less chance of importing from distutils before setuptools
  • The PyPA projects, like twine, build, etc, use setup.cfg.
  • It's been supported since 2016
  • It's really easy to just say the fields are dynamically specifiable as keywords to setup, while it is harder to say the keywords to setup might be in [options] or in [metadata] or in ...

While I'm really excited for PEP 621 support, that's quite some time away (looks like funding has not even been secured yet), and then there's another period for the tooling to mature and become common enough to be used, it won't ever support Python 2 / PyPy 2, etc, so I expect adoption to be slow. And setup.cfg is still not going away, with some tools strongly refusing (cough, flake8, cough cough) to ever add pyproject.toml support (MyPy is still setup.cfg only too).

If people are writing setup.cfg's, it will be much easier to transition to pyproject.toml than from setup.py.

@henryiii
henryiii marked this pull request as draft January 29, 2021 01:23
@henryiii
henryiii marked this pull request as ready for review January 29, 2021 01:25
@di

di commented Jan 29, 2021

Copy link
Copy Markdown
Member

Can we experiment with using https://pypi.org/project/sphinx-tabs/ or https://pypi.org/project/sphinxcontrib-contentui/ to provide both the setup.py and setup.cfg configuration options simultaneously?

@henryiii

Copy link
Copy Markdown
Contributor Author

I went with exectuablebooks' sphinx-tabs, as I'm a Jupyterbook fan. (https://henryiii.github.io/level-up-your-python ;) ), and it likely is well maintained. Here's what the current state looks like:

Screen Shot 2021-01-29 at 2 44 00 PM

@di di left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small suggestions but otherwise this looks great.

Comment thread requirements.txt Resolved
Comment thread source/tutorials/packaging-projects.rst Resolved
Comment thread source/tutorials/packaging-projects.rst Resolved
Comment thread source/tutorials/packaging-projects.rst Resolved
Comment thread source/tutorials/packaging-projects.rst Resolved
Co-authored-by: Dustin Ingram <di@users.noreply.github.com>

@di di left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, will give it a day or so to let other folks review as well before merging.

@pradyunsg

Copy link
Copy Markdown
Member

May I suggest using sphinx-inline-tabs instead? I think it looks nicer. :)

@di

di commented Feb 2, 2021

Copy link
Copy Markdown
Member

Oh, look at that! Very nice @pradyunsg. Does it support markup in the tab title?

@henryiii

henryiii commented Feb 2, 2021

Copy link
Copy Markdown
Contributor Author

I'll try it soon! :)

@henryiii

henryiii commented Feb 2, 2021

Copy link
Copy Markdown
Contributor Author

No, it doesn't, though it seems to try harder:

Screen Shot 2021-02-02 at 10 43 20 AM

@henryiii

henryiii commented Feb 2, 2021

Copy link
Copy Markdown
Contributor Author

I'll push a version that uses this:

Screen Shot 2021-02-02 at 10 51 03 AM

@gaborbernat gaborbernat left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaborbernat

Copy link
Copy Markdown

@henryiii instead of posting the image it's better to post the link to the rendered document, e.g. https://python-packaging-user-guide--818.org.readthedocs.build/tutorials/packaging-projects/#configuring-metadata

@henryiii

henryiii commented Feb 3, 2021

Copy link
Copy Markdown
Contributor Author

The link is available already, "Details" on the readthedocs check. Putting an image in shows what it looks like without having to click a link, and once I've changed it, you only see the new version with a link, so you can't compare. Though I could have made the image clickable, I suppose :)

@gaborbernat

Copy link
Copy Markdown

The link is available already, "Details" on the readthedocs check. Putting an image in shows what it looks like without having to click a link, and once I've changed it, you only see the new version with a link, so you can't compare.

That link takes you to the main page, not the section you want to view the change rendered. It's nice to have a direct link available 😄

@di
di merged commit 9dfbeb0 into python:main Feb 3, 2021
@di

di commented Feb 3, 2021

Copy link
Copy Markdown
Member

Thanks @henryiii!

@henryiii

henryiii commented Feb 6, 2021

Copy link
Copy Markdown
Contributor Author

FYI, sphinx-tabs now supports rst in tab headings, including math. executablebooks/sphinx-tabs#102

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

V

@webknjaz

Copy link
Copy Markdown
Member

Hey @Bfox85, this sort of drive-through reviews is rather useless and is considered spam. Please use words if you have something meaningful to add here.

@pradyunsg

Copy link
Copy Markdown
Member

Does it support markup in the tab title?
[snip]
No, it doesn't, though it seems to try harder:

It does now!

pradyunsg/sphinx-inline-tabs#13

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

Successfully merging this pull request may close these issues.

5 participants