Skip to content

MNT use conda-forge for the pypy build on circle ci #18867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Nov 19, 2020
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,14 @@ jobs:

pypy3:
docker:
- image: pypy:3.6-7.2.0
- image: condaforge/miniforge3
steps:
- restore_cache:
keys:
- pypy3-ccache-{{ .Branch }}
- pypy3-ccache
- checkout
- run: conda init bash && source ~/.bashrc
- run: ./build_tools/circle/build_test_pypy.sh
- save_cache:
key: pypy3-ccache-{{ .Branch }}-{{ .BuildNum }}
Expand Down
44 changes: 16 additions & 28 deletions build_tools/circle/build_test_pypy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,28 @@
set -x
set -e

# System build tools
apt-get -yq update
apt-get -yq install libatlas-base-dev liblapack-dev gfortran ccache libopenblas-dev
apt-get -yq install wget bzip2 build-essential ccache

pip install virtualenv
# Install pypy and all the scikit-learn dependencies from conda-forge. In
# particular, we want to install pypy compatible binary packages for numpy and
# scipy as it would be to costly to build those from source.
conda install -y mamba
mamba create -n pypy -y \
pypy numpy scipy cython \
joblib threadpoolctl pillow pytest \
sphinx numpydoc docutils

if command -v pypy3; then
virtualenv -p $(command -v pypy3) pypy-env
elif command -v pypy; then
virtualenv -p $(command -v pypy) pypy-env
fi

source pypy-env/bin/activate
eval "$(conda shell.bash hook)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting conda require quite a few steps..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that was really hell. circle ci must also be doing something weird when passing the bash commands to execute in the container because some setups that would work in my local docker would not work on circle ci. And I could never get micromamba setup to work at all on circle ci (while it would work well and fast in my local setup).

conda activate pypy

# Check that we are running PyPy instead of CPython in this environment.
python --version
which python
python -c "import platform; assert platform.python_implementation() == 'PyPy'"

pip install -U pip

# pins versions to install wheel from https://antocuni.github.io/pypy-wheels/manylinux2010
pip install --extra-index-url https://antocuni.github.io/pypy-wheels/manylinux2010 numpy==1.18.0 scipy==1.3.2

# Install Cython directly
pip install https://antocuni.github.io/pypy-wheels/ubuntu/Cython/Cython-0.29.14-py3-none-any.whl
pip install sphinx numpydoc docutils joblib pillow pytest

# Build and install scikit-learn in dev mode
ccache -M 512M
export CCACHE_COMPRESS=1
export PATH=/usr/lib/ccache:$PATH
Expand All @@ -35,17 +32,8 @@ export OMP_NUM_THREADS="1"
# Set parallelism to 3 to overlap IO bound tasks with CPU bound tasks on CI
# workers with 2 cores when building the compiled extensions of scikit-learn.
export SKLEARN_BUILD_PARALLEL=3

# Build and install scikit-learn in dev mode
pip install --no-build-isolation -e .

# Check that Python implementation is PyPy
python - << EOL
import platform
from sklearn.utils import IS_PYPY
assert IS_PYPY is True, "platform={}!=PyPy".format(platform.python_implementation())
EOL

python -m pytest sklearn/
python -m pytest sklearn
python -m pytest doc/sphinxext/
python -m pytest $(find doc -name '*.rst' | sort)