Skip to content

Commit

Permalink
chore(workflows): set PYTHON_GIL=0 for Python 3.13t
Browse files Browse the repository at this point in the history
  • Loading branch information
XuehaiPan committed Nov 5, 2024
1 parent a045ef1 commit e79fbc0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/tests-with-pydebug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
CMAKE_BUILD_TYPE: "Debug"
OPTREE_CXX_WERROR: "ON"
PYTHON: "python" # to be updated
PYTHON_TAG: "py3" # to be updated
Expand Down Expand Up @@ -110,6 +111,7 @@ jobs:
pyenv install --list | tr -d ' ' | grep -E "^${{ matrix.python-version }}" |
grep -vF '-' | grep -E '[0-9]t$' | sort -rV | head -n 1
)"
echo "PYTHON_GIL=0" >> "${GITHUB_ENV}"
elif ! PYTHON_VERSION="$(pyenv latest --known "${{ matrix.python-version }}")"; then
PYTHON_VERSION="$(
pyenv install --list | tr -d ' ' | grep -E "^${{ matrix.python-version }}" |
Expand Down Expand Up @@ -149,19 +151,24 @@ jobs:
- name: Set up Environment
shell: bash
run: |
set -x
${{ env.PYTHON }} --version
${{ env.PYTHON }} -c 'from pprint import pprint; import sysconfig; pprint(sysconfig.get_config_vars())'
${{ env.PYTHON }} -m pip install --upgrade pip setuptools wheel
echo "::group::Upgrade pip"
${{ env.PYTHON }} -m pip install --upgrade pip setuptools wheel rich
echo "::endgroup::"
echo "::group::Python sysconfig"
${{ env.PYTHON }} -c 'import rich, sysconfig; rich.print(sysconfig.get_config_vars())'
echo "::endgroup::"
PYTHON_TAG="$(
export PYTHON_TAG="$(
echo 'import sys; print(
"{0.name[0]}p{1.major}{1.minor}{2}".format(
"{0.name[0]}p{1.major}{1.minor}".format(
sys.implementation,
sys.version_info,
getattr(sys, "abiflags", ""),
).lower(),
)' | ${{ env.PYTHON }} -
)"
)${{ matrix.python-abiflags }}"
echo "PYTHON_TAG=${PYTHON_TAG}" | tee -a "${GITHUB_ENV}"
- name: Install OpTree
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
CMAKE_BUILD_TYPE: "Debug"
OPTREE_CXX_WERROR: "ON"
FULL_TEST_PYTHON_VERSIONS: "3.10;3.11"
PYTHON: "python" # to be updated
Expand Down Expand Up @@ -72,11 +73,17 @@ jobs:
- name: Set up Environment
shell: bash
run: |
${{ env.PYTHON }} --version
${{ env.PYTHON }} -c 'from pprint import pprint; import sysconfig; pprint(sysconfig.get_config_vars())'
${{ env.PYTHON }} -m pip install --upgrade pip setuptools wheel
set -x
PYTHON_TAG="$(
${{ env.PYTHON }} --version
echo "::group::Upgrade pip"
${{ env.PYTHON }} -m pip install --upgrade pip setuptools wheel rich
echo "::endgroup::"
echo "::group::Python sysconfig"
${{ env.PYTHON }} -c 'import rich, sysconfig; rich.print(sysconfig.get_config_vars())'
echo "::endgroup::"
export PYTHON_TAG="$(
echo 'import sys; print(
"{0.name[0]}p{1.major}{1.minor}{2}".format(
sys.implementation,
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")

if(NOT DEFINED CMAKE_CXX_STANDARD AND NOT "$ENV{CMAKE_CXX_STANDARD}" STREQUAL "")
set(CMAKE_CXX_STANDARD "$ENV{CMAKE_CXX_STANDARD}")
Expand Down Expand Up @@ -76,6 +77,10 @@ if(MSVC)
" /wd5262" # use [[fallthrough]] when a break statement is intentionally omitted between cases
" /wd5264" # 'const' variable is not used
)
string(
APPEND CMAKE_CXX_FLAGS_DEBUG
" /wd4702" # unreachable code
)
string(APPEND CMAKE_CXX_FLAGS_DEBUG " /Zi")
string(APPEND CMAKE_CXX_FLAGS_RELEASE " /O2 /Ob2")
else()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def build_extension(self, ext):
build_temp = pathlib.Path(self.build_temp).absolute()
build_temp.mkdir(parents=True, exist_ok=True)

config = 'Debug' if self.debug else 'Release'
config = os.getenv('CMAKE_BUILD_TYPE', '') or ('Debug' if self.debug else 'Release')
cmake_args = [
f'-DCMAKE_BUILD_TYPE={config}',
f'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{config.upper()}={ext_path.parent}',
Expand Down

0 comments on commit e79fbc0

Please sign in to comment.