Skip to content

Switch to uv. #34

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

Merged
merged 1 commit into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 10 additions & 31 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,56 +16,35 @@ jobs:
strategy:
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "pypy3.7"
- "pypy3.8"
- "pypy3.9"
- "pypy3.10"
os: [ubuntu-latest]


steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- name: Set up Python ${{ matrix.python-version }} with uv
uses: drivendataorg/setup-python[email protected]
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python }}-${{ hashFiles('requirements*.txt') }}
cache: 'packages'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install -r requirements.txt
pip install -r requirements-test.txt
uv sync
- name: Test with pytest
run: |
pytest
uv run pytest


linters:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- uses: actions/cache@v2
with:
path: |
~/.cache/pip
~/.cache/pre-commit
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements*.txt') }}
- name: Install dependencies
run: |
pip install pre-commit
- name: pre-commit linters
run: pre-commit run --all-files --show-diff-on-failure --color=always
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]
9 changes: 2 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.3.4
rev: v0.4.5
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
- repo: 'https://github.com/mgedmin/check-manifest'
rev: '0.46'
hooks:
- id: check-manifest
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.12.1
hooks:
- id: black
language_version: python3.9
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

fluent_compiler 1.2 (unreleased)
--------------------------------

* Dropped Python 3.7 support
* Compiler performance improvements - thanks `@leamingrad <https://github.com/leamingrad>`_.

fluent_compiler 1.1 (2024-04-02)
--------------------------------

Expand Down
22 changes: 10 additions & 12 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ development:

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

pip install -e .
uv sync

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

pip install -r requirements-test.txt
uv python install 3.10
uv venv --python 3.10
uv sync

6. Run the tests::
4. Run the tests::

pytest

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

* Install pre-commit globally e.g. ``pipx install pre-commit`` if you
already have `pipx <https://github.com/pypa/pipx>`_.

* Do ``pre-commit install`` in the repo.

Now all the linters will run when you commit changes.

To run tests on multiple Python versions locally you can also install
and use ``tox``.
To run tests on multiple Python versions locally you can also use ``tox``.


Fixes and features
Expand Down
83 changes: 83 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,75 @@
[project]
name = "fluent-compiler"
description = "Blazing fast implementation of Fluent localization language."
license = {text = "APL 2"}
authors = [
{ name = "Luke Plant", email = "[email protected]" }
]
requires-python = ">=3.8"
keywords = [
"fluent",
"localization",
"l10n",
"compiler",
"projectfluent",
"ftl",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Compilers",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Localization",
]
dynamic = ["version"]

dependencies = [
"attrs>=19.3.0",
"babel>=2.12.0",
"fluent-syntax>=0.14",
"pytz>=2025.2",
"tox-uv>=1.13.1",
"tox>=4.8.0",
]

[project.urls]
Homepage = "https://github.com/django-ftl/fluent-compiler"
Documentation = "https://fluent-compiler.readthedocs.io/en/latest/"
Repository = "https://github.com/django-ftl/fluent-compiler"
Changelog = "https://fluent-compiler.readthedocs.io/en/latest/history.html"
Tracker = "https://github.com/django-ftl/fluent-compiler/issues"

[project.readme]
file = "README.rst"
content-type = "text/x-rst"

