Skip to content

Commit e073225

Browse files
committed
multi-version builds for Mac, setuptools integration, and refactor
1 parent b2ef878 commit e073225

11 files changed

+260
-193
lines changed

.travis.yml

+17-5
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,25 @@ env:
1313
- CRATE_NAME=trust_pypi_example
1414
# Rust release. E.g. Stable, nightly, nightly-2014-12-18
1515
- RUSTRELEASE=stable
16-
- SKIPCROSS=true
16+
- RUSTCOMPILER=RUSTUP
1717

1818
matrix:
1919
include:
2020
# TARGET is the rust target triplet
21-
# WHEELPLATFORM is the wheel platform target
22-
# PYENV is the Python version to build against. Not relevent if using "manylinux"
21+
# WHEELPLATFORM - is the wheel platform target that is passed in as
22+
# python setup.py bdist_wheel --plat-name=<WHEELPLATFORM>
23+
# E.g. "macosx_10_11_x86_64", "win_amd64", "manylinux1_x86_64"
24+
# Using "manylinux1_i686" or "manylinux1_x86_64" will initiate a
25+
# special "manylinux build"
26+
27+
28+
# PYENV - single version, or comma seperated list of versions to build against
29+
# Not relevent if using "manylinux" because python is already installed in
30+
# the manylinux docker container and those are used instead
31+
32+
# RUSTCOMPILER - which build tools do we intall for rust. options are RUSTUP or CROSS.
33+
# This option is ignored when building a manylinux wheel
34+
# Also, at this time you would have to integrate Cross yourself.
2335

2436

2537
# Linux
@@ -51,10 +63,10 @@ matrix:
5163
# See versions https://docs.travis-ci.com/user/osx-ci-environment/#OS-X-Version
5264
# current default is osx_image: xcode7.3 OS X 10.11
5365
# xcode6.4 seems to segfault with rustup or cross
54-
- env: TARGET=x86_64-apple-darwin PYENV=2.7.13 WHEELPLATFORM=macosx_10_11_x86_64
66+
- env: TARGET=x86_64-apple-darwin PYENV='3.6.1,3.5.3,3.4.6,2.7.13' WHEELPLATFORM=macosx_10_11_x86_64
5567
os: osx
5668
osx_image: xcode7.3
57-
- env: TARGET=x86_64-apple-darwin PYENV=3.6.1 WHEELPLATFORM=macosx_10_12_x86_64
69+
- env: TARGET=x86_64-apple-darwin PYENV='3.6.1,3.5.3,3.4.6,2.7.13' WHEELPLATFORM=macosx_10_12_x86_64
5870
os: osx
5971
osx_image: xcode8.1
6072
# - env: TARGET=i686-apple-darwin PYENV=2.7.13 WHEELPLATFORM=

HISTORY.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
History
33
=======
44

5-
0.1.0 (2017-05-16)
5+
0.1.0 (2017-05-17)
66
------------------
77

88
* First release on PyPI.

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include HISTORY.rst
66
include LICENSE
77
include README.rst
88

9-
recursive-include trust_pypi_example/tests *
9+
recursive-include tests/ *.py
1010
recursive-exclude * __pycache__
1111
recursive-exclude * *.py[co]
1212

ci/install.sh

+36-33
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,42 @@
11
set -ex
22

3-
main() {
4-
if [[ $WHEELPLATFORM == *"manylinux"* ]]; then
5-
echo "Manylinx does not require Cross - WHEELPLATFORM=$WHEELPLATFORM"
6-
return
7-
fi
8-
if [ ! -z ${SKIPCROSS+x} ]; then
9-
# This is for local testing. It skips the install.
10-
echo "SKIPCROSS is set."
11-
return
12-
fi
13-
local target=
14-
if [ $TRAVIS_OS_NAME = linux ]; then
15-
target=x86_64-unknown-linux-musl
16-
# target=x86_64-unknown-linux-gnu
17-
sort=sort
18-
else
19-
target=x86_64-apple-darwin
20-
sort=gsort # for `sort --sort-version`, from brew's coreutils.
3+
source `dirname $0`/utils.sh
4+
5+
6+
if [ -z ${TARGET+x} ]; then
7+
if [ ! -z ${TRAVIS_BUILD_NUMBER+x} ]; then
8+
echo "Target not set but it looks like this is running on Travis."
9+
exit 2
2110
fi
11+
echo "TARGET is not set. Defaulting to x86_64-unknown-linux-gnu"
12+
export TARGET='x86_64-unknown-linux-gnu'
13+
# This is for local testing. You can change the default to match your system.
14+
else
15+
echo "TARGET is $TARGET"
16+
fi
17+
2218

23-
# This fetches latest stable release
24-
# local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \
25-
# | cut -d/ -f3 \
26-
# | grep -E '^v[0.1.0-9.]+$' \
27-
# | $sort --version-sort \
28-
# | tail -n1)
29-
curl -LSfs https://japaric.github.io/trust/install.sh | \
30-
sh -s -- \
31-
--force \
32-
--git japaric/cross \
33-
--tag 'v0.1.10' \
34-
--target $target
35-
}
19+
if [ -z ${RUSTRELEASE+x} ]; then
20+
if [ ! -z ${TRAVIS_BUILD_NUMBER+x} ]; then
21+
echo "RUSTRELEASE not set but it looks like this is running on Travis."
22+
exit 2
23+
fi
24+
echo "RUSTRELEASE is not set. Defaulting to stable"
25+
export RUSTRELEASE='stable'
26+
# This is for local testing. You can change the default to match your system.
27+
else
28+
echo "RUSTRELEASE is $RUSTRELEASE"
29+
fi
3630

