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

Use declarative metadata with pyproject.toml #10356

Merged
merged 2 commits into from Sep 13, 2022

Conversation

AA-Turner
Copy link
Member

Requires #10355, #10352

This moves Sphinx's package metadata to the standards-compliant format, preserving setuptools-specific items with the tool.setuptools backend.

Relates

@AA-Turner
Copy link
Member Author

It seems that tox requires fully building and installing the package, and setuptools dropped support for Python 3.6 in December 2021 (https://setuptools.pypa.io/en/latest/history.html#v59-7-0), before the support for pyproject.toml was added.

I'm going to mark this as draft for now, I may look at e.g. flit later (that Sphinx uses egg_info configuration slightly complicates things, though).

A

@AA-Turner AA-Turner marked this pull request as draft April 16, 2022 21:52
pyproject.toml Outdated Show resolved Hide resolved
@tk0miya tk0miya added the type:proposal a feature suggestion label Apr 17, 2022
@AA-Turner AA-Turner force-pushed the declarative-config branch 6 times, most recently from 2414dda to 2091cc2 Compare April 17, 2022 23:05
@AA-Turner
Copy link
Member Author

It was easier than expected to move to flit, so I'm un-marking as draft. CI is passing.

A

@AA-Turner AA-Turner marked this pull request as ready for review April 17, 2022 23:11
@AA-Turner AA-Turner added this to the 5.x milestone May 23, 2022
@AA-Turner AA-Turner self-assigned this May 23, 2022
@nanonyme
Copy link

To be fair, Python 3.6 is since EOL this January.

@tk0miya
Copy link
Member

tk0miya commented May 29, 2022

As I commented at #9820 (comment), my large concern is supporting users. I suppose most of them would not know python at all. So I hesitate to depend on the latest libraries.

I can accept to migrate package metadata that is not related to install itself (ex. classifiers). But I'm not sure it's worthy for us to migrate it partially.

@nanonyme
Copy link

Users using pip will not notice any difference with this.

@AA-Turner
Copy link
Member Author

As I commented at #9820 (comment), my large concern is supporting users. I suppose most of them would not know python at all. So I hesitate to depend on the latest libraries.

I entirely agree we should be supporting users. I see three groups:

  1. "python user" -- uses pip install sphinx
  2. "distro user" -- uses apt install sphinx (or yum, dnf, etc.)
  3. "sources user" -- uses git clone https://github.com/sphinx-doc/sphinx.git && cd sphinx && python setup.py build or similar

For group 1, pip manages everything automatically. It fetches pacakges matching the constraints that we specify, and ensures a consistent installation.

For group 2, the redistributor (debian, RHEL, ubuntu, etc) ensures that the system has a consistent installation, and installs everything themselves.

For group 3, there are no guarantees at all -- it is up to the user to ensure every dependency is installed and there are no conflicts.

I would argue that the users of Sphinx are mostly in group 1, then group 2, then 3. There are five million downloads of Sphinx per month from PyPI. We can't know numbers for redistributors, or proxies of PyPI, so this is an inexact science.

Group 2 users are in a precarious position when they attempt to use extensions like autodoc -- as Sphinx needs to import the module being documented, all the module's dependencies must be present. This might create conflicts with other Python packages in the distribution's global installation, which is why environments of some kind (venv, virtualenv, conda env) are so strongly reccomended.

I would like to solve these challenges -- having a single distributable self-contained binary that is "sphinx" would be amazing. It would free us from constraints on system Python versions etc, whilst allowing integration with a particular python version for those that install via pip. However we don't have this (sadly).

My conclusions are the following:

  • pip users will be fine with any sort of version constraints, as pip is a proper package manager.
  • users of distribution (ubuntu etc) supplied Sphinx binaries will be fine, as distributions manage all their versions independently of us, often pinning more strictly etc to ensure that the system as a whole has a consistent Python installation.
  • Hence, we should not worry about redistributors.
  • Users who install from source are assumed to be experts, and we do not provide any extra support here.

The issue in this PR -- changing our build process -- is unrelated to any of these issues. For users of pip, pre-build wheels are downloaded from PyPI. For distribution users, only the packaging team need to care about our build process, and all distributions have PEP 517 / 518 tool chains now. From this PR, nothing will change for end users.


I'm happy to propose a PR to Sphinx's policies @tk0miya to outline this and provide a place for more discussion, but I would strongly argue that we can make these important improvements and changes in our build system and dependencies without negatively affecting end users, which is the most important thing.

A

(Sorry for the long message, I didn't intend to write this much!)

@nanonyme
Copy link

nanonyme commented May 30, 2022

Note in case 3 you can do pip install . and it becomes case 1 again. The real case 3 is offline install, that is, users who manually download all deps.

@AA-Turner AA-Turner force-pushed the declarative-config branch 2 times, most recently from 7f45bc2 to 1a28a4e Compare June 2, 2022 19:26
@danieleades
Copy link
Contributor

mypy config should also be moved into pyproject.toml file

@danieleades
Copy link
Contributor

as an aside, is there any interest in moving to a full-blown package manager, such as Poetry?

@AA-Turner
Copy link
Member Author

I would like to move forwards with this--@tk0miya does my earlier comment make sense?

The one line summary is that I propose we only support users installing from wheels on PyPI -- anything else is non-standard, and as we are volunteers here I think reasonable to put those limits on it.

A

- Move to pyproject.toml metadata
- Update references to `setup.py`
- Use pypa/build
- Update workflows and tooling
@AA-Turner AA-Turner merged commit b347657 into sphinx-doc:5.x Sep 13, 2022
@AA-Turner AA-Turner deleted the declarative-config branch September 13, 2022 09:31
@AA-Turner
Copy link
Member Author

I've gone ahead with this for 5.2--though if we get reports from users that the new configuration seriously breaks things I will look at reverting the change.

A

@@ -4,6 +4,10 @@ Release 5.2.0 (in development)
Dependencies
------------

* #10356: Sphinx now uses declarative metadata with ``pyproject.toml`` to
create packages, using PyPA's ``build`` project as a build backend. Patch by
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noticed this in the ChangeLog — build is actually a frontend, flit_core is the backend.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, thank you.

A

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

@AA-Turner AA-Turner modified the milestones: 5.x, 5.2.0 Oct 4, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type:proposal a feature suggestion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants