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

Compliance with PEP517 and PEP632 #4212

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

henserobbie
Copy link
Contributor

Description
This PR is an extension of PR #4211 with the goal of continuing to remove deprecated libraries, simplifying the build process and bringing the Pygame build configuration into compliance with PEP-517 and PEP-632. This PR is focused on the refractor of the setup.py file, the introduction of pyproject.toml and the removal of disutils from setup.py. The end goal is a more simplified and intuitive build system that uses pip install as the primary build command rather than running setup.py install.

Changes

  • pyproject.toml: This was added and metadata information and build dependencies that were previously defined in setup.py have been moved here.
    • The addition of the pyproject.toml file brings the build structure in line with PEP-517 allowing for build dependencies and the setuptools backend to be specified within.
  • setup.cfg: Added duplicate metadata to allow builds on Python 3.6.
    • Prior to Python 3.7, pip looked for metadata within the setup.cfg rather than the pyproject.toml. Duplicating the metadata was a simple fix to ensure continued support for Python 3.6.
  • setup.py: Refactored for organization, distutils was removed and replaced with setuptools, and metadata was removed.
    • The overall refactoring intent was to allow future maintainers to more easily make changes to smaller parts of the build system without having to parse through the entire process. This should hopefully help future-proof the process by allowing for deprecated dependencies to more easily be swapped out.
    • disutils was removed in most places in compliance with PEP-632, usages of distutils have been replaced by the appropriate counterparts in setuptools. If no appropriate counterpart was found a custom implementation of the utility was created.
    • Metadata removed from the setup.py file in favor of being moved to pyproject.toml and setup.cfg as described above.
  • buildconfig/appveyor.yml: Appveyor build changed to use pip instead of calling setup.py directly.
    • mscv analyze option is now specified via environment variable, USE_ANALYZE, which gets detected by the setup.py script similar to PYGAME_DETECT_AVX2. This is because you cannot pass arguments to the setup.py when building with pip.

Tests
These changes will be tested through Appveyor to ensure that the build process works similar to PR #4211. If the Appveyor targets record successful builds with all tests passing then that will be our indication that the updated build system functions as intended and works within the legacy code base.

Added metadata to pyproject.toml for pip to grab.
Added metadata to setup.cfg for python 3.6 builds because pip does not look for metadata in the pyproject.toml in python 3.6
Reordered setup script for organization, removed usage of distutils, removed metadata
Changed the install command to use pip wheel instead of calling the setup.py script directly, msvc analyze option is now detected as an environment variable in the setup.py script instead of an argument
Copy link
Member

@illume illume left a comment

Choose a reason for hiding this comment

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

Hi,

thanks for this cleanup work. Nice improvements.

I have a proposal below for merging this in pieces... What do you think?

These two commits could be merged in already if they were in a separate PR:

For the reorder commit it would be good if it could be smaller atomic commits. So it's easier to see what is changing, and also so that we can bisect more easily if there is a bug and we need to track it down later.

The pyproject.toml one is breaking things, so I think that one would need more work. Best keep it aside for now and let's get the other pieces merged in?

@@ -168,8 +168,7 @@ install:
- "%PYTHON% -m pip install Sphinx==4.5.0 sphinxcontrib-applehelp==1.0.2 pip install sphinxcontrib-devhelp==1.0.2 sphinxcontrib-htmlhelp==2.0.0 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5"
- "%PYTHON% setup.py docs"
- "%WITH_COMPILER% %PYTHON% -m buildconfig"
- "%WITH_COMPILER% %PYTHON% setup.py build -j4 %USE_ANALYZE%"
- "%WITH_COMPILER% %PYTHON% setup.py -setuptools %DISTRIBUTIONS%"
- "%WITH_COMPILER% %PYTHON% -m pip wheel . --wheel-dir=dist"
Copy link
Member

Choose a reason for hiding this comment

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

It would be better if the "-j4" part was passed in. However, it's not the end of the world, because it doesn't seem to help as much as it used to help. Now it only saves 2-4 minutes total off the build time.

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.

None yet

2 participants