Skip to content

Commit

Permalink
Python 3.13t changes required to build python 3.13t wheel (#2001)
Browse files Browse the repository at this point in the history
* Update build_common.sh

Update build_common.sh

Update build_common.sh

Update build_common.sh

Update check_binary.sh

Update check_binary.sh

Update check_binary_symbols.py

Update check_binary.sh

Update check_binary_symbols.py

* test

* fix
  • Loading branch information
atalman authored Oct 2, 2024
1 parent e3219c4 commit 9452ae2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
12 changes: 8 additions & 4 deletions check_binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,20 @@ fi
# All MacOS packages use conda, even for the wheel packages.
if [[ "$PACKAGE_TYPE" == libtorch ]]; then
# NOTE: Only $PWD works on both CentOS and Ubuntu
install_root="$PWD"
export install_root="$PWD"
else
# Strip everything but major.minor from DESIRED_PYTHON version
if [[ $DESIRED_PYTHON =~ ([0-9].[0-9]+) ]]; then

if [[ $DESIRED_PYTHON =~ ([0-9].[0-9]+)t ]]; then
# For python that is maj.mint keep original version
py_dot="$DESIRED_PYTHON"
elif [[ $DESIRED_PYTHON =~ ([0-9].[0-9]+) ]]; then
# Strip everything but major.minor from DESIRED_PYTHON version
py_dot="${BASH_REMATCH[0]}"
else
echo "Unexpected ${DESIRED_PYTHON} format"
exit 1
fi
install_root="$(dirname $(which python))/../lib/python${py_dot}/site-packages/torch/"
export install_root="$(dirname $(which python))/../lib/python${py_dot}/site-packages/torch/"
fi

###############################################################################
Expand Down
20 changes: 11 additions & 9 deletions manywheel/build_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,20 @@ fi
# expect. The binary CI jobs pass in python versions like this; they also only
# ever pass one python version, so we assume that DESIRED_PYTHON is not a list
# in this case
if [[ -n "$DESIRED_PYTHON" && "$DESIRED_PYTHON" != cp* ]]; then
if [[ -n "$DESIRED_PYTHON" && $DESIRED_PYTHON =~ ([0-9].[0-9]+)t ]]; then
python_digits="$(echo $DESIRED_PYTHON | tr -cd [:digit:])"
py_majmin="${DESIRED_PYTHON}"
DESIRED_PYTHON="cp${python_digits}-cp${python_digits}t"
elif [[ -n "$DESIRED_PYTHON" && "$DESIRED_PYTHON" != cp* ]]; then
python_nodot="$(echo $DESIRED_PYTHON | tr -d m.u)"
DESIRED_PYTHON="cp${python_nodot}-cp${python_nodot}"
if [[ ${python_nodot} -ge 310 ]]; then
py_majmin="${DESIRED_PYTHON:2:1}.${DESIRED_PYTHON:3:2}"
else
py_majmin="${DESIRED_PYTHON:2:1}.${DESIRED_PYTHON:3:1}"
fi
fi

if [[ ${python_nodot} -ge 310 ]]; then
py_majmin="${DESIRED_PYTHON:2:1}.${DESIRED_PYTHON:3:2}"
else
py_majmin="${DESIRED_PYTHON:2:1}.${DESIRED_PYTHON:3:1}"
fi


pydir="/opt/python/$DESIRED_PYTHON"
export PATH="$pydir/bin:$PATH"
echo "Will build for Python version: ${DESIRED_PYTHON} with ${python_installation}"
Expand Down Expand Up @@ -125,7 +127,7 @@ case ${DESIRED_PYTHON} in
retry pip install -q numpy==1.15
;;
cp31*)
retry pip install -q --pre numpy==2.0.2
retry pip install -q --pre numpy==2.1.0
;;
# Should catch 3.9+
*)
Expand Down
10 changes: 7 additions & 3 deletions test/check_binary_symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,14 @@ def check_lib_symbols_for_abi_correctness(lib: str, pre_cxx11_abi: bool = True)
raise RuntimeError("Didn't find enought cxx11 symbols")

def main() -> None:
if os.getenv("PACKAGE_TYPE") == "libtorch":
install_root = Path(os.getcwd())
if "install_root" in os.environ:
install_root = Path(os.getenv("install_root"))
else:
install_root = Path(distutils.sysconfig.get_python_lib()) / "torch"
if os.getenv("PACKAGE_TYPE") == "libtorch":
install_root = Path(os.getcwd())
else:
install_root = Path(distutils.sysconfig.get_python_lib()) / "torch"

libtorch_cpu_path = install_root / "lib" / "libtorch_cpu.so"
pre_cxx11_abi = "cxx11-abi" not in os.getenv("DESIRED_DEVTOOLSET", "")
check_lib_symbols_for_abi_correctness(libtorch_cpu_path, pre_cxx11_abi)
Expand Down

0 comments on commit 9452ae2

Please sign in to comment.