Skip to content

Commit 0417796

Browse files
authored
Merge pull request #7 from benfred/test_gha
Create wheels with github actions and update rust dependencies
2 parents 14fb768 + d3faddb commit 0417796

File tree

7 files changed

+126
-86
lines changed

7 files changed

+126
-86
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Build
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ master ]
7+
tags:
8+
- v*
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build-wheels:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
os: [macos-latest, ubuntu-latest, windows-latest]
18+
python-version: [37, 38, 39, 310, 311]
19+
20+
steps:
21+
- uses: actions/checkout@v3
22+
23+
- name: Set up QEMU
24+
if: runner.os == 'Linux'
25+
uses: docker/setup-qemu-action@v2
26+
with:
27+
platforms: all
28+
29+
- name: Setup rust
30+
uses: actions-rs/toolchain@v1
31+
with:
32+
toolchain: stable
33+
34+
- name: Build wheels
35+
uses: pypa/[email protected]
36+
env:
37+
CIBW_BUILD: cp${{matrix.python-version}}-*
38+
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH" CARGO_TERM_COLOR="always"'
39+
CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"'
40+
41+
- name: Upload Binaries
42+
uses: actions/upload-artifact@v3
43+
with:
44+
name: wheels
45+
path: wheelhouse
46+
47+
test-wheels:
48+
needs: [build-wheels]
49+
runs-on: ${{ matrix.os }}
50+
strategy:
51+
matrix:
52+
python-version: [3.7, 3.8, 3.9, '3.10', '3.11']
53+
os: [macos-latest, ubuntu-latest, windows-latest]
54+
55+
steps:
56+
- uses: actions/checkout@v3
57+
with:
58+
path: py_cpp_demangle_source
59+
- uses: actions/download-artifact@v3
60+
with:
61+
name: wheels
62+
- name: Set up Python ${{ matrix.python-version }}
63+
uses: actions/setup-python@v4
64+
with:
65+
python-version: ${{ matrix.python-version }}
66+
- name: Install wheel
67+
run: |
68+
pip install --force-reinstall --no-deps --no-index --find-links . cpp-demangle
69+
- name: Run unittests
70+
run: |
71+
python -m unittest discover py_cpp_demangle_source/tests
72+
73+
release:
74+
name: Release
75+
runs-on: ubuntu-latest
76+
if: "startsWith(github.ref, 'refs/tags/')"
77+
needs: [test-wheels]
78+
steps:
79+
- uses: actions/download-artifact@v3
80+
with:
81+
name: wheels
82+
- name: Create GitHub Release
83+
uses: fnkr/[email protected]
84+
env:
85+
GHR_PATH: .
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
- uses: actions/setup-python@v2
88+
with:
89+
python-version: 3.9
90+
- name: Push to PyPi
91+
env:
92+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
93+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
94+
run: |
95+
pip install --upgrade wheel pip setuptools twine
96+
twine upload *
97+
rm *

.travis.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
name = "py_cpp_demangle"
33
version = "0.1.0"
44
authors = ["Ben Frederickson <[email protected]>"]
5-
edition = "2018"
5+
edition = "2021"
66

77
[lib]
8-
name = "py_cpp_demangle"
8+
name = "cpp_demangle"
99
crate-type = ["cdylib"]
1010

1111
[dependencies]
12-
cpp_demangle = "0.2.12"
12+
cpp_demangle = "0.4.0"
1313

1414
[dependencies.pyo3]
15-
version = "0.7"
15+
version = "0.17.3"
1616
features = ["extension-module"]

appveyor.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

ci/install_rust.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ if [ ! -d ~/rust-installer ]; then
33
curl -sL https://static.rust-lang.org/rustup.sh -o ~/rust-installer/rustup.sh
44
sh ~/rust-installer/rustup.sh -y
55
source $HOME/.cargo/env
6-
rustup default nightly
6+
rustup default stable
77
fi

pyproject.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[tool.cibuildwheel]
2+
# skip testing in the cibuildwheel phase, will install the wheels later
3+
# and verify
4+
test-command = ""
5+
skip = ["pp*", "*musl*", "*-manylinux_i686", "*win32"]
6+
7+
[tool.cibuildwheel.macos]
8+
archs = ["x86_64"]
9+
10+
[build-system]
11+
requires = [
12+
"setuptools>=42",
13+
"wheel",
14+
"setuptools_rust",
15+
]
16+
build-backend = "setuptools.build_meta"
17+
18+
[tool.cibuildwheel.linux]
19+
before-all = "ci/install_rust.sh"

src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use pyo3::prelude::*;
22
use pyo3::exceptions;
33

4+
5+
46
// This defines a python module. pyo3 will copy the rust doc comment
57
// below into a python docstring
68

@@ -25,14 +27,14 @@ use pyo3::exceptions;
2527
fn cpp_demangle(_py: Python, m: &PyModule) -> PyResult<()> {
2628
// This adds a function to the python module:
2729
/// Demangles a mangled c++ linker symbol name and returns it as a string
28-
#[pyfn(m, "demangle")]
30+
#[pyfn(m)]
2931
fn demangle(mangled: String) -> PyResult<String> {
30-
match cpp_demangle::Symbol::new(&mangled[..]) {
32+
match ::cpp_demangle::Symbol::new(&mangled[..]) {
3133
// Return the output as a string to Python
3234
Ok(sym) => Ok(sym.to_string()),
3335

3436
// on an error, this will raise a python ValueError exception!
35-
Err(error) => return Err(exceptions::ValueError::py_err(error.to_string()))
37+
Err(error) => return Err(exceptions::PyValueError::new_err(error.to_string()))
3638
}
3739
}
3840

0 commit comments

Comments
 (0)