Skip to content

Commit

Permalink
feat!: rewrite in rust (#143)
Browse files Browse the repository at this point in the history
* simplify `Grid`, `Stack`, `Absolute` creation
* use `phantom` instead of `visibility`
* more pythonic function signature and remove some unnecessary types

BREAKING CHANGE: change multiple public API signature
  • Loading branch information
kahojyun authored Apr 20, 2024
1 parent a480852 commit 0e102e4
Show file tree
Hide file tree
Showing 150 changed files with 4,925 additions and 8,797 deletions.
371 changes: 0 additions & 371 deletions .editorconfig

This file was deleted.

63 changes: 0 additions & 63 deletions .gitattributes

This file was deleted.

2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

version: 2
updates:
- package-ecosystem: "nuget" # See documentation for possible values
- package-ecosystem: "cargo" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "monthly"
226 changes: 120 additions & 106 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ concurrency:
permissions:
contents: read

env:
CARGO_TERM_COLOR: always
PYTHON_VERSION: 3.12

jobs:
# Should run on every push and PR
test:
Expand All @@ -27,26 +31,21 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
- name: Cargo build
run: cargo build --verbose
- name: Cargo test
run: cargo test --verbose
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install hatch
run: |
python -m pip install --upgrade pip
pip install hatch
- name: Test
run: hatch run test:run
- name: Stubtest
run: hatch run stubcheck

# Should run on every push and PR, but only run semantic-release on push
release:
Expand All @@ -63,7 +62,7 @@ jobs:
with:
fetch-depth: 0
- name: Semantic Release
uses: docker://ghcr.io/codfish/semantic-release-action@sha256:9e0bbcc4ca3b3611668dcf911e51432573efb3222587c4ca1cc8a759c1b8283c # v3.1.1
uses: codfish/semantic-release-action@v3
# Only run on push events
if: github.event_name == 'push'
id: semantic-release
Expand All @@ -77,107 +76,125 @@ jobs:
"@semantic-release/github",
]
outputs:
version: ${{ steps.semantic-release.outputs.release-version || '0.0.0-dev' }}
version: ${{ steps.semantic-release.outputs.release-version || format('0.0.0-dev+{0}', github.sha) }}
published: ${{ steps.semantic-release.outputs.new-release-published || 'false' }}

# Should run on every push and PR
build-wheel:
name: Build wheel for ${{ matrix.os }}-${{ matrix.arch }}
linux:
runs-on: ${{ matrix.platform.runner }}
needs: release
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
arch: [x64, arm64]

runs-on: ${{ matrix.os }}

platform:
- runner: ubuntu-latest
target: x86_64
steps:
- uses: actions/checkout@v4
- name: Write version to file
run: echo ${{ needs.release.outputs.version }} > VERSION.txt
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install build
run: |
python -m pip install --upgrade pip
pip install --upgrade build
- name: Build wheel
run: python -m build --wheel
env:
BUILD_TARGET_ARCH: ${{ matrix.arch }}
- name: Repair macOS wheel
if: startsWith(matrix.os, 'macos')
run: |
pip install delocate
delocate-wheel -v dist/*.whl
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.os }}-${{ matrix.arch }}
path: dist/*.whl
- uses: actions/checkout@v4
- name: Replace version in Cargo.toml
shell: pwsh
run: (Get-Content -Path Cargo.toml -Raw) -replace 'version = ".*"', 'version = "${{ needs.release.outputs.version }}"' | Set-Content -Path Cargo.toml
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.platform.target }}
path: dist

# Should run on every push and PR
build-wheel-linux:
name: Build wheel for manylinux-x64
windows:
runs-on: ${{ matrix.platform.runner }}
needs: release
runs-on: ubuntu-latest
strategy:
matrix:
platform:
- runner: windows-latest
target: x64
- runner: windows-latest
target: x86
steps:
- uses: actions/checkout@v4
- name: Replace version in Cargo.toml
shell: pwsh
run: (Get-Content -Path Cargo.toml -Raw) -replace 'version = ".*"', 'version = "${{ needs.release.outputs.version }}"' | Set-Content -Path Cargo.toml
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: ${{ matrix.platform.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows-${{ matrix.platform.target }}
path: dist

macos:
runs-on: ${{ matrix.platform.runner }}
needs: release
strategy:
matrix:
platform:
- runner: macos-latest
target: x86_64
- runner: macos-14
target: aarch64
steps:
- uses: actions/checkout@v4
- name: Write version to file
run: echo ${{ needs.release.outputs.version }} > VERSION.txt
- name: Build wheels
uses: pypa/cibuildwheel@v2.17
env:
CIBW_BUILD: "*-manylinux_x86_64"
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_28_x86_64
CIBW_BEFORE_ALL_LINUX: dnf install -y dotnet-sdk-8.0
CIBW_BUILD_FRONTEND: build
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-manylinux
path: wheelhouse/*.whl
- uses: actions/checkout@v4
- name: Replace version in Cargo.toml
shell: pwsh
run: (Get-Content -Path Cargo.toml -Raw) -replace 'version = ".*"', 'version = "${{ needs.release.outputs.version }}"' | Set-Content -Path Cargo.toml
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.platform.target }}
path: dist

# Should run on every push and PR
sdist:
name: Build sdist
needs: release
runs-on: ubuntu-latest

needs: release
steps:
- uses: actions/checkout@v4
- name: Write version to file
run: echo ${{ needs.release.outputs.version }} > VERSION.txt
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install build
run: |
python -m pip install --upgrade pip
pip install --upgrade build
- name: Build sdist
run: python -m build --sdist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
- uses: actions/checkout@v4
- name: Replace version in Cargo.toml
shell: pwsh
run: (Get-Content -Path Cargo.toml -Raw) -replace 'version = ".*"', 'version = "${{ needs.release.outputs.version }}"' | Set-Content -Path Cargo.toml
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: dist

# For branch protection rules
check:
if: always()
needs:
- build-wheel
- build-wheel-linux
- linux
- windows
- macos
- sdist
runs-on: ubuntu-latest
steps:
Expand All @@ -190,20 +207,17 @@ jobs:
publish:
name: Publish to PyPI
needs:
- build-wheel
- build-wheel-linux
- sdist
- check
- release
if: needs.release.outputs.published == 'true' && github.event_name == 'push'
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- uses: actions/download-artifact@v4
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
uses: PyO3/maturin-action@v1
with:
command: upload
args: --non-interactive --skip-existing wheels-*/*
Loading

0 comments on commit 0e102e4

Please sign in to comment.