Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
unaidedelf8777 committed May 5, 2024
1 parent 564b60d commit a922df9
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 90 deletions.
99 changes: 33 additions & 66 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ permissions:
contents: read

jobs:
linux:
check-rust:
runs-on: ubuntu-latest
steps:
- name: Check Rust Compiler and Cargo
run: |
rustc --version
cargo --version
build-and-test:
needs: check-rust
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
Expand All @@ -30,56 +39,10 @@ jobs:
target: s390x
- runner: ubuntu-latest
target: ppc64le
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- 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

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
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
Expand All @@ -89,44 +52,48 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
toolchain: stable
profile: minimal
override: true
- name: Build and test
run: |
python -m pip install --upgrade pip setuptools wheel
python setup.py bdist_wheel
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.platform.target }}
path: dist
name: wheels-${{ runner.os }}-${{ matrix.platform.target }}
path: dist/*.whl

sdist:
needs: check-rust
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
uses: PyO3/maturin-action@v1
- uses: actions/setup-python@v5
with:
command: sdist
args: --out dist
python-version: '3.10'
- name: Build source distribution
run: |
python -m pip install --upgrade pip setuptools wheel
python setup.py sdist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: dist
name: source-dist
path: dist/*.tar.gz

release:
name: Release
needs: build-and-test
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 }}
uses: pypa/gh-action-pypi-publish@v1
with:
command: upload
args: --non-interactive --skip-existing wheels-*/*
password: ${{ secrets.PYPI_API_TOKEN }}
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ name = "function-sampler"
packages = [
{ include = "function_sampler" },
]
version = "0.1.5"
version = "0.1.6"
description = "Function calling Logit Sampler"
authors = ["Nathan Hoos <[email protected]>"]
license = "Apache 2.0"
readme = "README.md"
url = "https://github.com/unaidedelf8777/function-sampler/"

classifiers = [
"Programming Language :: Rust",
Expand All @@ -27,11 +28,10 @@ jsonref = "^1.1.0"
torch = "^2.2.2"
joblib = "^1.3.2"
jsonschema = "^4.21.1"
toml = "^0.10.2"
interegular = "0.3.3"

[tool.poetry.group.dev.dependencies]
ruff = "^0.3.1"
maturin = "^1.5.1"
pre-commit = "^3.7.0"
setuptools-rust = "^1.9.0"

Expand Down
48 changes: 27 additions & 21 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,48 @@
from setuptools import setup, find_packages
from setuptools_rust import Binding, RustExtension
import toml

# Load the contents of your pyproject.toml
with open('pyproject.toml', 'r') as pyproject_file:
pyproject_data = toml.load(pyproject_file)

# Extract package metadata
metadata = pyproject_data.get('tool', {}).get('poetry', {})
metadata = {
'name': "function-sampler",
'version': "0.1.5",
'description': "Function calling Logit Sampler",
'long_description': "",
'authors': ["unaidedelf8777"],
'author_email': "[email protected]",
'license': "Apache 2.0",
'classifiers': [
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
],
'url': "https://github.com/unaidedelf8777/function-sampler/",
}

# Define the Rust extension module, assuming it's the same name as the package name
rust_extensions = [
RustExtension(
f"function_sampler.fsm.fsm_utils", # Python package.module for the Rust extension
f"./Cargo.toml", # Path to Cargo.toml of Rust extension
f"function_sampler.fsm.fsm_utils",
f"./Cargo.toml",
binding=Binding.PyO3,
features=["default"],
args=["--profile=release"]
),
]

setup(
name=metadata.get('name'),
version=metadata.get('version'),
author=",".join(metadata.get('authors', [])),
author_email=metadata.get('emails', [''])[0],
description=metadata.get('description', ''),
long_description=metadata.get('description', ''),
name=metadata['name'],
version=metadata['version'],
author=metadata['authors'][0].split(" <")[0], # Extracting name
author_email=metadata['author_email'],
description=metadata['description'],
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
url=metadata.get('homepage', ''),
classifiers=metadata.get('classifiers', []),
keywords=",".join(metadata.get('keywords', [])),
license=metadata.get('license', ''),
url=metadata['url'],
classifiers=metadata['classifiers'],
license=metadata['license'],
packages=find_packages(),
include_package_data=True,
zip_safe=False,
python_requires='>=3.9',
setup_requires=['setuptools-rust', 'wheel', 'toml'],
setup_requires=['setuptools_rust', 'wheel'],
rust_extensions=rust_extensions,
)

0 comments on commit a922df9

Please sign in to comment.