8000 Migrate to pyproject.toml by hseg · Pull Request #168 · citeproc-py/citeproc-py · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Migrate to pyproject.toml #168

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Migrate to pyproject.toml #168

wants to merge 3 commits into from

Conversation

hseg
Copy link
@hseg hseg commented Jun 30, 2025

This makes the project more accessible to packagers used to PEP517-formatted repositories. Moreover, build tools are starting to deprecate old configuration mechanisms, see eg 1.

(Two things that struck me while testing this out -- we don't appear to be using any nosetest-specific features, so I'm surprised we're not just using the ubiquitous pytest instead (tests indeed work with it). Also, I'm unsure what tests/citeproc-test.py does, and whether it's meant to be executed as a standard test. pytest ignores it by default)

Note: One significant change is that /bin/csl_unsorted has been made a submodule of citeproc (I've created a citeproc.scripts.* namespace for these) so as to use standard entry points, which should be more portable across platforms.

Also, this incorporates #167 since I was already working on those bits
Closes: #165, #167

Copy link
Contributor
@tmorrell tmorrell left a comment

Choose a reason for hiding this comment

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

This looks like a good modernization. Thanks!

@tmorrell tmorrell added the minor Increment the minor version when merged label Jul 1, 2025
@tmorrell
Copy link
Contributor
tmorrell commented Jul 1, 2025

tests/citeproc-test.py gets run separately since it manages what errors are new.

python {toxinidir}/tests/citeproc-test.py --no-update
. There might be a more elegant way to handle that, but it seems to work alright.

I don't know why nosetest was used. If pytest works it might be worth switching.

I've tested this locally and it seems to work fine. I've tagged this for a minor release, but will leave the PR open for at least a week in case there is additional feedback.

hseg added 2 commits July 1, 2025 21:58
This makes the project more accessible to users expecting a
PEP517-formatted repository. Moreover, build tools are starting to
deprecate old configuration mechanisms, see eg [1].

[1]: pypa/pip#6334
@hseg
Copy link
Author
hseg commented Jul 1, 2025 via email

@hseg hseg force-pushed the pyproject branch 2 times, most recently from 5b5e02c to 23715d8 Compare July 2, 2025 12:54
@hseg
Copy link
Author
hseg commented Jul 2, 2025

Hm, actually I seem to have broken tox, one moment.

The tests all work unchanged, and pytest's autodetection already picks
up on all of them with no need for configuration.
Also, since tests/citeproc-test.py isn't named test_*.py, it is
automatically ignored.
Preferring pytest over nose given that it's more maintained nowadays.
Added pytest-cov to automatically run coverage for us.
@hseg
Copy link
Author
hseg commented Jul 2, 2025

OK, it seems the combination of invoking as pytest rather than python -m pytest (which didn't add the citeproc package to pythonpath) and the changedir made pytest fail to find some files.
I've opted to remove the changedir, given that I haven't seen it in any other project (only have seen {envtmpdir} used to build the rply docs), but another approach is to just append {toxinidir} to the pytest arguments if that is preferrred.
I've validated these changes by running tox in a venv here, and other than the obvious warnings due to tests/citeproc-test.py, everything went fine, so I'm more confident this should work now.

Copy link
Contributor
@tmorrell tmorrell left a comment

Choose a reason for hiding this comment

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

I'm a bit nervous about the error OSError: Error reading file '/Users/runner/work/citeproc-py/citeproc-py/citeproc/data/schema/csl.rng': failed to load "/Users/runner/work/citeproc-py/citeproc-py/citeproc/data/schema/csl.rng": No such file or directory`. This should be generated by setup.py. Though there seems to be another missing file error, so maybe it's just something about the current directory. In any event the tests need to pass in order to merge.

@hseg
Copy link
Author
hseg commented Jul 3, 2025

Of course, investigating...

@hseg
Copy link
Author
hseg commented Jul 3, 2025

Oddly enough, when I run the actions on ubuntu-latest using https://github.com/nektos/act, I get no errors. But then, perhaps it's doing things differently?

@hseg
Copy link
Author
hseg commented Jul 3, 2025

BTW, the tests/citeproc-test.py warnings are very distracting, but I'm unsure how to fix them

@hseg
Copy link
Author
hseg commented Jul 3, 2025

I don't get errors building in a chroot, either

@hseg
Copy link
Author
hseg commented Jul 3, 2025

Wait! Isn't that path part of a submodule?

@hseg
Copy link
Author
hseg commented Jul 3, 2025

Ahah! It appears the custom build hooks are meant to generate that .rng file, but for some reason tox isn't invoking them. (That .rng file isn't part of the submodule, rather is generated by convert_rnc in setup.py)

@hseg
Copy link
Author
hseg commented Jul 3, 2025

... also, why on earth is tests/citeproc-test.py doing its own submodule management?

8000

@tmorrell
Copy link
Contributor
tmorrell commented Jul 3, 2025

That's the way it was implemented a decade ago? Way before my time....

The submodules that are part of the code are pretty fixed, while the tests get updated more often. And the approach in the tests is honestly a bit more automated and readable (and avoids confusion like #172)

@hseg
Copy link
Author
hseg commented Jul 3, 2025

Not sure I agree, but that's an issue for another PR.

Found the proximal cause for the breakage -- it's my dropping of changedir = {envtmpdir} from tox.ini, but I'd rather figure out how to not need that than revert it.

@hseg
Copy link
Author
hseg commented Jul 3, 2025 via email

@tmorrell
8666 Copy link
Contributor
tmorrell commented Jul 3, 2025

I'm supportive of the move to importlib_resources to make pathing more consistent. I'm also fine treating setup.py as a special case.

Also no rush! Have a good weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Increment the minor version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Licensing: Clarify this is BSD-2-Clause-Views, not BSD-2-Clause
2 participants
0