1313# See the License for the specific language governing permissions and
1414# limitations under the License.
1515
16+ # Build a **single** Python wheel for a specified version. The version and
17+ # associated paths should be set as environment variables; the expected
18+ # environment variables will be verified below.
19+
20+ set -e -x
21+
22+ # Check that the REPO_ROOT, PY_BIN and PY_TAG environment variables are set.
23+ if [[ -z " ${REPO_ROOT} " ]]; then
24+ echo " REPO_ROOT environment variable should be set by the caller."
25+ exit 1
26+ fi
27+ if [[ -z " ${PY_BIN} " ]]; then
28+ echo " PY_BIN environment variable should be set by the caller."
29+ exit 1
30+ fi
31+ if [[ -z " ${PY_TAG} " ]]; then
32+ echo " PY_TAG environment variable should be set by the caller."
33+ exit 1
34+ fi
35+
36+ # set up pyenv & shell environment for switching across python versions
37+ eval " $( pyenv init -) "
38+ eval " $( pyenv init --path) "
39+
40+ install_python_pyenv () {
41+ version=$1
42+
43+ if [ -z " $( pyenv versions --bare | grep $version ) " ]; then
44+ echo " Python $version is not installed. Installing..."
45+ pyenv install $version
46+ echo " Python $version installed."
47+ else
48+ echo " Python $version is already installed."
49+ fi
50+ pyenv shell $version
51+ }
52+ install_python_pyenv ${PY_BIN}
53+
54+
1655# ``readlink -f`` is not our friend on OS X. This relies on **some**
1756# ``python`` being installed.
1857SCRIPT_FI=$( python3 -c " import os; print(os.path.realpath('${0} '))" )
@@ -21,8 +60,8 @@ SCRIPTS_DIR=$(dirname ${OSX_DIR})
2160export REPO_ROOT=$( dirname ${SCRIPTS_DIR} )
2261
2362# Create a virtualenv where we can install Python build dependencies.
24- VENV=${REPO_ROOT} /venv_build
25- " python3 " -m venv ${VENV}
63+ VENV=${REPO_ROOT} /venv ${PY_BIN}
64+ " python ${PY_BIN} " -m venv ${VENV}
2665
2766curl https://bootstrap.pypa.io/get-pip.py | ${VENV} /bin/python
2867${VENV} /bin/python -m pip install \
@@ -45,7 +84,20 @@ ${VENV}/bin/delocate-wheel \
4584 --wheel-dir ${FIXED_WHEELS} \
4685 --verbose \
4786 --check-archs \
48- ${DIST_WHEELS} /google_crc32c* .whl
87+ ${DIST_WHEELS} /google_crc32c* ${PY_TAG} * .whl
88+
89+ if [[ " ${PUBLISH_WHEELS} " == " true" ]]; then
90+ . /${OSX_DIR} /publish_python_wheel.sh
91+ fi
92+
93+ # test wheel
94+ ${VENV} /bin/pip install \
95+ --no-index --find-links=${REPO_ROOT} /wheels google-crc32c --force-reinstall
96+ ${VENV} /bin/pip install pytest
97+ ${VENV} /bin/py.test ${REPO_ROOT} /tests
98+ ${VENV} /bin/python ${REPO_ROOT} /scripts/check_crc32c_extension.py
99+
100+ ls ${REPO_ROOT} /wheels/
49101
50102# Clean up.
51103rm -fr ${DIST_WHEELS}
0 commit comments