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

Modernize setuptools to use pyproject.toml #2519

Closed
wants to merge 6 commits into from

Conversation

kruton
Copy link
Contributor

@kruton kruton commented Jul 25, 2024

This is inline with the recommendations in Python Packaging User Guide. Migration to the new format should not change any build steps since the newer build invocations are already being used (e.g., python -m build).

requirements.txt is left as-is and read as "dynamic" data (i.e., outside of the pyproject.toml file) by setuptools. A further enhancement may be to separate out the production requirements from the development environment requirements if any exist.

zip_safe directive is removed since it is deprecated.

scripts is also deprecated in favor of entry_points which is now under [projects.scripts] in the same format. This means the changedetection.py file is not included, but it appears to be intended for local development as the changedetection.io script created during installation from entry_points has the same function.

include_package_data is true by default in pyproject.toml format, so it is excluded from the new file.

The changes were verified to build the same .whl and .tar.gz by examining the artifacts. The exceptions are:

  • In the .whl file there is no longer changedetection.py in the scripts directory.
  • zip_safe is no longer included
  • pyproject.toml is now included
  • In PKG-INFO:
    • Home-page field is now in Project-URL
    • Additional Classifier for Apache License 2.0
    • Keywords are now keywords instead of a long string

This is inline with the recommendations in Python Packaging User Guide at
https://packaging.python.org/en/latest/guides/modernize-setup-py-project/
Migration to the new format should not change any build steps since the
newer build invokations are already being used (e.g., "python -m build").

`requirements.txt` is left as-is and read as "dynamic" data (i.e., outside
of the `pyproject.toml` file) by setuptools. A further enhancement may
be to separate out the production requirements from the development
environment requirements if any exist.

`zip_safe` directive is removed since it is deprecated (See
https://setuptools.pypa.io/en/latest/deprecated/zip_safe.html).

`scripts` is also deprecated in favor of `entry_points` which is now
under `[projects.scripts]` in the same format. This means the
`changedetection.py` file is not included, but it appears to be intended
for local development as the `changedetection.io` script created during
installation from `entry_points` has the same function.

`include_package_data` is true by default in `pyproject.toml` format, so
it is excluded from the new file.

The changes were verified to build the same `.whl` and `.tar.gz` by
examining the artifacts. The exceptions are:
  * In the `.whl` file there is no longer `changedetection.py` in the
    `scripts` directory.
  * `zip_safe` is no longer included
  * `pyproject.toml` is now included
  * In `PKG-INFO`:
    * `Home-page` field is now in `Project-URL`
    * Additional Classifier for `Apache License 2.0`
    * `Keywords` are now keywords instead of a long string
@kruton
Copy link
Contributor Author

kruton commented Jul 25, 2024

I'm opening pull requests for random things because I was trying to test my change to the JavaScript sent to Playwright and found the testing instructions difficult to follow.

I'm going to try to port the test infrastructure to use testcontainers-python which should allow anyone (including CI systems) to simply run "pytest" and have it start up the containers it needs. Hopefully it will also make it easier to understand how to set up the correct environment on new tests.

@dgtlmoon
Copy link
Owner

thanks so much for this, I have to admit my python skills in general arent so great :) so this helps a lot!

pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
@dgtlmoon
Copy link
Owner

I'm going to try to port the test infrastructure to use testcontainers-python which should allow anyone (including CI systems) to simply run "pytest" and have it start up the containers it needs. Hopefully it will also make it easier to understand how to set up the correct environment on new tests.

ok interesting, lets do that on another PR and i'll take a look

kruton and others added 2 commits July 26, 2024 21:02
This allows us to use multiple license files until PEP 639 is implemented
in setuptools.
@kruton
Copy link
Contributor Author

kruton commented Nov 14, 2024

@dgtlmoon sorry, I forgot to push my change for the license files a few months ago!

@kruton kruton closed this Nov 27, 2024
@kruton kruton deleted the modern-build branch November 27, 2024 06:39
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.

2 participants