-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modernize packaging and add release automation (#270)
* add a tox environment for testing package builds * replace setup.py with static pyproject.toml Use setuptools to package in the same way, but use pyproject.toml for compatibility with tools relying on PEP 517. * dynamically generate version from tags 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. * add github action to publish releases for tags 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
- Loading branch information
Showing
10 changed files
with
264 additions
and
263 deletions.
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 = "[email protected]" }] | ||
maintainers = [{ name = "Matt Post", email = "[email protected]" }] | ||
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
Oops, something went wrong.