3731

38-
# Skipping this for now.
39-
# main
32+
if [[ $WHEELPLATFORM == *"manylinux"* ]]; then
33+
echo "Manylinx does not require Cross - WHEELPLATFORM=$WHEELPLATFORM"
34+
elif [[ $RUSTCOMPILER == "RUSTUP" ]]; then
35+
rustup_install
36+
elif [[ $RUSTCOMPILER == "CROSS" ]]; then
37+
# for now I don't think we actually need cross but we can leave this in.
38+
cross_install
39+
else
40+
echo "RUSTCOMPILER is not set and this isn't a Manylinux wheel - exit 2"
41+
exit 2
42+
fi

ci/manylinux_build_wheel.sh

+40-61
Original file line numberDiff line numberDiff line change
@@ -6,82 +6,61 @@
66
set -e -x
77

88
function RETURNOWNERSHIP {
9-
# We need to change perms back to user in the end since we run as root in the manylinux container
10-
chown -Rf --reference=/io/setup.py /io /root/.cache/pip /root/.cargo /root/.rustup
9+
# We need to change perms back to user in the end since we run as root in the manylinux container
10+
chown -Rf --reference=/io/setup.py /io /root/.cache/pip /root/.cargo /root/.rustup
1111
}
1212
trap RETURNOWNERSHIP EXIT
1313

14-
export USER='root'
15-
chown -fR root:root /root/.cache/pip /root/.cargo /root/.rustup
14+
source `dirname $0`/utils.sh
1615

