Skip to content

Commit

Permalink
Merge pull request #3 from terra-quantum-public/create-conda-packages
Browse files Browse the repository at this point in the history
feat: add conda package build and upload to CI
  • Loading branch information
cedrictq authored Nov 19, 2024
2 parents 788df51 + 4f81895 commit d2fdf23
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 9 deletions.
28 changes: 26 additions & 2 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ jobs:
platform:
- runner: ubuntu-latest
target: x86_64
target-platform: linux-64
before: 'yum install --assumeyes perl-core'
manylinux: 'auto'
create-conda-package: true
- runner: ubuntu-latest
target: x86_64
before: 'apt update && apt install -y libssl-dev'
Expand Down Expand Up @@ -67,23 +69,37 @@ jobs:
manylinux: 'musllinux_1_2'
- runner: windows-latest
target: x64
target-platform: win-64
create-conda-package: true
- runner: windows-latest
target: x86
- runner: macos-latest
target: x86_64
target-platform: osx-64
create-conda-package: true
- runner: macos-latest
target: aarch64
target-platform: osx-arm64
create-conda-package: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
if: runner.os == 'Windows'
with:
python-version: 3.*
python-version: |
3.9
3.10
3.11
3.12
architecture: ${{ matrix.platform.target }}
- uses: actions/setup-python@v5
if: runner.os != 'Windows'
with:
python-version: 3.*
python-version: |
3.9
3.10
3.11
3.12
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
Expand All @@ -92,6 +108,14 @@ jobs:
sccache: 'true'
manylinux: ${{ matrix.platform.manylinux }}
before-script-linux: ${{ matrix.platform.before }}
- name: Build conda package
if: matrix.platform.create-conda-package
uses: prefix-dev/rattler-build-action@v0.2.19
with:
upload-artifact: false
artifact-name: conda-${{ matrix.platform.runner }}-${{ matrix.platform.target }}
recipe-path: 'conda-recipe/recipe.yaml'
build-args: '--target-platform ${{ matrix.platform.target-platform }} --experimental'

sdist:
runs-on: ubuntu-latest
Expand Down
49 changes: 44 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ jobs:
platform:
- runner: ubuntu-latest
target: x86_64
target-platform: linux-64
before: 'yum install --assumeyes perl-core'
manylinux: 'auto'
create-conda-package: true
- runner: ubuntu-latest
target: x86_64
before: 'apt update && apt install -y libssl-dev'
Expand Down Expand Up @@ -53,23 +55,37 @@ jobs:
manylinux: 'musllinux_1_2'
- runner: windows-latest
target: x64
target-platform: win-64
create-conda-package: true
- runner: windows-latest
target: x86
- runner: macos-latest
target: x86_64
target-platform: osx-64
create-conda-package: true
- runner: macos-latest
target: aarch64
target-platform: osx-arm64
create-conda-package: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
if: runner.os == 'Windows'
with:
python-version: 3.*
python-version: |
3.9
3.10
3.11
3.12
architecture: ${{ matrix.platform.target }}
- uses: actions/setup-python@v5
if: runner.os != 'Windows'
with:
python-version: 3.*
python-version: |
3.9
3.10
3.11
3.12
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
Expand All @@ -83,6 +99,14 @@ jobs:
with:
name: wheels-${{ matrix.platform.runner }}-${{ matrix.platform.manylinux }}-${{ matrix.platform.target }}
path: dist
- name: Build conda package
if: matrix.platform.create-conda-package
uses: prefix-dev/rattler-build-action@v0.2.19
with:
upload-artifact: true
artifact-name: conda-${{ matrix.platform.runner }}-${{ matrix.platform.target }}
recipe-path: 'conda-recipe/recipe.yaml'
build-args: '--target-platform ${{ matrix.platform.target-platform }} --experimental'

sdist:
runs-on: ubuntu-latest
Expand All @@ -99,6 +123,7 @@ jobs:
name: wheels-sdist
path: dist


release:
name: Release
runs-on: ubuntu-latest
Expand All @@ -109,16 +134,30 @@ jobs:
attestations: write
steps:
- uses: actions/checkout@v4
- name: Install rattler-build
run: |
mkdir -p ${{ runner.temp }}/rattler-build
curl -Ls \
https://github.com/prefix-dev/rattler-build/releases/latest/download/rattler-build-x86_64-unknown-linux-musl \
-o ${{ runner.temp }}/rattler-build/rattler-build
chmod +x ${{ runner.temp }}/rattler-build/rattler-build
echo ${{ runner.temp }}/rattler-build >> $GITHUB_PATH
- uses: actions/download-artifact@v4
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-path: 'wheels-*/*'

subject-path: |
wheels-*/*
conda-*/*
- name: Get project version
id: 'pyproject_version'
run: echo "version=v$(grep -m 1 version pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3)" >> $GITHUB_OUTPUT

- name: Publish to prefix.dev channel
run: |
for pkg in $(find conda-*/* -type f \( -name "*.conda" -o -name "*.tar.bz2" \) ); do
echo "Uploading ${pkg}"
rattler-build upload prefix -c terraquantumag "${pkg}"
done
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
.idea

.venv
venv
venv

dist
output
21 changes: 21 additions & 0 deletions conda-recipe/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Terra Quantum AG

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
46 changes: 46 additions & 0 deletions conda-recipe/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
schema_version: 1

context:
name: ${{ load_from_file("pyproject.toml").project.name }}
version: ${{ load_from_file("pyproject.toml").project.version }}

package:
name: ${{ name|lower }}
version: ${{ version }}

source:
path: ../dist
use_gitignore: false

build:
script: pip install --find-links . keygen-py
number: 0

requirements:
build:
- python
host:
- python
- pip
- setuptools
- wheel
run:
- python

tests:
- python:
imports:
- keygen_sh
pip_check: true

about:
summary: Unofficial Keygen SDK for Python. Integrate license activation and offline licensing. Wrapper around keygen-rs rust crate
license: MIT
license_file: LICENSE
homepage: https://github.com/terra-quantum-public/keygen-py

extra:
recipe-maintainers:
- sbtq
- cedrictq

5 changes: 5 additions & 0 deletions conda-recipe/variants.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
python:
- 3.9
- 3.10
- 3.11
- 3.12
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "keygen-py"
version = "0.0.1.dev5"
version = "0.0.1.dev6"
license = "MIT"
description = "Unofficial Keygen SDK for Python. Integrate license activation and offline licensing. Wrapper around keygen-rs rust crate"
requires-python = ">=3.9"
Expand Down

0 comments on commit d2fdf23

Please sign in to comment.