Skip to content

Commit

Permalink
dynamically generate version from tags
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dhellmann committed Jul 26, 2024
1 parent c75d72a commit f636507
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ sacrebleu.egg-info
*~
.DS_Store
.idea/
sacrebleu/version.py
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[build-system]
requires = ["setuptools>=64"]
requires = ["setuptools>=64", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"

[project]
name = "sacrebleu"
version = "2.4.1"
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"
Expand Down Expand Up @@ -72,3 +72,6 @@ Repository = "https://github.com/mjpost/sacrebleu"

[tool.setuptools.package-data]
sacrebleu = ["py.typed"]

[tool.setuptools_scm]
version_file = "sacrebleu/version.py"
63 changes: 43 additions & 20 deletions sacrebleu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__

__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__",
]

0 comments on commit f636507

Please sign in to comment.