Skip to content

Conversation

@ripariancommit
Copy link
Contributor

@ripariancommit ripariancommit commented Jun 3, 2025

This PR extends the github workflows to run PR checks, autotest changes, and auto-build distribution artifacts and documentation. It also changes the project's supported python versions (see below).

Changes

  1. Remove the legacy setup.legacy.py and debug.py files, since they are replaced by newer pyproject.toml and pytesting.
  2. Added a 'PR Check' workflow. It runs on every PR into the develop branch, and performs linting and commit policy checking (NOOP for now).
  3. Added a 'CI Testing' workflow, which also runs on each PR to the develop ref. It runs the project test suite on a matrix of Windows and Ubuntu GH runners, each with python 3.9 and the latest python (currently 3.13). If any environment fails, it will show on the PR.
  4. Added a 'Continuous Delivery' workflow, which runs when you merge or push commits into the master branch. It builds the project distribution and package files, and builds and publishes the project documentation to GH pages.
  5. During testing, I noticed that some of the client module code and docs do not work in python 3.5. Rather than add support for versions back to 3.5, I considered that it has not been supported upstream for several years. Further, python 3.9 (which is almost EOL as well) is the oldest python runtime that is supported on GH runners. So I have made sure the project is compatible-with and tested-on python 3.9, and updated the advertised supported versions in the pyproject.toml.
  6. Small changes.
    1. Removed version constraints from the pyproject.toml dependencies. I found some guidance that it is best to let these versions float, unless you know for a fact that your project requires a particular version or range.
    2. Added the ruff linter temporary files to .gitignore.
    3. Removed the html docs target from the all Makefile target.
    4. Cleaned up the Makefile targets.
  7. Updated the CHANEGLOG with user-visible changes from this PR and ripariancommit merge - Documentation #24.

Testing

  • Tested all these workflows on my own fork. here

Process

  • I release all copyright ownership to @b3yc0d3.
  • This PR is based on a develop ref that has the recent master changes merged into it. I will rebase this PR and mark it as ready for review once the develop branch is merged.

ripariancommit added a commit to ripariancommit/rule34Py that referenced this pull request Jun 3, 2025
Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
@b3yc0d3 b3yc0d3 marked this pull request as ready for review June 6, 2025 15:51
@b3yc0d3
Copy link
Owner

b3yc0d3 commented Jun 6, 2025

Merged the master back to develop, tested it, works so far

The 'all' make target builds the 'html' documentation target.

According to the GNU coding standards, the 'all' target "need not
rebuild any documentation". Since building the docs implies installing
the .[docs] optional python dependencies, it can cause unexpected errors
for builders.

So remove the 'html' target dependency.

Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
In several places in rule34Py, we use a type hinting syntax to declare a
union of types, with the pipe character. This is only a valid syntax in
>py3.10. It causes a TypeError in versions prior to that.

Import and use the 'Union' type from the typing module, to provide
backwards compatibility.

Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
Unless we have some specific information that a dependency prior to
some version does not work in the project, we should not arbitrarily
restrict the dep version.

Remove all '>=' dependency constraints in the pyproject.toml.

Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
The tomllib module was added to the standard python distribution
starting in version 3.11. Trying to build the docs on versions prior to
that will throw an import error.

Conditionally prefer to use the third-party 'tomli' module for python
runtimes prior to 3.11. Tomli provides a similar interface and
intentional backport support for TOML parsing on old pythons. It is
licensed under MIT.

Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
The project claims to support python versions back to 3.9, but these
aren't necessarily the versions that developers test their changes on.

Upgrade the PR check pipeline to use matrix testing of python 3.9 and
the latest python runtime on both windows and linux.

Also move linting into its own workflow stage, prior to the
build/testing stages.

Only upload artifacts from the latest-python build/test jobs, since they
are probably the most interesting.

Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
Python 3.9 is the earliest python version that is still supported by
python upstream. And it is the earliest version that we reliably test on
GH runners (without going to great lengths to manually install an
earlier python runtime).

So upgrade the minimum supported python version in the package metadata
to 3.9.

Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
The upstream rule34Py repo requires that PRs opened against it target
the 'develop' ref.

