diff --git a/.github/workflows/test-libmaxminddb.yml b/.github/workflows/test-libmaxminddb.yml index eefa7f2..7c3ae89 100644 --- a/.github/workflows/test-libmaxminddb.yml +++ b/.github/workflows/test-libmaxminddb.yml @@ -13,43 +13,41 @@ jobs: strategy: matrix: + env: [3.9, "3.10", 3.11, 3.12, 3.13] # We don't test on Windows currently due to issues # build libmaxminddb there. - platform: [macos-latest, ubuntu-latest] - python-version: [3.9, "3.10", 3.11, 3.12, 3.13] + os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest] - name: Python ${{ matrix.python-version }} on ${{ matrix.platform }} - runs-on: ${{ matrix.platform }} + name: Python ${{ matrix.env }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} env: MAXMINDDB_REQUIRE_EXTENSION: 1 MAXMINDDB_USE_SYSTEM_LIBMAXMINDDB: 1 MM_FORCE_EXT_TESTS: 1 steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@v4 with: submodules: true persist-credentials: false - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v3 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools tox tox-gh-actions uv wheel + - name: Install tox + run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv --with tox-gh + - name: Install Python + if: matrix.env != '3.13' + run: uv python install --python-preference only-managed ${{ matrix.env }} - name: Install libmaxminddb run: sudo apt install libmaxminddb-dev - if: matrix.platform == 'ubuntu-latest' + if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm' - name: Install libmaxminddb run: brew install libmaxminddb - if: matrix.platform == 'macos-latest' + if: matrix.os == 'macos-latest' - name: "Work around macos arm64 homebrew directory changes" if: runner.os == 'macOS' && runner.arch == 'ARM64' @@ -62,5 +60,12 @@ jobs: env: CFLAGS: "${{ env.CFLAGS }} -Werror -Wall -Wextra" - - name: Test with tox (system libmaxminddb) - run: tox + - name: Setup test suite + run: tox run -vv --notest --skip-missing-interpreters false + env: + TOX_GH_MAJOR_MINOR: ${{ matrix.env }} + + - name: Run test suite + run: tox run --skip-pkg-install + env: + TOX_GH_MAJOR_MINOR: ${{ matrix.env }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4606f48..9dd77be 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,35 +9,33 @@ on: permissions: {} jobs: - build: - + test: + name: test with ${{ matrix.env }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: - platform: [macos-latest, ubuntu-24.04-arm, ubuntu-latest, windows-latest] - python-version: [3.9, "3.10", 3.11, 3.12, 3.13] - - name: Python ${{ matrix.python-version }} on ${{ matrix.platform }} - runs-on: ${{ matrix.platform }} - + env: [3.9, "3.10", 3.11, 3.12, 3.13] + os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest] steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@v4 with: submodules: true persist-credentials: false - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install tox tox-gh-actions - - - name: Test with tox (vendored libmaxminddb) - run: tox + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v3 + - name: Install tox + run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv --with tox-gh + - name: Install Python + if: 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 + env: + TOX_GH_MAJOR_MINOR: ${{ matrix.env }} + - name: Run test suite + run: tox run --skip-pkg-install env: MAXMINDDB_REQUIRE_EXTENSION: 1 MM_FORCE_EXT_TESTS: 1 + TOX_GH_MAJOR_MINOR: ${{ matrix.env }} diff --git a/pyproject.toml b/pyproject.toml index 1c9f3e6..020de9c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,7 @@ dev = [ ] lint = [ "black>=25.1.0", + "flake8>=7.2.0", "mypy>=1.15.0", "pylint>=3.3.6", "ruff>=0.11.6", @@ -49,8 +50,12 @@ requires = [ ] build-backend = "setuptools.build_meta" +[tool.setuptools] +include-package-data = true +packages = ["maxminddb"] + [tool.setuptools.package-data] -maxminddb = ["py.typed"] +maxminddb = ["extension.pyi", "py.typed"] [tool.black] # src is showing up in our GitHub linting builds. It seems to @@ -82,3 +87,43 @@ ignore = [ [tool.ruff.lint.per-file-ignores] "tests/*" = ["ANN201", "D"] + +[tool.tox] +env_list = [ + "3.9", + "3.10", + "3.11", + "3.12", + "3.13", + "lint", +] +skip_missing_interpreters = false + +[tool.tox.env_run_base] +dependency_groups = [ + "dev", +] +commands = [ + ["pytest", "tests"], +] + +[tool.tox.env.lint] +description = "Code linting" +python = "3.13" +dependency_groups = [ + "dev", + "lint", +] +commands = [ + ["black", "--check", "--diff", "."], + ["flake8", "maxminddb"], + ["mypy", "maxminddb", "tests"], + ["pylint", "maxminddb"], +] + +[tool.tox.gh.python] +"3.13" = ["3.13", "lint"] +"3.12" = ["3.12"] +"3.11" = ["3.11"] +"3.10" = ["3.10"] +"3.9" = ["3.9"] diff --git a/setup.cfg b/setup.cfg index 75a816e..af494c4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,46 +2,3 @@ extend-ignore = E203 # black uses 88 : ¯\_(ツ)_/¯ max-line-length = 88 - -[options] -package_dir = - maxminddb = maxminddb -packages = maxminddb -install_requires = -include_package_data = True -python_requires = >=3.9 - -[options.package_data] -maxminddb = extension.pyi; py.typed - -[tox:tox] -envlist = {py39,py310,py311,py312,py313}-test,py313-{black,lint,flake8,mypy} - -[gh-actions] -python = - 3.9: py39 - 3.10: py310 - 3.11: py311 - 3.12: py312 - 3.13: py313,black,lint,flake8,mypy - -[testenv:{py39,py310,py311,py312,py313}-test] -deps = pytest -commands = pytest tests -passenv = * - -[testenv:py313-black] -deps = black -commands = black --check --diff . - -[testenv:py313-lint] -deps = pylint -commands = pylint maxminddb - -[testenv:py313-flake8] -deps = flake8 -commands = flake8 maxminddb - -[testenv:py313-mypy] -deps = mypy -commands = mypy maxminddb tests