-
Notifications
You must be signed in to change notification settings - Fork 165
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
Merged
mjpost
merged 4 commits into
mjpost:master
from
dhellmann:269-add-github-action-for-publishing
Jul 29, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9f7dfcf
add a tox environment for testing package builds
dhellmann e50dc4b
replace setup.py with static pyproject.toml
dhellmann dd20ed1
dynamically generate version from tags
dhellmann 6bc3b26
add github action to publish releases for tags
dhellmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# This workflows will upload a Python Package using Twine when a release is created | ||
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries | ||
|
||
name: Upload Python Package | ||
|
||
on: | ||
- push | ||
|
||
jobs: | ||
build-n-publish: | ||
name: Build and publish Python distributions to PyPI | ||
if: ${{ github.repository_owner == 'mjpost' }} | ||
|
||
runs-on: ubuntu-latest | ||
environment: release | ||
|
||
permissions: | ||
# IMPORTANT: this permission is mandatory for trusted publishing | ||
id-token: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
# with: | ||
# fetch-depth: 0 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install .[build] | ||
- name: Build sdist and wheel | ||
run: | | ||
python -m build | ||
- name: Publish distribution to PyPI | ||
if: startsWith(github.ref, 'refs/tags') | ||
uses: pypa/gh-action-pypi-publish@release/v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ sacrebleu.egg-info | |
*~ | ||
.DS_Store | ||
.idea/ | ||
sacrebleu/version.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ test: | |
bash test.sh | ||
|
||
pip: | ||
python3 setup.py sdist bdist_wheel | ||
python3 -m build . | ||
|
||
publish: pip | ||
twine upload dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
[build-system] | ||
requires = ["setuptools>=64", "setuptools_scm>=8"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "sacrebleu" | ||
dynamic = ["version"] | ||
authors = [{ name = "Matt Post", email = "post@cs.jhu.edu" }] | ||
maintainers = [{ name = "Matt Post", email = "post@cs.jhu.edu" }] | ||
description = "Hassle-free computation of shareable, comparable, and reproducible BLEU, chrF, and TER scores" | ||
readme = "README.md" | ||
license = { file = "LICENSE.txt" } | ||
classifiers = [ | ||
# How mature is this project? Common values are | ||
# 3 - Alpha | ||
# 4 - Beta | ||
# 5 - Production/Stable | ||
"Development Status :: 5 - Production/Stable", | ||
|
||
# Indicate who your project is intended for | ||
"Intended Audience :: Developers", | ||
"Intended Audience :: Science/Research", | ||
"Topic :: Scientific/Engineering", | ||
"Topic :: Scientific/Engineering :: Artificial Intelligence", | ||
"Topic :: Text Processing", | ||
|
||
# Pick your license as you wish (should match "license" above) | ||
"License :: OSI Approved :: Apache Software License", | ||
|
||
# List operating systems | ||
"Operating System :: POSIX", | ||
"Operating System :: MacOS :: MacOS X", | ||
"Operating System :: Microsoft :: Windows", | ||
|
||
# Specify the Python versions you support here. In particular, ensure | ||
# that you indicate whether you support Python 2, Python 3 or both. | ||
"Programming Language :: Python :: 3 :: Only", | ||
|
||
# Indicate that type hints are provided | ||
"Typing :: Typed", | ||
] | ||
|
||
requires-python = ">=3.8" | ||
|
||
keywords = [ | ||
"machine translation", | ||
"evaluation", | ||
"NLP", | ||
"natural language processing", | ||
"computational linguistics", | ||
] | ||
|
||
dependencies = [ | ||
"portalocker", | ||
"regex", | ||
"tabulate>=0.8.9", | ||
"numpy>=1.17", | ||
"colorama", | ||
"lxml", | ||
] | ||
|
||
[project.optional-dependencies] | ||
dev = ["wheel", "pytest", "mypy", "types-tabulate", "lxml-stubs", "setuptools"] | ||
ja = ["mecab-python3>=1.0.9,<2.0.0", "ipadic>=1.0,<2.0"] | ||
ko = ["mecab-ko>=1.0.0,<=1.0.1", "mecab-ko-dic>=1.0,<2.0"] | ||
|
||
[project.scripts] | ||
sacrebleu = "sacrebleu.sacrebleu:main" | ||
|
||
[project.urls] | ||
Repository = "https://github.com/mjpost/sacrebleu" | ||
|
||
[tool.setuptools.packages.find] | ||
include = ["sacrebleu*"] | ||
|
||
[tool.setuptools.package-data] | ||
sacrebleu = ["py.typed"] | ||
|
||
[tool.setuptools_scm] | ||
version_file = "sacrebleu/version.py" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,30 +14,53 @@ | |
# express or implied. See the License for the specific language governing | ||
# permissions and limitations under the License. | ||
|
||
__version__ = '2.4.1' | ||
__description__ = 'Hassle-free computation of shareable, comparable, and reproducible BLEU, chrF, and TER scores' | ||
__description__ = "Hassle-free computation of shareable, comparable, and reproducible BLEU, chrF, and TER scores" | ||
|
||
|
||
from .utils import smart_open, SACREBLEU_DIR, download_test_set | ||
from .utils import get_source_file, get_reference_files | ||
from .utils import get_available_testsets, get_langpairs_for_testset | ||
from .metrics.helpers import extract_word_ngrams, extract_char_ngrams | ||
# Backward compatibility functions for old style API access (<= 1.4.10) | ||
from .compat import ( | ||
corpus_bleu, | ||
corpus_chrf, | ||
corpus_ter, | ||
raw_corpus_bleu, | ||
sentence_bleu, | ||
sentence_chrf, | ||
sentence_ter, | ||
) | ||
from .dataset import DATASETS | ||
from .metrics import BLEU, CHRF, TER | ||
|
||
# Backward compatibility functions for old style API access (<= 1.4.10) | ||
from .compat import corpus_bleu, raw_corpus_bleu, sentence_bleu | ||
from .compat import corpus_chrf, sentence_chrf | ||
from .compat import corpus_ter, sentence_ter | ||
from .metrics.helpers import extract_char_ngrams, extract_word_ngrams | ||
from .utils import ( | ||
SACREBLEU_DIR, | ||
download_test_set, | ||
get_available_testsets, | ||
get_langpairs_for_testset, | ||
get_reference_files, | ||
get_source_file, | ||
smart_open, | ||
) | ||
from .version import __version__ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This import replaces the old static definition. |
||
|
||
__all__ = [ | ||
'smart_open', 'SACREBLEU_DIR', 'download_test_set', | ||
'get_source_file', 'get_reference_files', | ||
'get_available_testsets', 'get_langpairs_for_testset', | ||
'extract_word_ngrams', 'extract_char_ngrams', | ||
'DATASETS', | ||
'BLEU', 'CHRF', 'TER', | ||
'corpus_bleu', 'raw_corpus_bleu', 'sentence_bleu', | ||
'corpus_chrf', 'sentence_chrf', | ||
'corpus_ter', 'sentence_ter' | ||
"smart_open", | ||
"SACREBLEU_DIR", | ||
"download_test_set", | ||
"get_source_file", | ||
"get_reference_files", | ||
"get_available_testsets", | ||
"get_langpairs_for_testset", | ||
"extract_word_ngrams", | ||
"extract_char_ngrams", | ||
"DATASETS", | ||
"BLEU", | ||
"CHRF", | ||
"TER", | ||
"corpus_bleu", | ||
"raw_corpus_bleu", | ||
"sentence_bleu", | ||
"corpus_chrf", | ||
"sentence_chrf", | ||
"corpus_ter", | ||
"sentence_ter", | ||
"__version__", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding |
||
] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.