Add a pr-quailty check stage to validate the above assertion.

Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
The PR Check pipeline should contain only the logic that we want to run
on PR checks - like linting and policy checking.

Then we should have a CI pipeline that gates commits into the 'develop'
branch based on whether they pass the test suite.

Then we should have a CD pipeline that does things like deploy the GH
pages.
This project still supports python versions old enough to be before
general support for TOML files, and the pyproject.toml specification.
builders running python 3.9 might have difficulty following the tool
setup instructions without upgrading their setuptools version.

Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
The ruff linter generates a .ruff_cache directory. It is a temporary
file that should be ignored.

Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
This project is now well-tested by unit tests and autotesting. The
debug.py script can be removed in favor of the new testing.

Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
The dist target should only build the source distribution, per the GNU
standard. To get both the wheel and sdist, simply call

```
make all
make dist
```

Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
The requests-ratelimiter module "requires" python >=3.7,<4.0. Because it
is a dependency of this project, when you try to process the project
dependencies with poetry, you get a satisfaction warning that the python
versions required by this project (>3.9) technically could include
runtimes 4.0+, breaking compat.

It's an odd rqeuirement, that honestly should be fixed in upstream
requests-ratelimiter. Until we can get that upstreamed, just add '<4.0'
to our python requirement to resolve the error.

Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
The Twine utility is now used to publish the project artifacts, but it
is not included in the pyproject dependencies. Add it to the deps.

Use a small python script to programmatically extract the project name
and version from the pyproject.toml file, since that is the source of
the artifact names.

Generally clean up the Makefile targets.

Signed-off-by: Riparian Commit <ripariancommit@protonmail.com>
@ripariancommit
Copy link
Contributor Author

Rebased the branch to develop and cleaned up the Makefile some more. Ready for review and merge.

@b3yc0d3 b3yc0d3 added the enhancement New feature or request label Jun 9, 2025
@b3yc0d3 b3yc0d3 merged commit e731cb9 into b3yc0d3:develop Jun 9, 2025
18 checks passed
b3yc0d3 added a commit that referenced this pull request Jun 9, 2025
### Added

- Added captcha-compliance capabilities. You can now pass the client your captcha clearance token by completing the captcha in your browser, opening the response header, and writing your `cf_clearance` token into the client's `rule34Py.captcha_clearance` attribute and setting the client's `user_agent` attribute to match your browser.
	- Alternatively, set your execution environment's `R34_CAPTCHA_CLEARANCE` and `R34_USER_AGENT` variables to the appropriate values. The client will read form them during initialization.
	- See [this user guide](https://b3yc0d3.github.io/rule34Py/guides/captcha-clearance.html) for more information. (#24)
- Added a rate limiter for requests to the rule34.xxx base site (the PHP endpoint). By default, the client will now limit API calls that use this endpoint to 1 per second.
	- This behavior can be disabled by setting `rule34Py.set_base_site_rate_limit(False)`.
	- There is no rate limit on the api.rule34.xxx endpoint, which is assumed to handle rate-limiting on the server-side.
	- This new feature requires the `requests-ratelimiter` module.
- Added project documentation via sphinx docs. See: https://b3yc0d3.github.io/rule34Py/. It can be built by calling `make html`. (#24)

### Changed

- Changed the behavior of the `rule34Py.random_post()` method to function more like the website. The method now accepts no `tag` parameters, and returns a random post ID from all posts on the site. Users who want to use the old behavior of returning a random post from the first 1000 tag-search results are directed to do something like `random.choice(rule34Py.search([tags...]))`.
- Changed the `rule34Py.get_pool()` method to return a `Pool` object containing more complete information about a Pool.
	- The Pool's post ids can be accessed via the `Pool.posts` attribute.
- Moved the `:examples/` python recipes into tutorial documentation in the new sphinx documentation (`:docs/tutorials`). (#24)

### Deprecated

- Deprecated support for python runtimes 3.5 to 3.8, as they are EOL. The minimum supported python version is now 3.9. (#27)

### Removed

- Removed the deprecated `legacy.setup.py` file. Users are instructed to upgrade their setuptools installation and use `pyproject.toml` to build the project.
- Removed the `debug.py` file. Users are instructed to use the `make check` Makefile target to run the project's test suite. (#27)
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