diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1a48ee0f..9b88b4e9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -31,9 +31,9 @@ jobs: python-version: ["3.11", "3.12"] include: - { os: ubuntu-latest, python-version: "3.10" } - # - os: ubuntu-latest - # python-version: "3.13" - # python-install-version: "3.13-dev" + - os: ubuntu-latest + python-version: "3.13" + python-install-version: "3.13-dev" runs-on: ${{ matrix.os }} steps: - name: Clone the repo @@ -75,9 +75,9 @@ jobs: python-version: ["3.11", "3.12"] include: - { os: ubuntu-latest, python-version: "3.10" } - # - os: ubuntu-latest - # python-version: "3.13" - # python-install-version: "3.13-dev" + - os: ubuntu-latest + python-version: "3.13" + python-install-version: "3.13-dev" runs-on: ${{ matrix.os }} steps: - name: Clone the repo diff --git a/noxfile.py b/noxfile.py index 96f994c6..34c0ed49 100644 --- a/noxfile.py +++ b/noxfile.py @@ -2,6 +2,7 @@ import json import os +import tempfile from importlib.metadata import Distribution from pathlib import Path @@ -11,7 +12,7 @@ nox.options.error_on_external_run = True -def install_coverage_hook(session: nox.Session): +def _install_coverage_hook(session: nox.Session): session.run( 'python', '-c', @@ -27,6 +28,28 @@ def install_coverage_hook(session: nox.Session): ) +def _session_install_for_python313(session: nox.Session, install_args: list[str]): + with tempfile.TemporaryDirectory() as temp_dir: + constraints_txt = Path(temp_dir, 'python313-constraints.txt') + constraints_txt.write_text("""\ +sqlalchemy @ git+https://github.com/sqlalchemy/sqlalchemy ; python_version >= "3.13" +truststore @ git+https://github.com/sethmlarson/truststore@support-for-python-313 ; python_version >= "3.13" +""") + + session.install( + '-c', + os.fspath(constraints_txt), + *install_args, + env={f'{p}_NO_EXTENSIONS': '1' for p in ['AIOHTTP', 'MULTIDICT', 'YARL']}, + ) + + +@nox.session(reuse_venv=True) +def dev_env(session: nox.Session): + _session_install_for_python313(session, ['-e', '.[gui, test, types]']) + print(session.virtualenv.bin, end='') + + @nox.session(name='format') def format_code(session: nox.Session): "Format source code." @@ -70,21 +93,25 @@ def test(session: nox.Session, minimum_versions: bool): wheel_metadata_json, )['wheel-path'] - install_requires = [ + install_args = [ f'instawow[gui, test] @ {package_path}', 'instawow_test_plugin @ tests/plugin', ] - if minimum_versions: (package_metadata,) = Distribution.discover(name='instawow', path=[package_path]) - - session.install( - '--resolution', 'lowest-direct', *install_requires, *package_metadata.requires or () + _session_install_for_python313( + session, + [ + '--resolution', + 'lowest-direct', + *install_args, + *(package_metadata.requires or ()), + ], ) else: - session.install(*install_requires) + _session_install_for_python313(session, install_args) - install_coverage_hook(session) + _install_coverage_hook(session) session.run( *'coverage run -m pytest -n auto'.split(), @@ -117,7 +144,11 @@ def type_check(session: nox.Session): wheel_metadata_json, )['wheel-path'] - session.install(f'instawow[gui, types] @ {package_path}') + _session_install_for_python313( + session, + [f'instawow[gui, types] @ {package_path}'], + ) + session.run('npx', 'pyright', external=True) @@ -165,7 +196,6 @@ def publish_dists(session: nox.Session): def freeze_cli(session: nox.Session): import argparse import shutil - import tempfile PYAPP_VERSION = 'v0.15.1' diff --git a/shell.nix b/shell.nix index e9bc19ca..dd11d136 100644 --- a/shell.nix +++ b/shell.nix @@ -1,33 +1,24 @@ { pkgs ? import { } }: let - python = pkgs.python312; - venvDir = toString ./venvs + ("/" + python.pythonVersion); + python = pkgs.python313.override { enableGIL = false; enableOptimizations = true; }; in pkgs.mkShell { buildInputs = [ - pkgs.nixpkgs-fmt - pkgs.nodejs_20 pkgs.nil + pkgs.nixpkgs-fmt + pkgs.nodejs_21 + pkgs.python312.pkgs.nox pkgs.uv python - python.pkgs.venvShellHook ]; SOURCE_DATE_EPOCH = "315532800"; # The year 1980 PYTHONBREAKPOINT = "IPython.terminal.debugger.set_trace"; shellHook = '' - if [ -d "${venvDir}" ]; then - echo "Skipping venv creation, '${venvDir}' already exists" - else - echo "Creating new venv environment in path: '${venvDir}'" - # Note that the module venv was only introduced in python 3, so for 2.7 - # this needs to be replaced with a call to virtualenv - uv venv "${venvDir}" - fi - - source "${venvDir}/bin/activate" + set -ex - AIOHTTP_NO_EXTENSIONS=1 MULTIDICT_NO_EXTENSIONS=1 CC=clang++ uv pip install nox -e ".[gui, test, types]" + VENV_BIN_DIR=$(nox -vv -s dev_env --force-python ${python.pythonVersion}) + source "$VENV_BIN_DIR/activate" ''; }