Skip to content

Commit d337e99

Browse files
committed
Switch to uv.
This also involves: - dropping Python 3.7 support - changing Babel minimum version to get tests to pass - fixing all the things
1 parent 40e624c commit d337e99

File tree

11 files changed

+125
-131
lines changed

11 files changed

+125
-131
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,56 +16,35 @@ jobs:
1616
strategy:
1717
matrix:
1818
python-version:
19-
- "3.7"
2019
- "3.8"
2120
- "3.9"
2221
- "3.10"
2322
- "3.11"
2423
- "3.12"
25-
- "pypy3.7"
2624
- "pypy3.8"
2725
- "pypy3.9"
2826
- "pypy3.10"
2927
os: [ubuntu-latest]
3028

31-
3229
steps:
3330
- uses: actions/checkout@v4
34-
- name: Set up Python ${{ matrix.python-version }}
35-
uses: actions/setup-python@v4
31+
- name: Set up Python ${{ matrix.python-version }} with uv
32+
uses: drivendataorg/setup-python[email protected]
3633
with:
3734
python-version: ${{ matrix.python-version }}
38-
allow-prereleases: true
39-
- uses: actions/cache@v2
40-
with:
41-
path: ~/.cache/pip
42-
key: ${{ runner.os }}-pip-${{ matrix.python }}-${{ hashFiles('requirements*.txt') }}
35+
cache: 'packages'
36+
4337
- name: Install dependencies
4438
run: |
45-
python -m pip install --upgrade pip
46-
pip install -e .
47-
pip install -r requirements.txt
48-
pip install -r requirements-test.txt
39+
uv sync
4940
- name: Test with pytest
5041
run: |
51-
pytest
42+
uv run pytest
43+
5244
5345
linters:
5446
runs-on: ubuntu-latest
5547
steps:
56-
- uses: actions/checkout@v2
57-
- name: Set up Python
58-
uses: actions/setup-python@v2
59-
with:
60-
python-version: 3.9
61-
- uses: actions/cache@v2
62-
with:
63-
path: |
64-
~/.cache/pip
65-
~/.cache/pre-commit
66-
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements*.txt') }}
67-
- name: Install dependencies
68-
run: |
69-
pip install pre-commit
70-
- name: pre-commit linters
71-
run: pre-commit run --all-files --show-diff-on-failure --color=always
48+
- uses: actions/checkout@v3
49+
- uses: actions/setup-python@v3
50+
- uses: pre-commit/[email protected]

.pre-commit-config.yaml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@ repos:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
77
- repo: https://github.com/charliermarsh/ruff-pre-commit
8-
rev: v0.3.4
8+
rev: v0.4.5
99
hooks:
1010
- id: ruff
1111
args: [ --fix, --exit-non-zero-on-fix ]
12-
- repo: 'https://github.com/mgedmin/check-manifest'
13-
rev: '0.46'
14-
hooks:
15-
- id: check-manifest
1612
- repo: https://github.com/psf/black
17-
rev: 22.3.0
13+
rev: 23.12.1
1814
hooks:
1915
- id: black
20-
language_version: python3.9

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
fluent_compiler 1.2 (unreleased)
5+
--------------------------------
6+
7+
* Dropped Python 3.7 support
8+
* Compiler performance improvements - thanks `@leamingrad <https://github.com/leamingrad>`_.
9+
410
fluent_compiler 1.1 (2024-04-02)
511
--------------------------------
612

CONTRIBUTING.rst

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,19 @@ development:
1818

1919
1. Fork ``fluent_compiler`` on GitHub.
2020
2. Clone and go to the forked repository.
21-
3. Create and activate a virtual environment for development (or your
22-
preferred mechanism for isolated Python environments).
23-
4. Install the package in development mode::
21+
3. Set up a venv for development. We use `uv <https://docs.astral.sh/uv/>`_ and
22+
recommend you do the same. With uv, the setup instructions are::
2423

25-
pip install -e .
24+
uv sync
2625

27-
5. Install test requirements::
26+
This will use your default Python version. If you want to use a different
27+
Python version, instead of the above do this e.g.::
2828

29-
pip install -r requirements-test.txt
29+
uv python install 3.10
30+
uv venv --python 3.10
31+
uv sync
3032

31-
6. Run the tests::
33+
4. Run the tests::
3234

3335
pytest
3436

@@ -39,15 +41,11 @@ including `ruff <https://github.com/astral-sh/ruff>`_ and `black
3941
<https://github.com/psf/black>`_. These are most easily added by using
4042
`pre-commit <https://pre-commit.com/>`_:
4143

