Skip to content

Commit

Permalink
Merge pull request #3 from drebbe-intrepid/python_ci
Browse files Browse the repository at this point in the history
Python CI
  • Loading branch information
drebbe-intrepid committed May 30, 2024
2 parents bcec234 + fcc3f39 commit 952f074
Show file tree
Hide file tree
Showing 7 changed files with 211 additions and 5 deletions.
167 changes: 167 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# This file is autogenerated by maturin v1.5.1
# To update, run
#
# maturin generate-ci github
#
name: CI

on:
push:
branches:
- main
- master
tags:
- '*'
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
# linux:
# runs-on: ${{ matrix.platform.runner }}
# strategy:
# matrix:
# platform:
# - runner: ubuntu-latest
# target: aarch64
# - runner: ubuntu-latest
# target: armv7
# - runner: ubuntu-latest
# target: x86_64
# # - runner: ubuntu-latest
# # target: x86
# fail-fast: false
# steps:
# - uses: actions/checkout@v4
# with:
# submodules: recursive
# fetch-depth: 0 # needed for history/tags
# - uses: actions/setup-python@v5
# with:
# python-version: '3.9'
# - name: Build wheels
# uses: PyO3/maturin-action@v1
# with:
# target: ${{ matrix.platform.target }}
# args: --release --out dist --find-interpreter --manifest-path crates/pymic2/Cargo.toml
# sccache: 'false'
# manylinux: 2_28
# before-script-linux: |
# cat /etc/os-release
# case "${{ matrix.platform.target }}" in
# "aarch64" | "armv7" | "s390x" | "ppc64le")
# # NOTE: pypa/manylinux docker images are Debian based
# uname -m
# sudo apt-get update -y
# sudo dpkg --add-architecture arm64
# sudo dpkg --print-foreign-architectures
# sudo apt-get update -y
# sudo apt-get install -y libsfml-dev:arm64 libudev-dev:arm64 libftdi1-dev:arm64 libfreetype-dev:arm64 libx11-dev:arm64 libxrandr-dev:arm64 libopengl-dev:arm64 libflac-dev:arm64 libogg-dev:arm64 libvorbis-dev:arm64 libopenal-dev:arm64
# . ./util/sfml.sh
# ;;
# "x86_64" | "x86")
# uname -m
# # NOTE: pypa/manylinux docker images are Debian based
# dnf install -y almalinux-release-devel
# dnf install -y systemd-devel libusb-devel freetype-devel libX11-devel libXrandr-devel libglvnd-devel flac-devel libogg-devel libvorbis-devel openal-soft-devel

# # libftdi is not available in the almalinux-release package
# . ./util/ftdi1.sh
# # libsfml is dirt old on almalinux...
# . ./util/sfml.sh
# ;;
# esac
# - name: Upload wheels
# uses: actions/upload-artifact@v4
# with:
# name: wheels-linux-${{ matrix.platform.target }}
# path: dist
# # windows:
# # runs-on: ${{ matrix.platform.runner }}
# # strategy:
# # matrix:
# # platform:
# # - runner: windows-latest
# # target: x64
# # - runner: windows-latest
# # target: x86
# # steps:
# # - uses: actions/checkout@v4
# # - uses: actions/setup-python@v5
# # with:
# # python-version: '3.10'
# # architecture: ${{ matrix.platform.target }}
# # - name: Build wheels
# # uses: PyO3/maturin-action@v1
# # with:
# # target: ${{ matrix.platform.target }}
# # args: --release --out dist --find-interpreter --manifest-path crates/pymic2/Cargo.toml
# # 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 }}
# # strategy:
# # matrix:
# # platform:
# # - runner: macos-latest
# # target: x86_64
# # - runner: macos-14
# # target: aarch64
# # steps:
# # - uses: actions/checkout@v4
# # with:
# # submodules: recursive
# # fetch-depth: 0 # needed for history/tags
# # - uses: actions/setup-python@v5
# # with:
# # python-version: '3.10'
# # - name: Install system dependencies
# # run: brew install sfml@2.5.1 cmake
# # - name: Build wheels
# # uses: PyO3/maturin-action@v1
# # with:
# # target: ${{ matrix.platform.target }}
# # args: --release --out dist --find-interpreter --manifest-path crates/pymic2/Cargo.toml
# # sccache: 'true'
# # - name: Upload wheels
# # uses: actions/upload-artifact@v4
# # with:
# # name: wheels-macos-${{ matrix.platform.target }}
# # path: dist

sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist --manifest-path crates/pymic2/Cargo.toml
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: dist

# release:
# name: Release
# runs-on: ubuntu-latest
# if: "startsWith(github.ref, 'refs/tags/')"
# needs: [linux, windows, macos, sdist]
# steps:
# - uses: actions/download-artifact@v4
# - name: Publish to PyPI
# uses: PyO3/maturin-action@v1
# env:
# MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
# with:
# command: upload
# args: --non-interactive --skip-existing wheels-*/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# will have compiled files and executables
debug/
target/
build_sfml/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/mic2_rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ audio = ["dep:sfml"]
[dependencies]
#libftd2xx = { version = "0.32.2", features=[], optional = true }
cfg-if = "1.0.0"
sfml = { version = "0.21.0", optional = true }
sfml = { version = "0.20.0", optional = true }
nmea-parser = { version = "0.10.0", optional = true }
serialport = { version = "4.2.1", optional = true }
rusb = "0.9.2"
Expand Down
2 changes: 1 addition & 1 deletion crates/pymic2/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ classifiers = [
dynamic = ["version"]

[tool.maturin]
features = ["pyo3/extension-module"]
features = ["pyo3/extension-module"]
14 changes: 14 additions & 0 deletions util/ftdi1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# libftdi is not available in the almalinux-release package
set -e

VERSION=1.5

echo "Downloading libftdi1-${VERSION}..."
curl -OL https://www.intra2net.com/en/developer/libftdi/download/libftdi1-${VERSION}.tar.bz2
tar -xf libftdi1-${VERSION}.tar.bz2
cd libftdi1-${VERSION}
echo "Building libftdi1-${VERSION}..."
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DFTDI_EEPROM=OFF -Wno-dev
cmake --build build --target install --config Release
cd ..
echo "Done building libftdi1-${VERSION}!"
24 changes: 24 additions & 0 deletions util/sfml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -e

PARENT_DIR=$(pwd)
SFML_VERSION="2.5.1"
SFML_URL="https://github.com/SFML/SFML/archive/refs/tags/${SFML_VERSION}.tar.gz"

mkdir -pv build_sfml && cd build_sfml
echo "Downloading SFML source ${SFML_VERSION}..."
curl -OL $SFML_URL
tar -xf ${SFML_VERSION}.tar.gz

echo "Building SFML ${SFML_VERSION}..."
cd SFML-${SFML_VERSION}
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -Wno-dev
cmake --build build --target install --config Release

echo "Setting up rust-sfml environment variables..."
export SFML_INCLUDE_DIR="$(pwd)/include"
export SFML_LIB_DIR="$(pwd)/build/lib"

cd $PARENT_DIR

echo "Done building SFML ${SFML_VERSION}!"

0 comments on commit 952f074

Please sign in to comment.