-
Notifications
You must be signed in to change notification settings - Fork 164
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 packaging and add release automation #270
modernize packaging and add release automation #270
Conversation
@martinpopel , this is related to #269 |
It looks like the linter doesn't like the way I replaced |
c98db25
to
f2152ac
Compare
Great thanks. |
f2152ac
to
715f024
Compare
I spotted a missing comma when I ran ruff locally, so I've pushed a new version. Let's see if CI likes that better. |
This missing comma is fixed, but we have another problem. I admit I never really understood the imports in sacrebleu. |
I can fix the circular import problem by importing from the new location. I don't see a tox environment for running the tests, how do you usually do that locally? |
715f024
to
cf527f5
Compare
I worked out how to run the tests, and the latest draft passed a bunch of them locally before I pushed it up for validation in CI. |
cf527f5
to
54737c3
Compare
I missed some places where automation was using the old approach to building packages. |
The build now fails with:
|
I've been trying to keep this change as small as possible, but there seem to be a few non-standard things about the layout and packaging of the source tree. I could go all in and fix all that, if you're interested? I don't want to overstep, though. |
Use setuptools to package in the same way, but use pyproject.toml for compatibility with tools relying on PEP 517.
Use setuptools-scm to get a version from the tag when released instead of looking for the contents of a file. Generate a version.py file to replace the static value in __init__.py.
This action responds when a tag is pushed to the main repository to build and upload both sdist and wheels to pypi.org. More details in https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
54737c3
to
6bc3b26
Compare
Let's see if specifying the finder parameters is enough. |
I like this, thanks. @mjpost do you agree with merging (as it is mostly you who publishes to PyPI)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have my editor configured to auto-format using ruff, and that has introduced a lot more change in these files than is truly needed.
"sentence_chrf", | ||
"corpus_ter", | ||
"sentence_ter", | ||
"__version__", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding __version__
here was needed.
get_source_file, | ||
smart_open, | ||
) | ||
from .version import __version__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import replaces the old static definition.
|
||
from .. import __version__ | ||
from ..version import __version__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import change eliminates a circular dependency between the sacrebleu
package and this module.
Thanks, @dhellmann! This looks good to me. Don't worry about overstepping, we appreciate the contribution. I assume I have to upload a secret somewhere for pypi authentication. It wasn't obvious to me what to do, however. Can you comment? |
Hmm, I found the link to the docs that you provided. I'll go through the OpenID authorization. |
Should I merge the current PR? Or did you want to go ahead and fix this as well? We could also consider this as a second PR, if you are interested. |
Let's leave it as a second PR. I have some deadlines at work that may mean it'll take a while before I can get to it, but if you file an issue and assign it to me I'll come back to it. |
Great, thanks, Doug! |
Within this PR, the CI tests work without any errors, but strangely after merging to master, there is an error:
Any ideas how to fix it? |
This line in the log output looks suspicious
It's probably coming from this line https://github.com/mjpost/sacrebleu/pull/270/files#diff-87c8be2ac3b248aef84cc474af838d7cc461b7f8fb7f5444ac75f4d8fc02e377R32 I used "[build]" there instead of "[dev]" so I think it's not installing the "build" package at all. |
This PR updates the packaging files to use pyproject.toml instead of
setup.py and setup.cfg.
It also adds dynamic version computation using setuptools-scm, to derive
the version of the package being built from the tag, so that there is
only one source of truth for the version number.
Finally, it adds a github action that will trigger when a tag is pushed
to build and upload the sdist and wheel files for the new version. There
are some manual steps that need to be completed before that github action
will work, to give github permission to publish to pypi.org.
Related to #269