Skip to content

Commit e414d5f

Browse files
committed
Add support for automated wheel packaging / PyPI deploys
See https://www.benfrederickson.com/writing-python-extensions-in-rust-using-pyo3/
1 parent 24c47df commit e414d5f

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed

.travis.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
language: python
2+
3+
matrix:
4+
include:
5+
- name: "Linux 64-bit"
6+
sudo: required
7+
services:
8+
- docker
9+
env:
10+
- CIBW_SKIP=*manylinux1_i686*
11+
- PIP=pip
12+
- PYTHON=python
13+
- name: "Linux 32-bit"
14+
sudo: required
15+
services:
16+
- docker
17+
env:
18+
- CIBW_SKIP=*manylinux1_x86_64*
19+
- PIP=pip
20+
- PYTHON=python
21+
- name: "macOS"
22+
os: osx
23+
language: generic
24+
env:
25+
- PIP=pip2
26+
- PYTHON=python2
27+
28+
env:
29+
global:
30+
- TWINE_USERNAME=michael.sanders
31+
32+
script:
33+
- $PIP install cibuildwheel setuptools_rust
34+
- export CIBW_BEFORE_BUILD_LINUX="yum install -y gpg libXtst libXtst-devel libXext libXext-devel"
35+
- export CIBW_BEFORE_BUILD="pip install setuptools_rust && source ./scripts/install-rust"
36+
- export CIBW_SKIP=cp34-*\ $CIBW_SKIP
37+
- export CIBW_ENVIRONMENT='PATH="$HOME/rust/bin:$PATH"'
38+
- cibuildwheel --output-dir wheelhouse
39+
- |
40+
if [[ $TRAVIS_TAG ]]; then
41+
$PIP install twine
42+
$PYTHON -m twine upload wheelhouse/*.whl
43+
fi

appveyor.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
environment:
2+
TWINE_USERNAME: michael.sanders
3+
matrix:
4+
# Stable 64-bit MSVC
5+
- channel: stable
6+
target: x86_64-pc-windows-msvc
7+
CIBW_SKIP: "*win32* cp27-* cp33-* cp34-*"
8+
CIBW_BEFORE_BUILD: pip install setuptools-rust
9+
# Stable 32-bit MSVC
10+
- channel: stable
11+
target: i686-pc-windows-msvc
12+
CIBW_SKIP: "*win_amd64* cp27-* cp33-* cp34-*"
13+
CIBW_BEFORE_BUILD: pip install setuptools-rust
14+
15+
16+
# From https://github.com/starkat99/appveyor-rust/blob/master/appveyor.yml
17+
install:
18+
- appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
19+
- rustup-init -yv --default-toolchain nightly --default-host %target%
20+
- set PATH=%PATH%;%USERPROFILE%\.cargo\bin
21+
- rustc -vV
22+
- cargo -vV
23+
- pip install cibuildwheel==0.9.4 setuptools_rust
24+
25+
build_script:
26+
- cibuildwheel --output-dir wheelhouse
27+
- >
28+
IF "%APPVEYOR_REPO_TAG%" == "true"
29+
(
30+
python -m pip install twine
31+
&&
32+
python -m twine upload 'wheelhouse/*.whl'
33+
)
34+
35+
artifacts:
36+
- path: "wheelhouse\\*.whl"
37+
name: Wheels

scripts/install-rust

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
# From https://github.com/benfred/py-cpp-demangle/blob/13a22fd/ci/install_rust.sh
4+
# https://www.benfrederickson.com/writing-python-extensions-in-rust-using-pyo3/
5+
if [ ! -d ~/rust-installer ]; then
6+
set -x
7+
mkdir ~/rust-installer
8+
curl -sL https://static.rust-lang.org/rustup.sh -o ~/rust-installer/rustup.sh
9+
sh ~/rust-installer/rustup.sh --prefix=~/rust --spec=nightly --disable-sudo -y
10+
set +x
11+
fi

0 commit comments

Comments
 (0)