[build-system]
requires = ["setuptools>=61.2"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
package-dir = {"" = "src"}
include-package-data = false

[tool.setuptools.packages.find]
where = ["src"]
namespaces = false

[tool.setuptools.dynamic]
version = {attr = "fluent_compiler.__version__"}


[tool.black]
line-length = 120
# required-version = '22.3.0' # see https://github.com/psf/black/issues/2493
Expand All @@ -17,3 +89,14 @@ extend-select = [

[tool.ruff.lint.isort]
known-first-party = ["fluent_compiler"]

[dependency-groups]
dev = [
"ast-decompiler>=0.4",
"beautifulsoup4>=4.7.1",
"hypothesis>=4.9.0",
"markdown>=3.0.1",
"markupsafe>=1.1.1",
"pre-commit>=3.5.0",
"pytest>=7.4.4",
]
10 changes: 4 additions & 6 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

set -x

check-manifest || exit 1
pytest || exit 1


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

./setup.py sdist || exit 1
uv build --sdist --wheel || exit 1
uv publish || exit 1

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

VERSION=$(./setup.py --version) || exit 1
twine upload dist/fluent_compiler-$VERSION.tar.gz dist/fluent_compiler-$VERSION-py3-none-any.whl || exit 1
git tag v$VERSION || exit 1
git tag $VERSION || exit 1
git push || exit 1
git push --tags || exit 1
53 changes: 0 additions & 53 deletions setup.cfg

This file was deleted.

1 change: 0 additions & 1 deletion src/fluent_compiler/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class NumberFormatOptions:


class FluentNumber(FluentType):

default_number_format_options = NumberFormatOptions()

def __new__(cls, value, **kwargs):
Expand Down
1 change: 1 addition & 0 deletions tests/format/test_escapers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def join(self, parts):
# that, unlike HtmlEscaper above, the output type is not a subclass of
# str, in order to test the implementation handles this properly.


# We also test whether the implementation can handle subclasses
class Markdown:
def __init__(self, text):
Expand Down
10 changes: 4 additions & 6 deletions tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def currency(amount, *args, **kwargs):


class TestFluentNumber(unittest.TestCase):

locale = Locale.parse("en_US")

def setUp(self):
Expand Down Expand Up @@ -189,7 +188,6 @@ def test_copy_attributes(self):


class TestFluentDate(unittest.TestCase):

locale = Locale.parse("en_US")

def setUp(self):
Expand Down Expand Up @@ -242,14 +240,14 @@ def test_timeStyle_datetime(self):
fd = fluent_date(self.a_datetime, timeStyle="short")
en_US = Locale.parse("en_US")
en_GB = Locale.parse("en_GB")
self.assertEqual(fd.format(en_US), "2:15 PM")
self.assertEqual(fd.format(en_US), "2:15\u202fPM")
self.assertEqual(fd.format(en_GB), "14:15")

def test_dateStyle_and_timeStyle_datetime(self):
fd = fluent_date(self.a_datetime, timeStyle="short", dateStyle="short")
en_US = Locale.parse("en_US")
en_GB = Locale.parse("en_GB")
self.assertEqual(fd.format(en_US), "2/1/18, 2:15 PM")
self.assertEqual(fd.format(en_US), "2/1/18, 2:15\u202fPM")
self.assertEqual(fd.format(en_GB), "01/02/2018, 14:15")

def test_validate_dateStyle(self):
Expand All @@ -269,7 +267,7 @@ def test_timeZone(self):
fd1 = fluent_date(dt1, dateStyle="short", timeStyle="short")
self.assertEqual(fd1.format(en_GB), "02/07/2018, 00:30")
fd1b = fluent_date(dt1, dateStyle="full", timeStyle="full")
self.assertEqual(fd1b.format(en_GB), "Monday, 2 July 2018 at 00:30:00 British Summer Time")
self.assertEqual(fd1b.format(en_GB), "Monday, 2 July 2018, 00:30:00 British Summer Time")
fd1c = fluent_date(dt1, dateStyle="short")
self.assertEqual(fd1c.format(en_GB), "02/07/2018")
fd1d = fluent_date(dt1, timeStyle="short")
Expand All @@ -280,7 +278,7 @@ def test_timeZone(self):
fd2 = fluent_date(dt2, dateStyle="short", timeStyle="short", timeZone="Europe/London")
self.assertEqual(fd2.format(en_GB), "02/07/2018, 00:30")
fd2b = fluent_date(dt2, dateStyle="full", timeStyle="full", timeZone="Europe/London")
self.assertEqual(fd2b.format(en_GB), "Monday, 2 July 2018 at 00:30:00 British Summer Time")
self.assertEqual(fd2b.format(en_GB), "Monday, 2 July 2018, 00:30:00 British Summer Time")
fd2c = fluent_date(dt2, dateStyle="short", timeZone="Europe/London")
self.assertEqual(fd2c.format(en_GB), "02/07/2018")
fd2d = fluent_date(dt1, timeStyle="short", timeZone="Europe/London")
Expand Down
Loading
Loading