Skip to content

Conversation

@ripariancommit
Copy link
Contributor

This patchset is the result of having to pull a long thread of changes. It started by attempting to deprecate the __vars__.py submodule, which meant moving the package metadata __authors__ and __version__ info into the module __init__.py. Then I took a closer look at what the modern recommendations are for representing package metadata and eventually decided that our existing pyproject.toml implementation based on setuptools is outdated and insufficient. Instead, this patchset updates the project to use poetry as the project build tool and addresses all of the fallout from that change.

Changes

  1. The __vars__.py submodule has been removed and its content distributed to the other modules that use it (basically just that __base_url__ and __api_url__ are now in api_urls.py.
  2. The pyproject.toml has been rewritten to use poetry as the build backend. In the process, I corrected some of the debatebly incorrect Authors and dependency information we had before.
    • Previously, setuptools was incorrectly declaring our developer dependencies (eg. ruff) as package "extras", when they are not. They aren't runtime dependencies. The new implementation makes them development-only "groups".
    • The project ownership metadata now just lists b3yc0d3 and his email as the project Author and Maintainer. I think that is the most correct thing to do. But standard practices here are all over the place in the python world.
    • The previous package metadata embedded the whole of the GPL v3 license text in the PKG-INFO file. This new metadata just lists the SPDX identifier for the license. The LICENSE and NOTICE.md files are still in the wheel and source distributions.
  3. There is now only one source of truth for the package version and other metadata - the pyproject.toml file. Everywhere else derives their values from it.
  4. Updated the Makefile implementation to use poetry as the canonical build tooling. Updated the developer documentation with the steps to use it.
    • tldr;
    pipx install poetry
    poetry install
    make
  5. I added a user guide to the docs explaining how to use importlib to extract the package ownership and version information. AFAICT, this is the "modern" way to extract package metadata, post-PEP-440.
  6. Removed the rule34Py.rule34Py.version() method, which has been deprecated for a while.
  7. Added a new make target linkcheck, that runs the built-in python link checker on the documentation. Fixed up some linting errors that it reported. Added this target to the lint make target.
  8. Updated the github workflows to use poetry.

Notes

  • You may note that the new pyproject.toml contains fewer "Classifiers" than it did previously. That's because poetry automatically adds classifiers for your license and supported python versions. I validated that the final classifiers are correct.
  • In a previous PR, I mentioned that I had to set a maximum python version, in order to satisfy poetry's dependency solver. I thought this was a bug that I would fix in the upstream pyrate-limiter project. But after a lot of research, I believe it is actually technically correct. So I have retained that version constraint.
  • I updated the make publish target to use poetry, which has a workflow to upload content to PyPI, just like Twine. If you would like to continue using Twine, we can revert this part. But I would recommend you give poetry a shot.

Testing

  • Manually validated the PKG-INFO/METADATA looks correct.
  • Rebuilt and hand-validated the documentation changes.
  • Tested the github workflows on this PR.

New METADATA file.

Metadata-Version: 2.3
Name: rule34Py
Version: 3.0.0
Summary: API wrapper for rule34.xxx
License: GPL-3.0-only
Keywords: adult,api-client,nsfw,rule34-pi,rule34.xxx
Author: b3yc0d3
Author-email: b3yc0d3@gmail.com
Maintainer: b3yc0d3
Maintainer-email: b3yc0d3@gmail.com
Requires-Python: >=3.9, <4.0
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: beautifulsoup4
Requires-Dist: lxml
Requires-Dist: requests
Requires-Dist: requests-ratelimiter
Project-URL: Documentation, https://b3yc0d3.github.io/rule34Py/
Project-URL: Issues, https://github.com/b3yc0d3/rule34Py/issues
Project-URL: Repository, https://github.com/b3yc0d3/rule34Py
Description-Content-Type: text/markdown

<README markdown>

Process

  • I release all copyright ownership to @b3yc0d3.

The __vars__ module contains dundered variables that are either (a)
module-level metadata like '__version__' or (b) static API endpoint
URLs.

Condense the codebase by moving the metadata into the package __init__
and the API endpoints into the api_urls module.

Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
Python community tooling generally assumes that module `__author__` and
`__email__` dunders are simple strings, rather than sets or lists.

Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
The project currently uses setuptools, build, and twine to coordinate
project build and publishing steps. And it leaves the business of
managing the python environment as an exercise to the user.

Further, the current setuptools pyproject implementation does not
correctly handle Maintainership contact information, and the python
dependencies are slightly messed up.

We should instead use poetry - which is a modern build tool for python
that most of our dependencies use - to manage the python venv and
coordinate dependencies.

Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
The sphinx linkcheck "builder" validates that documentation hyperlinks
(anchors) are not broken.

Use this facility within the `lint` make target.

Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
Add a unit test module which validates package metadata.

Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
The modern (post-PEP440) standard for distributing package metadata is
to make use of the package PKG-INFO file and the importlib.metadata
standard module.

Remove the obsolete module-level __author__ and __version__ dunders,
along with the rule34Py.version() method, in favor of the package
metadata.

Add a new guide, explaining to users how to extract the metadata.

Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
@b3yc0d3 b3yc0d3 added the enhancement New feature or request label Jun 19, 2025
@b3yc0d3 b3yc0d3 merged commit a5da5c5 into b3yc0d3:develop Jul 19, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants