From a63bf5acf63821e8b4ebdb54436a677dd61ecebe Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Sun, 13 Aug 2023 00:51:48 +0200 Subject: [PATCH] Add Windows CI --- .github/workflows/CI.yml | 117 +++++++++++++++++++++++++-------------- setup.cfg | 4 +- setup.py | 5 +- 3 files changed, 80 insertions(+), 46 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index dff158a..7963319 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -32,38 +32,56 @@ jobs: # name: wheels # path: dist - # windows: - # runs-on: windows-latest - # strategy: - # matrix: - # target: [x64] - # steps: - # - uses: actions/checkout@v3 - # with: - # submodules: 'true' + windows: + # Skip building pull requests from the same repository + if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) }} + runs-on: windows-latest + env: + # Disable output buffering in an attempt to get readable errors + PYTHONUNBUFFERED: '1' + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: 'true' - # - uses: actions/setup-python@v4 - # with: - # python-version: '3.10' - # architecture: ${{ matrix.target }} - - # - name: Build wheels - # uses: PyO3/maturin-action@v1 - # with: - # target: ${{ matrix.target }} - # args: --release --out dist --find-interpreter - # sccache: 'true' - - # - name: Upload wheels - # uses: actions/upload-artifact@v3 - # with: - # name: wheels - # path: dist + - name: Python environment + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: x86_64-pc-windows-msvc + + - name: Build + shell: bash + run: | + pip install -r requirements.txt + python setup.py bdist_wheel --py-limited-api=cp37 + pip install --force-reinstall dist/*.whl + python -c "import icicle" + + - name: Test + run: | + pip install -r tests/requirements.txt + python tests/example.py + python tests/invalid.py + + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist macos: # Skip building pull requests from the same repository if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) }} runs-on: macos-latest + env: + # Disable output buffering in an attempt to get readable errors + PYTHONUNBUFFERED: '1' steps: - name: Checkout uses: actions/checkout@v3 @@ -105,20 +123,35 @@ jobs: name: wheels path: dist + release: + if: ${{ startsWith(github.ref, 'refs/tags/v') }} + runs-on: ubuntu-latest + needs: + - windows + - macos + #- linux + steps: + - uses: actions/download-artifact@v3 + with: + name: wheels - # release: - # name: Release - # runs-on: ubuntu-latest - # if: "startsWith(github.ref, 'refs/tags/')" - # needs: [linux, windows, macos] - # steps: - # - uses: actions/download-artifact@v3 - # with: - # name: wheels - # - name: Publish to PyPI - # uses: PyO3/maturin-action@v1 - # env: - # MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} - # with: - # command: upload - # args: --skip-existing * + - name: Python environment + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Package + run: | + python setup.py sdist + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@b7f401de30cb6434a1e19f805ff006643653240e # v1.8.10 + with: + password: ${{ secrets.PYPI_API_TOKEN }} + + - name: Release + uses: softprops/action-gh-release@c9b46fe7aad9f02afd89b12450b780f52dacfb2d # master 2023-03-26 + with: + generate_release_notes: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/setup.cfg b/setup.cfg index a9f0dca..1839dc0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = icicle-emu -version = v1.0.0 +version = 0.0.1 url = https://github.com/mrexodia/icicle-python project_urls = Bug Tracker = https://github.com/mrexodia/icicle-python/issues @@ -22,6 +22,8 @@ classifiers = [options] packages = icicle +package_dir = + = python zip_safe = False setup_requires = setuptools-rust >= 0.12.1; python_requires = >=3.7 diff --git a/setup.py b/setup.py index b359b9b..434e239 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,13 @@ #!/usr/bin/env python +import sys from os import getenv from shutil import which from setuptools import find_packages, setup from setuptools_rust import RustExtension if __name__ == "__main__": - if which("cargo") is None: + if "sdist" not in sys.argv and which("cargo") is None: raise FileNotFoundError(f"Rust not found, visit https://rustup.rs for installation instructions") ref_name = getenv("GITHUB_REF_NAME") @@ -26,7 +27,5 @@ if __name__ == "__main__": pass setup( - packages=find_packages(where="python", exclude=["icicle/__pycache__"]), - package_dir={"": "python"}, rust_extensions=[RustExtension("icicle.icicle")], )