Skip to content
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
69 changes: 39 additions & 30 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,33 +59,48 @@ jobs:
python -m pip install -U setuptools wheel pip
python setup.py sdist

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist/*.tar.*

build-wheels:
build-wheels-matrix:
needs: validate-release-request
runs-on: ubuntu-latest
outputs:
include: ${{ steps.set-matrix.outputs.include }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- run: pip install cibuildwheel==2.15.0
- id: set-matrix
run: |
MATRIX_INCLUDE=$(
{
cibuildwheel --print-build-identifiers --platform linux --arch x86_64,aarch64 | grep cp | jq -nRc '{"only": inputs, "os": "ubuntu-latest"}' \
&& cibuildwheel --print-build-identifiers --platform macos --arch x86_64,arm64 | grep cp | jq -nRc '{"only": inputs, "os": "macos-latest"}' \
&& cibuildwheel --print-build-identifiers --platform windows --arch x86,AMD64 | grep cp | jq -nRc '{"only": inputs, "os": "windows-latest"}'
} | jq -sc
)
echo "include=$MATRIX_INCLUDE" >> $GITHUB_OUTPUT

build-wheels:
needs: build-wheels-matrix
runs-on: ${{ matrix.os }}
name: Build ${{ matrix.only }}

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
cibw_arch: ["auto64", "aarch64", "universal2"]
cibw_python:
- "cp38-*"
- "cp39-*"
- "cp310-*"
- "cp311-*"
- "cp312-*"
exclude:
- os: ubuntu-latest
cibw_arch: universal2
- os: macos-latest
cibw_arch: aarch64
- os: windows-latest
cibw_arch: universal2
- os: windows-latest
cibw_arch: aarch64
include: ${{ fromJson(needs.build-wheels-matrix.outputs.include) }}

defaults:
run:
shell: bash

env:
PIP_DISABLE_PIP_VERSION_CHECK: 1

steps:
- uses: actions/checkout@v3
Expand All @@ -94,23 +109,17 @@ jobs:
submodules: true

- name: Set up QEMU
if: matrix.os == 'ubuntu-latest' && matrix.cibw_arch == 'aarch64'
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
with:
platforms: arm64

- uses: pypa/cibuildwheel@v2.9.0
- uses: pypa/cibuildwheel@39a63b5912f086dd459cf6fcb13dcdd3fe3bc24d # v2.15.0
with:
only: ${{ matrix.only }}
env:
CIBW_BUILD_VERBOSITY: 1
CIBW_BUILD: ${{ matrix.cibw_python }}
CIBW_ARCHS: ${{ matrix.cibw_arch }}
CIBW_TEST_EXTRAS: "test"
CIBW_TEST_COMMAND: "cd .. && python {project}/tests/__init__.py"
CIBW_TEST_COMMAND_WINDOWS: "cd .. && python {project}\\tests\\__init__.py"
CIBW_TEST_SKIP: "*universal2:arm64"
CIBW_ENVIRONMENT: "IMMU_SKIP_MYPY_TESTS=1"

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: dist
path: wheelhouse/*.whl
Expand Down
2 changes: 1 addition & 1 deletion immutables/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
# supported platforms, publish the packages on PyPI, merge the PR
# to the target branch, create a Git tag pointing to the commit.

__version__ = '0.20.dev0'
__version__ = '0.20'
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "immutables"
description = "Immutable Collections"
authors = [{name = "MagicStack Inc", email = "hello@magic.io"}]
requires-python = '>=3.8.0'
readme = "README.rst"
license = {text = "Apache License, Version 2.0"}
dynamic = ["version"]
Expand Down Expand Up @@ -78,3 +79,16 @@ ignore_errors = true
[[tool.mypy.overrides]]
module = "immutables._testutils"
ignore_errors = true

[tool.cibuildwheel]
build-frontend = "build"
test-extras = "test"

[tool.cibuildwheel.macos]
test-command = "python {project}/tests/__init__.py"

[tool.cibuildwheel.windows]
test-command = "python {project}\\tests\\__init__.py"

[tool.cibuildwheel.linux]
test-command = "python {project}/tests/__init__.py"
27 changes: 20 additions & 7 deletions tests/test_pattern_matching.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys
import textwrap
import unittest

from immutables.map import Map as PyMap
Expand All @@ -7,14 +9,25 @@ class BaseMapTest:

Map = None

@unittest.skipIf(
sys.version_info < (3, 10),
"pattern matching is not supported in this Python version",
)
def test_map_can_be_matched(self):
match self.Map(a=1, b=2): # noqa: E999
case {"a": 1 as matched}:
matched = matched
case _:
assert False

assert matched == 1
locals_ = dict(locals())
exec(
textwrap.dedent("""\
match self.Map(a=1, b=2): # noqa: E999
case {"a": 1 as matched}:
matched = matched
case _:
assert False

self.assertEqual(matched, 1)
"""),
globals(),
locals_,
)


class PyMapTest(BaseMapTest, unittest.TestCase):
Expand Down