Skip to content

Commit 49d0a36

Browse files
feat: support Python 3.14 (#315)
1 parent 42e5268 commit 49d0a36

File tree

12 files changed

+478
-350
lines changed

12 files changed

+478
-350
lines changed

.kokoro/release-windows-wheel.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ set PYTHONUNBUFFERED=1
3737
set /p TWINE_PASSWORD=<%KOKORO_KEYSTORE_DIR%/73713_google-cloud-pypi-token-keystore-3
3838
call py -3 setup.py sdist || goto :error
3939
call py -3 -m twine upload --skip-existing --username __token__ --password "%TWINE_PASSWORD%" dist/* wheels/google_crc32c* || goto :error
40+
dir wheels
4041

4142
goto :EOF
4243

.kokoro/requirements.txt

Lines changed: 386 additions & 308 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ C toolchain.
99

1010
# Currently Published Wheels
1111

12-
Wheels are currently published for CPython 3.9, 3.10, 3.11, 3.12 and 3.13
12+
Wheels are currently published for CPython 3.9, 3.10, 3.11, 3.12, 3.13 and 3.14
1313
for multiple architectures. PyPy 3.9 and 3.10 are also supported for Linux.
1414
For information on building your own wheels please view [BUILDING.md](BUILDING.md).
1515

noxfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
HERE = os.path.dirname(__file__)
2626

27-
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13"])
27+
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"])
2828
def build_libcrc32c(session):
2929
session.env["PY_BIN"] = f"python{session.python}"
3030
session.env["REPO_ROOT"] = HERE
@@ -39,7 +39,7 @@ def build_libcrc32c(session):
3939
raise Exception("Unsupported")
4040

4141

42-
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13"])
42+
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"])
4343
def check(session):
4444
session.install("pytest")
4545
session.install("--no-index", f"--find-links={HERE}/wheels", "google-crc32c")

pyproject.toml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,3 @@ version = "1.7.1"
2222
description = "A python wrapper of the C library 'Google CRC32C'"
2323
readme = "README.md"
2424
requires-python = ">=3.9"
25-
license = "Apache-2.0"
26-
authors = [{ name = "Google LLC", email = "[email protected]" }]
27-
classifiers = [
28-
"Development Status :: 4 - Beta",
29-
"Intended Audience :: Developers",
30-
"Operating System :: OS Independent",
31-
"Programming Language :: Python :: 3",
32-
"Programming Language :: Python :: 3.9",
33-
"Programming Language :: Python :: 3.10",
34-
"Programming Language :: Python :: 3.11",
35-
"Programming Language :: Python :: 3.12",
36-
"Programming Language :: Python :: 3.13",
37-
]

scripts/manylinux/build_on_centos.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ if [[ -z ${BUILD_PYTHON} ]]; then
6363
elif [[ "${PYTHON_BIN}" == *"313"* && "${PYTHON_BIN}" != *"313t"* ]]; then
6464
PYTHON_VERSIONS="${PYTHON_VERSIONS} ${PYTHON_BIN}"
6565
continue
66+
elif [[ "${PYTHON_BIN}" == *"314"* && "${PYTHON_BIN}" != *"314t"* ]]; then
67+
PYTHON_VERSIONS="${PYTHON_VERSIONS} ${PYTHON_BIN}"
68+
continue
6669
else
6770
echo "Ignoring unsupported version: ${PYTHON_BIN}"
6871
echo "====================================="

scripts/manylinux/publish_python_wheel.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515

1616
set -eo pipefail
1717

18-
python3.9 -m pip install "setuptools<71"
18+
python -m pip install "setuptools<71"
1919

2020
# Start the releasetool reporter
21-
python3.9 -m pip install --require-hashes -r ${REPO_ROOT}/.kokoro/requirements.txt
22-
python3.9 -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script
21+
python -m pip install --require-hashes -r ${REPO_ROOT}/.kokoro/requirements.txt
22+
python -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script
2323

24+
ls ${REPO_ROOT}/wheels/
2425
# Disable logging
2526
set +x
2627
TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google-cloud-pypi-token-keystore-3")
27-
python3.9 -m twine upload --skip-existing --username __token__ --password "${TWINE_PASSWORD}" ${REPO_ROOT}/wheels/*
28+
python -m twine upload --skip-existing --username __token__ --password "${TWINE_PASSWORD}" ${REPO_ROOT}/wheels/*

scripts/osx/build.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,18 @@ git submodule update --init --recursive
3838

3939
${OSX_DIR}/build_c_lib.sh
4040

41-
# Build the wheel for the system Python.
42-
. /${OSX_DIR}/build_python_wheel.sh
43-
44-
# Install the wheel in a virtualenv and test it.
45-
VENV=${REPO_ROOT}/venv
46-
"python3" -m venv ${VENV}
47-
${VENV}/bin/pip install --no-index --find-links=${REPO_ROOT}/wheels google-crc32c --force-reinstall
48-
${VENV}/bin/pip install pytest
49-
${VENV}/bin/py.test ${REPO_ROOT}/tests
50-
${VENV}/bin/python ${REPO_ROOT}/scripts/check_crc32c_extension.py
51-
rm -fr ${VENV}
41+
# reinstall pyenv
42+
rm -rf /Users/kbuilder/.pyenv
43+
git clone https://github.com/pyenv/pyenv.git /Users/kbuilder/.pyenv
44+
45+
SUPPORTED_PYTHON_VERSIONS=("3.9" "3.10" "3.11" "3.12" "3.13" "3.14")
46+
47+
for PYTHON_VERSION in ${SUPPORTED_PYTHON_VERSIONS[@]}; do
48+
echo "Build wheel for Python ${PYTHON_VERSION}"
49+
export PY_BIN=$PYTHON_VERSION
50+
export PY_TAG="cp${PYTHON_VERSION//.}-cp${PYTHON_VERSION//.}"
51+
. /${OSX_DIR}/build_python_wheel.sh
52+
done
5253

5354
# Clean up.
5455
rm -fr ${CRC32C_INSTALL_PREFIX}

scripts/osx/build_python_wheel.sh

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,45 @@
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.
1857
SCRIPT_FI=$(python3 -c "import os; print(os.path.realpath('${0}'))")
@@ -21,8 +60,8 @@ SCRIPTS_DIR=$(dirname ${OSX_DIR})
2160
export 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

2766
curl 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.
51103
rm -fr ${DIST_WHEELS}

scripts/osx/publish_python_wheel.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@
1515

1616
set -eo pipefail
1717

18-
PYTHON=$(PYENV_VERSION=3.9 pyenv which python)
19-
PYTHON_BIN=$(dirname ${PYTHON})
18+
if [ -z "$(pyenv versions --bare | grep 3.8)" ]; then
19+
echo "Python 3.8 is not installed. Installing..."
20+
pyenv install 3.8
21+
fi
22+
pyenv shell 3.8
2023

21-
# Start the releasetool reporter
22-
${PYTHON} -m pip install --require-hashes -r ${REPO_ROOT}/.kokoro/requirements.txt
23-
${PYTHON} -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script
24+
python -m pip install "setuptools<71"
2425

25-
TWINE=${PYTHON_BIN}/twine
26+
# Start the releasetool reporter
27+
python -m pip install --require-hashes -r ${REPO_ROOT}/.kokoro/requirements.txt
28+
python -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script
2629

30+
ls ${REPO_ROOT}/wheels/
2731
# Disable logging
2832
set +x
2933
TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google-cloud-pypi-token-keystore-3")
30-
${PYTHON} -m twine upload --skip-existing --username __token__ --password "${TWINE_PASSWORD}" ${REPO_ROOT}/wheels/*
34+
python -m twine upload --skip-existing --username __token__ --password "${TWINE_PASSWORD}" ${REPO_ROOT}/wheels/*

0 commit comments

Comments
 (0)