42-
* Install pre-commit globally e.g. ``pipx install pre-commit`` if you
43-
already have `pipx <https://github.com/pypa/pipx>`_.
44-
4544
* Do ``pre-commit install`` in the repo.
4645

4746
Now all the linters will run when you commit changes.
4847

49-
To run tests on multiple Python versions locally you can also install
50-
and use ``tox``.
48+
To run tests on multiple Python versions locally you can also use ``tox``.
5149

5250

5351
Fixes and features

pyproject.toml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,75 @@
1+
[project]
2+
name = "fluent-compiler"
3+
description = "Blazing fast implementation of Fluent localization language."
4+
license = {text = "APL 2"}
5+
authors = [
6+
{ name = "Luke Plant", email = "[email protected]" }
7+
]
8+
requires-python = ">=3.8"
9+
keywords = [
10+
"fluent",
11+
"localization",
12+
"l10n",
13+
"compiler",
14+
"projectfluent",
15+
"ftl",
16+
]
17+
classifiers = [
18+
"Development Status :: 5 - Production/Stable",
19+
"Intended Audience :: Developers",
20+
"License :: OSI Approved :: Apache Software License",
21+
"Operating System :: OS Independent",
22+
"Programming Language :: Python :: 3 :: Only",
23+
"Programming Language :: Python :: 3.7",
24+
"Programming Language :: Python :: 3.8",
25+
"Programming Language :: Python :: 3.9",
26+
"Programming Language :: Python :: 3.10",
27+
"Programming Language :: Python :: 3.11",
28+
"Programming Language :: Python :: 3.12",
29+
"Programming Language :: Python :: Implementation :: CPython",
30+
"Programming Language :: Python :: Implementation :: PyPy",
31+
"Topic :: Software Development :: Compilers",
32+
"Topic :: Software Development :: Libraries :: Python Modules",
33+
"Topic :: Software Development :: Localization",
34+
]
35+
dynamic = ["version"]
36+
37+
dependencies = [
38+
"attrs>=19.3.0",
39+
"babel>=2.12.0",
40+
"fluent-syntax>=0.14",
41+
"pytz>=2025.2",
42+
"tox-uv>=1.13.1",
43+
"tox>=4.8.0",
44+
]
45+
46+
[project.urls]
47+
Homepage = "https://github.com/django-ftl/fluent-compiler"
48+
Documentation = "https://fluent-compiler.readthedocs.io/en/latest/"
49+
Repository = "https://github.com/django-ftl/fluent-compiler"
50+
Changelog = "https://fluent-compiler.readthedocs.io/en/latest/history.html"
51+
Tracker = "https://github.com/django-ftl/fluent-compiler/issues"
52+
53+
[project.readme]
54+
file = "README.rst"
55+
content-type = "text/x-rst"
56+
57+
[build-system]
58+
requires = ["setuptools>=61.2"]
59+
build-backend = "setuptools.build_meta"
60+
61+
[tool.setuptools]
62+
package-dir = {"" = "src"}
63+
include-package-data = false
64+
65+
[tool.setuptools.packages.find]
66+
where = ["src"]
67+
namespaces = false
68+
69+
[tool.setuptools.dynamic]
70+
version = {attr = "fluent_compiler.__version__"}
71+
72+
173
[tool.black]
274
line-length = 120
375
# required-version = '22.3.0' # see https://github.com/psf/black/issues/2493
@@ -17,3 +89,14 @@ extend-select = [
1789

1890
[tool.ruff.lint.isort]
1991
known-first-party = ["fluent_compiler"]
92+
93+
[dependency-groups]
94+
dev = [
95+
"ast-decompiler>=0.4",
96+
"beautifulsoup4>=4.7.1",
97+
"hypothesis>=4.9.0",
98+
"markdown>=3.0.1",
99+
"markupsafe>=1.1.1",
100+
"pre-commit>=3.5.0",
101+
"pytest>=7.4.4",
102+
]

release.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
set -x
44

5-
check-manifest || exit 1
65
pytest || exit 1
76

87

@@ -11,12 +10,11 @@ rm -rf build dist
1110
git ls-tree --full-tree --name-only -r HEAD | xargs chmod ugo+r
1211
find src docs tests -type d | xargs chmod ugo+rx
1312

14-
./setup.py sdist || exit 1
13+
uv build --sdist --wheel || exit 1
14+
uv publish || exit 1
1515

16-
python3 setup.py bdist_wheel --python-tag=py3 || exit 1
16+
VERSION=$(uv pip show fluent-compiler | grep 'Version: ' | cut -f 2 -d ' ' | tr -d '\n') || exit 1
1717

18-
VERSION=$(./setup.py --version) || exit 1
19-
twine upload dist/fluent_compiler-$VERSION.tar.gz dist/fluent_compiler-$VERSION-py3-none-any.whl || exit 1
20-
git tag v$VERSION || exit 1
18+
git tag $VERSION || exit 1
2119
git push || exit 1
2220
git push --tags || exit 1

setup.cfg

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/fluent_compiler/types.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ class NumberFormatOptions:
8888

8989

9090
class FluentNumber(FluentType):
91-
9291
default_number_format_options = NumberFormatOptions()
9392

9493
def __new__(cls, value, **kwargs):

tests/format/test_escapers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def join(self, parts):
4040
# that, unlike HtmlEscaper above, the output type is not a subclass of
4141
# str, in order to test the implementation handles this properly.
4242

43+
4344
# We also test whether the implementation can handle subclasses
4445
class Markdown:
4546
def __init__(self, text):

tests/test_types.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def currency(amount, *args, **kwargs):
1414

1515

1616
class TestFluentNumber(unittest.TestCase):
17-
1817
locale = Locale.parse("en_US")
1918

2019
def setUp(self):
@@ -189,7 +188,6 @@ def test_copy_attributes(self):
189188

190189

191190
class TestFluentDate(unittest.TestCase):
192-
193191
locale = Locale.parse("en_US")
194192

195193
def setUp(self):
@@ -242,14 +240,14 @@ def test_timeStyle_datetime(self):
242240
fd = fluent_date(self.a_datetime, timeStyle="short")
243241
en_US = Locale.parse("en_US")
244242
en_GB = Locale.parse("en_GB")
245-
self.assertEqual(fd.format(en_US), "2:15 PM")
243+
self.assertEqual(fd.format(en_US), "2:15\u202fPM")
246244
self.assertEqual(fd.format(en_GB), "14:15")
247245

248246
def test_dateStyle_and_timeStyle_datetime(self):
249247
fd = fluent_date(self.a_datetime, timeStyle="short", dateStyle="short")
250248
en_US = Locale.parse("en_US")
251249
en_GB = Locale.parse("en_GB")
252-
self.assertEqual(fd.format(en_US), "2/1/18, 2:15 PM")
250+
self.assertEqual(fd.format(en_US), "2/1/18, 2:15\u202fPM")
253251
self.assertEqual(fd.format(en_GB), "01/02/2018, 14:15")
254252

255253
def test_validate_dateStyle(self):
@@ -269,7 +267,7 @@ def test_timeZone(self):
269267
fd1 = fluent_date(dt1, dateStyle="short", timeStyle="short")
270268
self.assertEqual(fd1.format(en_GB), "02/07/2018, 00:30")
271269
fd1b = fluent_date(dt1, dateStyle="full", timeStyle="full")
272-
self.assertEqual(fd1b.format(en_GB), "Monday, 2 July 2018 at 00:30:00 British Summer Time")
270+
self.assertEqual(fd1b.format(en_GB), "Monday, 2 July 2018, 00:30:00 British Summer Time")
273271
fd1c = fluent_date(dt1, dateStyle="short")
274272
self.assertEqual(fd1c.format(en_GB), "02/07/2018")
275273
fd1d = fluent_date(dt1, timeStyle="short")
@@ -280,7 +278,7 @@ def test_timeZone(self):
280278
fd2 = fluent_date(dt2, dateStyle="short", timeStyle="short", timeZone="Europe/London")
281279
self.assertEqual(fd2.format(en_GB), "02/07/2018, 00:30")
282280
fd2b = fluent_date(dt2, dateStyle="full", timeStyle="full", timeZone="Europe/London")
283-
self.assertEqual(fd2b.format(en_GB), "Monday, 2 July 2018 at 00:30:00 British Summer Time")
281+
self.assertEqual(fd2b.format(en_GB), "Monday, 2 July 2018, 00:30:00 British Summer Time")
284282
fd2c = fluent_date(dt2, dateStyle="short", timeZone="Europe/London")
285283
self.assertEqual(fd2c.format(en_GB), "02/07/2018")
286284
fd2d = fluent_date(dt1, timeStyle="short", timeZone="Europe/London")

0 commit comments

Comments
 (0)