Skip to content
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

Add initial UV #601

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
59 changes: 41 additions & 18 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,48 @@
name: Publish Python 🐍 distributions 📦 to PyPI
name: Release to PyPI
on:
push:
tags:
- "*"
tags: ["*"]

env:
dists-artifact-name: python-package-distributions

jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI
runs-on: ubuntu-20.04
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
- uses: actions/checkout@v4
with:
python-version: 3.9
- name: Install dependencies
run: pip install -r requirements/build-requirements.txt
fetch-depth: 0
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build package
run: hatch build
- name: Publish distribution 📦 to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/[email protected]
run: uv build --python 3.13 --python-preference only-managed --sdist --wheel . --out-dir dist
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: ${{ env.dists-artifact-name }}
path: dist/*

release:
needs:
- build
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/project/tox-uv/${{ github.ref_name }}
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: ${{ env.dists-artifact-name }}
path: dist/
- name: Publish to PyPI
uses: pypa/[email protected]
with:
password: ${{ secrets.pypi_password }}
password: ${{ secrets.pypi_password }}
91 changes: 64 additions & 27 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,80 @@
name: Test iso-codes, build and publish to TestPypi
on: [pull_request]
jobs:
pytest:
test:
name: Run tests
runs-on: ubuntu-20.04
strategy:
matrix:
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
env:
- "3.13"
- "3.12"
- "3.11"
- "3.10"
- "3.9"
- type
- dev
- pkg_meta
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- uses: actions/checkout@v4
with:
python-version: ${{ matrix.python }}
- name: Install test dependencies
run: pip install -r requirements/test-requirements.txt
- name: Run Tox
run: tox -e py
build-n-publish-testpypi:
name: Build and publish Python 🐍 distributions 📦 to TestPyPI
runs-on: ubuntu-20.04
fetch-depth: 0
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Install tox
run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv
- name: Install Python
if: startsWith(matrix.env, '3.') && matrix.env != '3.13'
run: uv python install --python-preference only-managed ${{ matrix.env }}
- name: Setup test suite
run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.env }}
- name: Run test suite
run: tox run --skip-pkg-install -e ${{ matrix.env }}
env:
PYTEST_ADDOPTS: "-vv --durations=20"
DIFF_AGAINST: HEAD

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build package
run: uv build --python 3.13 --python-preference only-managed --sdist --wheel . --out-dir dist
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: ${{ env.dists-artifact-name }}
path: dist/*

release:
needs:
- build
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/project/tox-uv/${{ github.ref_name }}
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
- name: Download all the dists
uses: actions/download-artifact@v4
with:
python-version: 3.9
- name: Install build dependencies
run: pip install -r requirements/build-requirements.txt
- name: Build package
run: hatch build
- name: Publish distribution 📦 to Test PyPI
uses: pypa/[email protected]
name: ${{ env.dists-artifact-name }}
path: dist/
- name: Publish to Test PyPI
uses: pypa/[email protected]
with:
password: ${{ secrets.test_pypi_password }}
repository-url: https://test.pypi.org/legacy/
skip-existing: true
skip-existing: true
63 changes: 39 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_language_version:
python: python3.10
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-toml
- id: check-yaml
args:
- --unsafe
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0
hooks:
- id: ruff
args:
- --fix
- id: ruff-format
ci:
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.4
hooks:
- id: check-github-workflows
args: ["--verbose"]
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies: ["tomli>=2.0.2"]
- repo: https://github.com/tox-dev/tox-ini-fmt
rev: "1.4.1"
hooks:
- id: tox-ini-fmt
args: ["-p", "fix"]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "v2.5.0"
hooks:
- id: pyproject-fmt
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.7.4"
hooks:
- id: ruff-format
- id: ruff
args: ["--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"]
- repo: https://github.com/rbubley/mirrors-prettier
rev: "v3.3.3"
hooks:
- id: prettier
args: ["--print-width=120", "--prose-wrap=always"]
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
33 changes: 20 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,36 @@ keywords = ["iso"]
classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"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 :: 3.13",
]
requires-python = ">=3.9"
dependencies = []

[project.optional-dependencies]

dev = ["pre-commit == 3.7.1", "ruff == 0.6.3", "mypy == 1.10.1"]

doc = ["mkdocs == 1.6.0", "mkdocs-material == 9.5.30", "mkdocstrings == 0.25.2"]

dev = [
"pre-commit==3.7.1",
"ruff==0.6.3",
"mypy==1.10.1",
]
doc = [
"mkdocs==1.6.0",
"mkdocs-material==9.5.30",
"mkdocstrings==0.25.2",
]
test = [
"pytest == 8.2.2",
"tox == 4.18.0",
"pyinstaller[hook_testing] == 6.10.0",
"psutil == 6.0.0",
"pytest==8.2.2",
"tox==4.18.0",
"pyinstaller[hook-testing]==6.10.0",
"psutil==6.0.0",
]
build = [
"hatch==1.12.0",
]

build = ["hatch == 1.12.0"]

[project.entry-points.pyinstaller40]
hook-dirs = "isocodes.__pyinstaller:get_hook_dirs"
tests = "isocodes.__pyinstaller:get_hook_dirs"
tests = "isocodes.__pyinstaller:get_hook_dirs"
100 changes: 97 additions & 3 deletions tests/test_general.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,99 @@
from isocodes import languages
import pytest
from isocodes import (
Countries,
Languages,
Currencies,
SubdivisionsCountries,
FormerCountries,
ExtendedLanguages,
LanguageFamilies,
ScriptNames,
)


def test_languages():
assert languages.get(name="Spanish")
@pytest.fixture
def countries():
return Countries("3166-1")


@pytest.fixture
def languages():
return Languages("639-2")


@pytest.fixture
def currencies():
return Currencies("4217")


@pytest.fixture
def subdivisions_countries():
return SubdivisionsCountries("3166-2")


@pytest.fixture
def former_countries():
return FormerCountries("3166-3")


@pytest.fixture
def extended_languages():
return ExtendedLanguages("639-3")


@pytest.fixture
def language_families():
return LanguageFamilies("639-5")


@pytest.fixture
def script_names():
return ScriptNames("15924")


def test_countries_by_alpha_2(countries):
result = countries.by_alpha_2
assert isinstance(result, list)
assert all(isinstance(item, tuple) for item in result)


def test_languages_by_alpha_3(languages):
result = languages.by_alpha_3
assert isinstance(result, list)
assert all(isinstance(item, tuple) for item in result)


def test_currencies_by_alpha_3(currencies):
result = currencies.by_alpha_3
assert isinstance(result, list)
assert all(isinstance(item, tuple) for item in result)


def test_subdivisions_countries_by_code(subdivisions_countries):
result = subdivisions_countries.by_code
assert isinstance(result, list)
assert all(isinstance(item, tuple) for item in result)


def test_former_countries_by_alpha_2(former_countries):
result = former_countries.by_alpha_2
assert isinstance(result, list)
assert all(isinstance(item, tuple) for item in result)


def test_extended_languages_by_alpha_3(extended_languages):
result = extended_languages.by_alpha_3
assert isinstance(result, list)
assert all(isinstance(item, tuple) for item in result)


def test_language_families_by_alpha_3(language_families):
result = language_families.by_alpha_3
assert isinstance(result, list)
assert all(isinstance(item, tuple) for item in result)


def test_script_names_by_alpha_4(script_names):
result = script_names.by_alpha_4
assert isinstance(result, list)
assert all(isinstance(item, tuple) for item in result)
Loading
Loading