Repository navigation
Warn when a function diverges without an explicit exit #607
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "CI: Shape stubs" | |
| on: | |
| pull_request: | |
| workflow_dispatch: | |
| workflow_call: | |
| permissions: | |
| contents: read | |
| env: | |
| PYTHON_VERSION: "3.12" | |
| jobs: | |
| build-shape-stubs: | |
| name: Build shape stubs | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Get package version | |
| run: | | |
| set -euo pipefail | |
| RAW_VERSION=$(sed -n -e 's/^VERSION = "\(.*\)"/\1/p' version.bzl) | |
| PACKAGE_VERSION=$(python3 scripts/version_helpers.py to-pypi "$RAW_VERSION") | |
| echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> "$GITHUB_ENV" | |
| - name: Build shape stubs packages | |
| run: | | |
| set -euo pipefail | |
| SHAPE_EXT_BUILD_DIR="$RUNNER_TEMP/pyrefly-shape-extensions-build" | |
| TORCH_STUBS_BUILD_DIR="$RUNNER_TEMP/pyrefly-torch-stubs-build" | |
| NUMPY_STUBS_BUILD_DIR="$RUNNER_TEMP/pyrefly-numpy-stubs-build" | |
| JAX_STUBS_BUILD_DIR="$RUNNER_TEMP/jax-pyrefly-stubs-build" | |
| EINOPS_STUBS_BUILD_DIR="$RUNNER_TEMP/pyrefly-einops-stubs-build" | |
| rm -rf "$SHAPE_EXT_BUILD_DIR" "$TORCH_STUBS_BUILD_DIR" "$NUMPY_STUBS_BUILD_DIR" "$JAX_STUBS_BUILD_DIR" "$EINOPS_STUBS_BUILD_DIR" shape-stubs-dist | |
| cp -R tensor-shapes/pyrefly-shape-extensions "$SHAPE_EXT_BUILD_DIR" | |
| cp -R tensor-shapes/pyrefly-torch-stubs "$TORCH_STUBS_BUILD_DIR" | |
| cp -R tensor-shapes/pyrefly-numpy-stubs "$NUMPY_STUBS_BUILD_DIR" | |
| cp -R tensor-shapes/jax-pyrefly-stubs "$JAX_STUBS_BUILD_DIR" | |
| cp -R tensor-shapes/pyrefly-einops-stubs "$EINOPS_STUBS_BUILD_DIR" | |
| PACKAGE_VERSION="$PACKAGE_VERSION" SHAPE_EXT_BUILD_DIR="$SHAPE_EXT_BUILD_DIR" TORCH_STUBS_BUILD_DIR="$TORCH_STUBS_BUILD_DIR" NUMPY_STUBS_BUILD_DIR="$NUMPY_STUBS_BUILD_DIR" JAX_STUBS_BUILD_DIR="$JAX_STUBS_BUILD_DIR" EINOPS_STUBS_BUILD_DIR="$EINOPS_STUBS_BUILD_DIR" python3 - <<'PY' | |
| from pathlib import Path | |
| import os | |
| package_version = os.environ["PACKAGE_VERSION"] | |
| def replace_once(text: str, old: str, new: str, path: Path) -> str: | |
| if text.count(old) != 1: | |
| raise SystemExit(f"Expected exactly one {old!r} in {path}") | |
| return text.replace(old, new) | |
| def stamp( | |
| build_dir_env: str, dependencies: tuple[str, ...] = () | |
| ) -> None: | |
| pyproject = Path(os.environ[build_dir_env]) / "pyproject.toml" | |
| text = pyproject.read_text() | |
| text = replace_once( | |
| text, | |
| 'version = "0.0.0"', | |
| f'version = "{package_version}"', | |
| pyproject, | |
| ) | |
| for dependency in dependencies: | |
| text = replace_once( | |
| text, | |
| f'"{dependency}==0.0.0"', | |
| f'"{dependency}=={package_version}"', | |
| pyproject, | |
| ) | |
| pyproject.write_text(text) | |
| stamp("SHAPE_EXT_BUILD_DIR") | |
| stamp("TORCH_STUBS_BUILD_DIR", ("pyrefly-shape-extensions",)) | |
| stamp("NUMPY_STUBS_BUILD_DIR", ("pyrefly-shape-extensions",)) | |
| stamp( | |
| "JAX_STUBS_BUILD_DIR", | |
| ("pyrefly-shape-extensions", "pyrefly-numpy-stubs"), | |
| ) | |
| stamp( | |
| "EINOPS_STUBS_BUILD_DIR", | |
| ("pyrefly-shape-extensions", "pyrefly-torch-stubs"), | |
| ) | |
| PY | |
| python -m pip install --upgrade build | |
| python -m build --outdir shape-stubs-dist "$SHAPE_EXT_BUILD_DIR" | |
| python -m build --outdir shape-stubs-dist "$TORCH_STUBS_BUILD_DIR" | |
| python -m build --outdir shape-stubs-dist "$NUMPY_STUBS_BUILD_DIR" | |
| python -m build --outdir shape-stubs-dist "$JAX_STUBS_BUILD_DIR" | |
| python -m build --outdir shape-stubs-dist "$EINOPS_STUBS_BUILD_DIR" | |
| - name: Smoke test shape extension wheel | |
| run: | | |
| set -euo pipefail | |
| python -m venv "$RUNNER_TEMP/shape-ext-wheel-venv" | |
| "$RUNNER_TEMP/shape-ext-wheel-venv/bin/pip" install shape-stubs-dist/pyrefly_shape_extensions-*.whl | |
| "$RUNNER_TEMP/shape-ext-wheel-venv/bin/python" -c "import shape_extensions" | |
| - name: Smoke test shape extension sdist | |
| run: | | |
| set -euo pipefail | |
| python -m venv "$RUNNER_TEMP/shape-ext-sdist-venv" | |
| "$RUNNER_TEMP/shape-ext-sdist-venv/bin/pip" install shape-stubs-dist/pyrefly_shape_extensions-*.tar.gz | |
| "$RUNNER_TEMP/shape-ext-sdist-venv/bin/python" -c "import shape_extensions" | |
| # Smoke tests exercise stub packaging; runtime metadata and resolution are checked separately. | |
| - name: Smoke test torch stubs wheel | |
| run: | | |
| set -euo pipefail | |
| python -m venv "$RUNNER_TEMP/torch-stubs-wheel-venv" | |
| "$RUNNER_TEMP/torch-stubs-wheel-venv/bin/pip" install --no-deps shape-stubs-dist/pyrefly_shape_extensions-*.whl shape-stubs-dist/pyrefly_torch_stubs-*.whl | |
| "$RUNNER_TEMP/torch-stubs-wheel-venv/bin/python" - <<'PY' | |
| from importlib.metadata import distribution | |
| distribution("pyrefly-torch-stubs") | |
| distribution("pyrefly-shape-extensions") | |
| PY | |
| - name: Smoke test torch stubs sdist | |
| run: | | |
| set -euo pipefail | |
| python -m venv "$RUNNER_TEMP/torch-stubs-sdist-venv" | |
| "$RUNNER_TEMP/torch-stubs-sdist-venv/bin/pip" install --no-deps shape-stubs-dist/pyrefly_shape_extensions-*.whl shape-stubs-dist/pyrefly_torch_stubs-*.tar.gz | |
| "$RUNNER_TEMP/torch-stubs-sdist-venv/bin/python" - <<'PY' | |
| from importlib.metadata import distribution | |
| distribution("pyrefly-torch-stubs") | |
| distribution("pyrefly-shape-extensions") | |
| PY | |
| - name: Smoke test numpy stubs wheel | |
| run: | | |
| set -euo pipefail | |
| python -m venv "$RUNNER_TEMP/numpy-stubs-wheel-venv" | |
| "$RUNNER_TEMP/numpy-stubs-wheel-venv/bin/pip" install --no-deps shape-stubs-dist/pyrefly_shape_extensions-*.whl shape-stubs-dist/pyrefly_numpy_stubs-*.whl | |
| "$RUNNER_TEMP/numpy-stubs-wheel-venv/bin/python" - <<'PY' | |
| from importlib.metadata import distribution | |
| distribution("pyrefly-numpy-stubs") | |
| distribution("pyrefly-shape-extensions") | |
| PY | |
| - name: Smoke test numpy stubs sdist | |
| run: | | |
| set -euo pipefail | |
| python -m venv "$RUNNER_TEMP/numpy-stubs-sdist-venv" | |
| "$RUNNER_TEMP/numpy-stubs-sdist-venv/bin/pip" install --no-deps shape-stubs-dist/pyrefly_shape_extensions-*.whl shape-stubs-dist/pyrefly_numpy_stubs-*.tar.gz | |
| "$RUNNER_TEMP/numpy-stubs-sdist-venv/bin/python" - <<'PY' | |
| from importlib.metadata import distribution | |
| distribution("pyrefly-numpy-stubs") | |
| distribution("pyrefly-shape-extensions") | |
| PY | |
| - name: Smoke test JAX stubs wheel | |
| run: | | |
| set -euo pipefail | |
| python -m venv "$RUNNER_TEMP/jax-stubs-wheel-venv" | |
| "$RUNNER_TEMP/jax-stubs-wheel-venv/bin/pip" install --no-deps shape-stubs-dist/pyrefly_shape_extensions-*.whl shape-stubs-dist/jax_pyrefly_stubs-*.whl | |
| "$RUNNER_TEMP/jax-stubs-wheel-venv/bin/python" - <<'PY' | |
| from importlib.metadata import distribution | |
| distribution("jax-pyrefly-stubs") | |
| distribution("pyrefly-shape-extensions") | |
| PY | |
| - name: Smoke test JAX stubs sdist | |
| run: | | |
| set -euo pipefail | |
| python -m venv "$RUNNER_TEMP/jax-stubs-sdist-venv" | |
| "$RUNNER_TEMP/jax-stubs-sdist-venv/bin/pip" install --no-deps shape-stubs-dist/pyrefly_shape_extensions-*.whl shape-stubs-dist/jax_pyrefly_stubs-*.tar.gz | |
| "$RUNNER_TEMP/jax-stubs-sdist-venv/bin/python" - <<'PY' | |
| from importlib.metadata import distribution | |
| distribution("jax-pyrefly-stubs") | |
| distribution("pyrefly-shape-extensions") | |
| PY | |
| - name: Smoke test einops stubs wheel | |
| run: | | |
| set -euo pipefail | |
| python -m venv "$RUNNER_TEMP/einops-stubs-wheel-venv" | |
| "$RUNNER_TEMP/einops-stubs-wheel-venv/bin/pip" install --no-deps shape-stubs-dist/pyrefly_shape_extensions-*.whl shape-stubs-dist/pyrefly_torch_stubs-*.whl shape-stubs-dist/pyrefly_einops_stubs-*.whl | |
| "$RUNNER_TEMP/einops-stubs-wheel-venv/bin/python" - <<'PY' | |
| from importlib.metadata import distribution | |
| distribution("pyrefly-einops-stubs") | |
| distribution("pyrefly-shape-extensions") | |
| PY | |
| - name: Smoke test einops stubs sdist | |
| run: | | |
| set -euo pipefail | |
| python -m venv "$RUNNER_TEMP/einops-stubs-sdist-venv" | |
| "$RUNNER_TEMP/einops-stubs-sdist-venv/bin/pip" install --no-deps shape-stubs-dist/pyrefly_shape_extensions-*.whl shape-stubs-dist/pyrefly_torch_stubs-*.whl shape-stubs-dist/pyrefly_einops_stubs-*.tar.gz | |
| "$RUNNER_TEMP/einops-stubs-sdist-venv/bin/python" - <<'PY' | |
| from importlib.metadata import distribution | |
| distribution("pyrefly-einops-stubs") | |
| distribution("pyrefly-shape-extensions") | |
| PY | |
| - name: Verify shape stubs artifacts | |
| run: | | |
| set -euo pipefail | |
| python3 - <<'PY' | |
| import email.parser | |
| from pathlib import Path | |
| import os | |
| import tarfile | |
| import zipfile | |
| dist = Path("shape-stubs-dist") | |
| shape_ext_wheels = list(dist.glob("pyrefly_shape_extensions-*.whl")) | |
| shape_ext_sdists = list(dist.glob("pyrefly_shape_extensions-*.tar.gz")) | |
| torch_stubs_wheels = list(dist.glob("pyrefly_torch_stubs-*.whl")) | |
| torch_stubs_sdists = list(dist.glob("pyrefly_torch_stubs-*.tar.gz")) | |
| numpy_stubs_wheels = list(dist.glob("pyrefly_numpy_stubs-*.whl")) | |
| numpy_stubs_sdists = list(dist.glob("pyrefly_numpy_stubs-*.tar.gz")) | |
| jax_stubs_wheels = list(dist.glob("jax_pyrefly_stubs-*.whl")) | |
| jax_stubs_sdists = list(dist.glob("jax_pyrefly_stubs-*.tar.gz")) | |
| einops_stubs_wheels = list(dist.glob("pyrefly_einops_stubs-*.whl")) | |
| einops_stubs_sdists = list(dist.glob("pyrefly_einops_stubs-*.tar.gz")) | |
| assert len(shape_ext_wheels) == 1, shape_ext_wheels | |
| assert len(shape_ext_sdists) == 1, shape_ext_sdists | |
| assert len(torch_stubs_wheels) == 1, torch_stubs_wheels | |
| assert len(torch_stubs_sdists) == 1, torch_stubs_sdists | |
| assert len(numpy_stubs_wheels) == 1, numpy_stubs_wheels | |
| assert len(numpy_stubs_sdists) == 1, numpy_stubs_sdists | |
| assert len(jax_stubs_wheels) == 1, jax_stubs_wheels | |
| assert len(jax_stubs_sdists) == 1, jax_stubs_sdists | |
| assert len(einops_stubs_wheels) == 1, einops_stubs_wheels | |
| assert len(einops_stubs_sdists) == 1, einops_stubs_sdists | |
| with zipfile.ZipFile(shape_ext_wheels[0]) as z: | |
| names = set(z.namelist()) | |
| assert "shape_extensions/__init__.py" in names | |
| assert "shape_extensions/dsl.py" in names | |
| assert "shape_extensions/py.typed" in names | |
| metadata_name = next( | |
| name | |
| for name in names | |
| if name.endswith(".dist-info/METADATA") | |
| ) | |
| metadata = z.read(metadata_name).decode() | |
| assert f"Version: {os.environ['PACKAGE_VERSION']}" in metadata | |
| with tarfile.open(shape_ext_sdists[0]) as t: | |
| names = set(t.getnames()) | |
| assert any(name.endswith("/shape_extensions/__init__.py") for name in names) | |
| assert any(name.endswith("/shape_extensions/dsl.py") for name in names) | |
| assert any(name.endswith("/shape_extensions/py.typed") for name in names) | |
| with zipfile.ZipFile(torch_stubs_wheels[0]) as z: | |
| names = set(z.namelist()) | |
| assert "torch-stubs/__init__.pyi" in names | |
| assert "torch-stubs/nn/__init__.pyi" in names | |
| assert "torch-stubs/py.typed" in names | |
| metadata_name = next( | |
| name | |
| for name in names | |
| if name.endswith(".dist-info/METADATA") | |
| ) | |
| metadata = z.read(metadata_name).decode() | |
| assert f"Version: {os.environ['PACKAGE_VERSION']}" in metadata | |
| assert ( | |
| f"Requires-Dist: pyrefly-shape-extensions=={os.environ['PACKAGE_VERSION']}" | |
| in metadata | |
| ) | |
| with tarfile.open(torch_stubs_sdists[0]) as t: | |
| names = set(t.getnames()) | |
| assert any(name.endswith("/torch-stubs/__init__.pyi") for name in names) | |
| assert any(name.endswith("/torch-stubs/nn/__init__.pyi") for name in names) | |
| assert any(name.endswith("/torch-stubs/py.typed") for name in names) | |
| with zipfile.ZipFile(numpy_stubs_wheels[0]) as z: | |
| names = set(z.namelist()) | |
| assert "numpy-stubs/__init__.pyi" in names | |
| assert "numpy-stubs/linalg/__init__.pyi" in names | |
| assert "numpy-stubs/py.typed" in names | |
| metadata_name = next( | |
| name | |
| for name in names | |
| if name.endswith(".dist-info/METADATA") | |
| ) | |
| metadata = z.read(metadata_name).decode() | |
| assert f"Version: {os.environ['PACKAGE_VERSION']}" in metadata | |
| assert ( | |
| f"Requires-Dist: pyrefly-shape-extensions=={os.environ['PACKAGE_VERSION']}" | |
| in metadata | |
| ) | |
| with tarfile.open(numpy_stubs_sdists[0]) as t: | |
| names = set(t.getnames()) | |
| assert any(name.endswith("/numpy-stubs/__init__.pyi") for name in names) | |
| assert any(name.endswith("/numpy-stubs/linalg/__init__.pyi") for name in names) | |
| assert any(name.endswith("/numpy-stubs/py.typed") for name in names) | |
| with zipfile.ZipFile(jax_stubs_wheels[0]) as z: | |
| names = set(z.namelist()) | |
| assert "jax-stubs/__init__.pyi" in names | |
| assert "jax-stubs/numpy/__init__.pyi" in names | |
| assert "jax-stubs/py.typed" in names | |
| metadata_name = next( | |
| name | |
| for name in names | |
| if name.endswith(".dist-info/METADATA") | |
| ) | |
| metadata = z.read(metadata_name).decode() | |
| assert f"Version: {os.environ['PACKAGE_VERSION']}" in metadata | |
| assert ( | |
| f"Requires-Dist: pyrefly-shape-extensions=={os.environ['PACKAGE_VERSION']}" | |
| in metadata | |
| ) | |
| assert ( | |
| f"Requires-Dist: pyrefly-numpy-stubs=={os.environ['PACKAGE_VERSION']}" | |
| in metadata | |
| ) | |
| with tarfile.open(jax_stubs_sdists[0]) as t: | |
| names = set(t.getnames()) | |
| assert any(name.endswith("/jax-stubs/__init__.pyi") for name in names) | |
| assert any(name.endswith("/jax-stubs/numpy/__init__.pyi") for name in names) | |
| assert any(name.endswith("/jax-stubs/py.typed") for name in names) | |
| with zipfile.ZipFile(einops_stubs_wheels[0]) as z: | |
| names = set(z.namelist()) | |
| assert "einops-stubs/__init__.pyi" in names | |
| assert "einops-stubs/py.typed" in names | |
| metadata_name = next( | |
| name | |
| for name in names | |
| if name.endswith(".dist-info/METADATA") | |
| ) | |
| metadata = z.read(metadata_name).decode() | |
| assert f"Version: {os.environ['PACKAGE_VERSION']}" in metadata | |
| assert ( | |
| f"Requires-Dist: pyrefly-shape-extensions=={os.environ['PACKAGE_VERSION']}" | |
| in metadata | |
| ) | |
| assert ( | |
| f"Requires-Dist: pyrefly-torch-stubs=={os.environ['PACKAGE_VERSION']}" | |
| in metadata | |
| ) | |
| assert "==0.0.0" not in metadata | |
| with tarfile.open(einops_stubs_sdists[0]) as t: | |
| names = set(t.getnames()) | |
| assert any(name.endswith("/einops-stubs/__init__.pyi") for name in names) | |
| assert any(name.endswith("/einops-stubs/py.typed") for name in names) | |
| for runtime, artifacts, stub_dependencies in ( | |
| ("torch", (torch_stubs_wheels[0], torch_stubs_sdists[0]), ()), | |
| ("numpy", (numpy_stubs_wheels[0], numpy_stubs_sdists[0]), ()), | |
| ( | |
| "jax", | |
| (jax_stubs_wheels[0], jax_stubs_sdists[0]), | |
| (f"pyrefly-numpy-stubs=={os.environ['PACKAGE_VERSION']}",), | |
| ), | |
| ): | |
| expected = { | |
| runtime, | |
| f"pyrefly-shape-extensions=={os.environ['PACKAGE_VERSION']}", | |
| *stub_dependencies, | |
| } | |
| for artifact in artifacts: | |
| if artifact.suffix == ".whl": | |
| with zipfile.ZipFile(artifact) as z: | |
| name = next( | |
| n | |
| for n in z.namelist() | |
| if n.endswith(".dist-info/METADATA") | |
| ) | |
| metadata = z.read(name) | |
| else: | |
| with tarfile.open(artifact) as t: | |
| name = next(n for n in t.getnames() if n.endswith("/PKG-INFO")) | |
| metadata = t.extractfile(name).read() | |
| message = email.parser.BytesParser().parsebytes(metadata) | |
| requirements = set(message.get_all("Requires-Dist", [])) | |
| assert requirements == expected, (artifact, requirements) | |
| PY | |
| - name: Verify runtime dependency resolution without downloading runtimes | |
| run: | | |
| set -euo pipefail | |
| python3 - <<'PY' | |
| import json | |
| import subprocess | |
| import sys | |
| import tempfile | |
| import zipfile | |
| from email.message import EmailMessage | |
| from pathlib import Path | |
| dist = Path("shape-stubs-dist").resolve() | |
| pins = {"torch": "2.5.1", "numpy": "1.26.4", "jax": "0.4.38"} | |
| wheels = [ | |
| str(next(dist.glob(f"{name}-*.whl"))) | |
| for name in ("pyrefly_torch_stubs", "pyrefly_numpy_stubs", "jax_pyrefly_stubs") | |
| ] | |
| # Metadata-only runtime fixtures test the resolver contract, | |
| # not upstream API compatibility. | |
| with tempfile.TemporaryDirectory() as tmp: | |
| fixtures = Path(tmp) | |
| for name, pinned_version in pins.items(): | |
| for version in (pinned_version, "9999.0.0"): | |
| info = f"{name}-{version}.dist-info" | |
| metadata = EmailMessage() | |
| metadata["Metadata-Version"] = "2.1" | |
| metadata["Name"] = name | |
| metadata["Version"] = version | |
| with zipfile.ZipFile( | |
| fixtures / f"{name}-{version}-py3-none-any.whl", "w" | |
| ) as z: | |
| z.writestr(f"{info}/METADATA", metadata.as_bytes()) | |
| z.writestr( | |
| f"{info}/WHEEL", | |
| "Wheel-Version: 1.0\nRoot-Is-Purelib: true\nTag: py3-none-any\n", | |
| ) | |
| z.writestr(f"{info}/RECORD", "") | |
| for requested, expected in ( | |
| ([], {name: "9999.0.0" for name in pins}), | |
| ([f"{name}=={version}" for name, version in pins.items()], pins), | |
| ): | |
| report = fixtures / "report.json" | |
| subprocess.run( | |
| [ | |
| sys.executable, | |
| "-m", | |
| "pip", | |
| "install", | |
| "--dry-run", | |
| "--ignore-installed", | |
| "--no-index", | |
| "--only-binary=:all:", | |
| "--find-links", | |
| str(dist), | |
| "--find-links", | |
| str(fixtures), | |
| "--report", | |
| str(report), | |
| *wheels, | |
| *requested, | |
| ], | |
| check=True, | |
| ) | |
| resolved = { | |
| item["metadata"]["name"]: item["metadata"]["version"] | |
| for item in json.loads(report.read_text())["install"] | |
| } | |
| for name, version in expected.items(): | |
| assert resolved[name] == version, resolved | |
| PY | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.10" | |
| - name: Smoke test torch stubs wheel on Python 3.10 | |
| run: | | |
| set -euo pipefail | |
| python3.10 -m venv "$RUNNER_TEMP/torch-stubs-py310-wheel-venv" | |
| "$RUNNER_TEMP/torch-stubs-py310-wheel-venv/bin/pip" install --no-deps shape-stubs-dist/pyrefly_shape_extensions-*.whl shape-stubs-dist/pyrefly_torch_stubs-*.whl | |
| "$RUNNER_TEMP/torch-stubs-py310-wheel-venv/bin/python" - <<'PY' | |
| import os | |
| from importlib.metadata import version | |
| expected = os.environ["PACKAGE_VERSION"] | |
| assert version("pyrefly-torch-stubs") == expected | |
| assert version("pyrefly-shape-extensions") == expected | |
| PY | |
| - name: Smoke test torch stubs sdist on Python 3.10 | |
| run: | | |
| set -euo pipefail | |
| python3.10 -m venv "$RUNNER_TEMP/torch-stubs-py310-sdist-venv" | |
| "$RUNNER_TEMP/torch-stubs-py310-sdist-venv/bin/pip" install --no-deps shape-stubs-dist/pyrefly_shape_extensions-*.whl shape-stubs-dist/pyrefly_torch_stubs-*.tar.gz | |
| "$RUNNER_TEMP/torch-stubs-py310-sdist-venv/bin/python" - <<'PY' | |
| import os | |
| from importlib.metadata import version | |
| expected = os.environ["PACKAGE_VERSION"] | |
| assert version("pyrefly-torch-stubs") == expected | |
| assert version("pyrefly-shape-extensions") == expected | |
| PY | |
| - name: Smoke test shape extension wheel on Python 3.10 | |
| run: | | |
| set -euo pipefail | |
| python3.10 -m venv "$RUNNER_TEMP/shape-ext-py310-wheel-venv" | |
| "$RUNNER_TEMP/shape-ext-py310-wheel-venv/bin/pip" install shape-stubs-dist/pyrefly_shape_extensions-*.whl | |
| "$RUNNER_TEMP/shape-ext-py310-wheel-venv/bin/python" -c "import shape_extensions, shape_extensions.torchscript" | |
| - name: Smoke test shape extension sdist on Python 3.10 | |
| run: | | |
| set -euo pipefail | |
| python3.10 -m venv "$RUNNER_TEMP/shape-ext-py310-sdist-venv" | |
| "$RUNNER_TEMP/shape-ext-py310-sdist-venv/bin/pip" install shape-stubs-dist/pyrefly_shape_extensions-*.tar.gz | |
| "$RUNNER_TEMP/shape-ext-py310-sdist-venv/bin/python" -c "import shape_extensions, shape_extensions.torchscript" | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.11" | |
| - name: Smoke test torch stubs wheel on Python 3.11 | |
| run: | | |
| set -euo pipefail | |
| python3.11 -m venv "$RUNNER_TEMP/torch-stubs-py311-wheel-venv" | |
| "$RUNNER_TEMP/torch-stubs-py311-wheel-venv/bin/pip" install --no-deps shape-stubs-dist/pyrefly_shape_extensions-*.whl shape-stubs-dist/pyrefly_torch_stubs-*.whl | |
| "$RUNNER_TEMP/torch-stubs-py311-wheel-venv/bin/python" - <<'PY' | |
| import os | |
| from importlib.metadata import version | |
| expected = os.environ["PACKAGE_VERSION"] | |
| assert version("pyrefly-torch-stubs") == expected | |
| assert version("pyrefly-shape-extensions") == expected | |
| PY | |
| - name: Smoke test torch stubs sdist on Python 3.11 | |
| run: | | |
| set -euo pipefail | |
| python3.11 -m venv "$RUNNER_TEMP/torch-stubs-py311-sdist-venv" | |
| "$RUNNER_TEMP/torch-stubs-py311-sdist-venv/bin/pip" install --no-deps shape-stubs-dist/pyrefly_shape_extensions-*.whl shape-stubs-dist/pyrefly_torch_stubs-*.tar.gz | |
| "$RUNNER_TEMP/torch-stubs-py311-sdist-venv/bin/python" - <<'PY' | |
| import os | |
| from importlib.metadata import version | |
| expected = os.environ["PACKAGE_VERSION"] | |
| assert version("pyrefly-torch-stubs") == expected | |
| assert version("pyrefly-shape-extensions") == expected | |
| PY | |
| - name: Upload shape stubs dist | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: shape-stubs-dist | |
| path: shape-stubs-dist |