17-
function rust_build() {
18-
# We build our Rust lib here so it will be compatible with old versions of common shared libs
19-
20-
# install rustup inside the manylinux container
21-
curl https://sh.rustup.rs -sSf > /tmp/rustup.sh
22-
sh /tmp/rustup.sh -y
23-
source $HOME/.cargo/env
24-
rustup install "stable-$TARGET"
25-
rustup default "stable-$TARGET"
26-
rustup update
27-
28-
cd /io/trust_pypi_example/rust/
29-
cargo build --target $TARGET --release
16+
export USER='root'
17+
chown -fR root:root /root/.cache/pip /root/.cargo /root/.rustup
3018

31-
# disable tests
32-
if [ ! -z $DISABLE_TESTS ]; then
33-
echo "Rust Tests Disabled"
34-
else
35-
cargo test --target $TARGET --release
36-
fi
37-
# uncomment if creating a bin
38-
# cargo run --target $TARGET
39-
# cargo run --target $TARGET --release
19+
function manylinux_build_test_and_bundle() {
20+
rustup_install
4021

41-
if [ ! -d "target/$TARGET/release" ]; then
42-
echo "Cannot find release dir at target/$TARGET/release"
43-
exit 2
44-
else
45-
pushd target
46-
mv release release.bak || true
47-
cp -r $TARGET/release release
48-
popd
49-
fi
50-
51-
}
52-
53-
function manylinux_test_and_bundle() {
5422
cd /io
5523
rm -rf /io/wheelhouse
24+
mkdir -p wheelhouse
25+
source $HOME/.cargo/env
5626

57-
# Skips 2.6
58-
for PYBIN in /opt/python/{cp27*,cp3*}/bin/; do
59-
"${PYBIN}/pip" install -U pip virtualenv
60-
"${PYBIN}/virtualenv" /tmp/$PYBIN
61-
source "/tmp${PYBIN}/bin/activate"
62-
pip install -q -U pip
63-
pip install -q -r /io/requirements_dev.txt
64-
pip wheel /io/ -w /io/wheelhouse/
65-
deactivate
66-
done
27+
# remove unnneded versions
28+
rm -rf /opt/python/cp26*
29+
# rm -rf /opt/python/cp27* # uncludes m and mu
30+
# rm -rf /opt/python/cp33*
31+
# rm -rf /opt/python/cp34*
32+
# rm -rf /opt/python/cp35*
33+
# rm -rf /opt/python/cp36*
6734

68-
# Bundle external shared libraries into the wheels
69-
# for whl in /io/wheelhouse/*.whl; do
70-
# auditwheel show "$whl"
71-
# auditwheel repair "$whl" -w /io/wheelhouse/
72-
# done
7335

74-
# Install packages and test
75-
for PYBIN in /opt/python/{cp27*,cp3*}/bin/; do
36+
# Skips 2.6 {cp27*,cp3*}
37+
for PYBIN in /opt/python/*/bin/; do
38+
"${PYBIN}/pip" install -U pip virtualenv
39+
"${PYBIN}/virtualenv" /tmp/$PYBIN
40+
set +x
7641
source "/tmp${PYBIN}/bin/activate"
77-
"${PYBIN}/pip" install trust_pypi_example --no-index -f /io/wheelhouse
78-
py.test /io/tests/
79-
42+
set -x
43+
pip install -q -U pip
44+
pip install -q -r requirements_dev.txt
45+
python setup.py clean
46+
make clean
47+
python setup.py build_ext
48+
if [ -z ${WHEELPLATFORM+x} ]; then
49+
python setup.py bdist_wheel
50+
else
51+
python setup.py bdist_wheel --plat-name="$WHEELPLATFORM"
52+
fi
53+
cp dist/*.whl wheelhouse || true
54+
python setup.py test # should work with py.test
55+
python setup.py check
56+
python setup.py develop
57+
set +x
8058
deactivate
59+
set -x
8160
done
8261
}
8362

8463

85-
rust_build
86-
manylinux_test_and_bundle
64+
# rust_build
65+
manylinux_build_test_and_bundle
8766
RETURNOWNERSHIP

ci/pyinstall.sh

+56-37
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,62 @@
11
set -ex
2-
# Set up pyinstall and the virtualenv
3-
PATH="$HOME/.pyenv/shims:$HOME/.pyenv/bin:$PATH"
4-
pyenv --version || true
5-
if [ -d "$HOME/.pyenv/.git" ]; then
6-
# for local testing
7-
pushd "$HOME/.pyenv"
8-
git pull
9-
popd
10-
else
11-
rm -rf ~/.pyenv
12-
git clone https://github.com/yyuu/pyenv.git $HOME/.pyenv
13-
mkdir -p ~/.cache/pyenv/versions
14-
ln -s ~/.cache/pyenv/versions ~/.pyenv/versions
15-
fi
162

17-
if [ -z ${PYENV+x} ]; then
18-
# This is for local testing. You can change the default to match your system.
19-
export PYENV='3.6.1'
20-
echo "PYENV is not set. Defaulting to python $PYENV."
21-
if [ ! -z ${TRAVIS_BUILD_NUMBER+x} ]; then
22-
# should not see TRAVIS_BUILD_NUMBER if this is local testing.
23-
echo "TARGET is not set but TRAVIS_BUILD_NUMBER is. Exiting with error"
24-
exit 2
3+
function pyenv_install() {
4+
# Set up pyinstall and the virtualenv
5+
PATH="$HOME/.pyenv/shims:$HOME/.pyenv/bin:$PATH"
6+
pyenv --version || true
7+
if [ -d "$HOME/.pyenv/.git" ]; then
8+
# for local testing
9+
pushd "$HOME/.pyenv"
10+
git pull
11+
popd
12+
else
13+
rm -rf ~/.pyenv
14+
git clone https://github.com/yyuu/pyenv.git $HOME/.pyenv
15+
mkdir -p ~/.cache/pyenv/versions
16+
ln -s ~/.cache/pyenv/versions ~/.pyenv/versions
2517
fi
26-
else
27-
echo "PYENV is $PYENV"
28-
fi
2918

30-
pyenv --version
31-
pyenv install --skip-existing $PYENV
32-
pyenv global $PYENV
19+
# make venvs for each version we want to test
20+
rm -rf /tmp/.venv
21+
22+
IFS="," # allows iterating over csv string
23+
for CURRENT_PYENV in $PYENV; do
24+
25+
pyenv install --skip-existing $CURRENT_PYENV
26+
pyenv global $CURRENT_PYENV
27+
28+
pyenv rehash
29+
python --version
30+
pip install -q -U pip
31+
pip install -q -U virtualenv
32+
python -m venv "/tmp/.venv/${CURRENT_PYENV}" || python -m virtualenv "/tmp/.venv/${CURRENT_PYENV}"
33+
set +x
34+
source /tmp/.venv/${CURRENT_PYENV}/bin/activate
35+
set -x
36+
pip install -q -U pip
37+
set +x
38+
deactivate
39+
set -x
3340

34-
pyenv rehash
41+
done
42+
}
3543

36-
python --version
37-
rm -rf .venv
38-
pip install -U pip || true
39-
pip install -U virtualenv || true
40-
python -m venv .venv || python -m virtualenv .venv
41-
source .venv/bin/activate
42-
pip install -q -U pip
43-
pip install -q -r requirements_dev.txt
44+
45+
if [[ $WHEELPLATFORM == *"manylinux"* ]]; then
46+
echo "skipping pyenv install"
47+
else
48+
if [ -z ${PYENV+x} ]; then
49+
# This is for local testing. You can change the default to match your system.
50+
export PYENV='3.6.1'
51+
echo "PYENV is not set. Defaulting to python $PYENV."
52+
if [ ! -z ${TRAVIS_BUILD_NUMBER+x} ]; then
53+
# should not see TRAVIS_BUILD_NUMBER if this is local testing.
54+
echo "TARGET is not set but TRAVIS_BUILD_NUMBER is. Exiting with error"
55+
exit 2
56+
fi
57+
else
58+
echo "PYENV is $PYENV"
59+
fi
60+
61+
pyenv_install
62+
fi

0 commit comments

Comments
 (0)