mirror of
https://github.com/boostorg/python.git
synced 2026-01-19 16:32:16 +00:00
Compare commits
5 Commits
tmp
...
ft_fixes_c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ac9715633 | ||
|
|
6a9c3416f7 | ||
|
|
b44fcf142b | ||
|
|
597df1d7ba | ||
|
|
b7b0137984 |
65
.github/get-py-env.py
vendored
Executable file
65
.github/get-py-env.py
vendored
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Determine info about the Python install and write shell code to stdout, to
|
||||
# set env variables. This will set the variables PY_LDFLAGS, PY_CFLAGS and
|
||||
# PY_INC_PATH.
|
||||
#
|
||||
# The python3-config tool is used as the source of this info. In theory we
|
||||
# could use sysconfig as well but the setup-python action from github appears
|
||||
# to patch python3-config but not patch the sysconfig info.
|
||||
#
|
||||
# Usage:
|
||||
# eval $(python3 get-py-env.py)
|
||||
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
|
||||
def get_output(cmd):
|
||||
rv = subprocess.run(
|
||||
cmd,
|
||||
capture_output=True, # Capture stdout and stderr
|
||||
text=True, # Decode output as text (UTF-8)
|
||||
check=True, # Raise an error if the command fails
|
||||
)
|
||||
return rv.stdout
|
||||
|
||||
|
||||
def extract_flags(cmd, prefix):
|
||||
flags = []
|
||||
for part in get_output(cmd).split():
|
||||
part = part.strip()
|
||||
if part.startswith(prefix):
|
||||
flags.append(part)
|
||||
return ' '.join(flags)
|
||||
|
||||
|
||||
def find_python_h():
|
||||
"""Find the include path that has Python.h contained inside.
|
||||
We could use INCLUDEPY from sysconfig but github patches
|
||||
python3-config but not the sysconfig info (after moving the
|
||||
install).
|
||||
"""
|
||||
c_flags = extract_flags(['python3-config', '--cflags'], '-I')
|
||||
for part in c_flags.split():
|
||||
m = re.search(r'-I(\S+)', part)
|
||||
if not m:
|
||||
continue
|
||||
inc_path = m.group(1)
|
||||
if os.path.exists(os.path.join(inc_path, 'Python.h')):
|
||||
return inc_path
|
||||
raise SystemExit('cannot find Python.h')
|
||||
|
||||
|
||||
def main():
|
||||
ld_flags = extract_flags(['python3-config', '--ldflags'], '-L')
|
||||
c_flags = extract_flags(['python3-config', '--cflags'], '-I')
|
||||
include_path = find_python_h()
|
||||
print(f'PY_LDFLAGS="{ld_flags}"')
|
||||
print(f'PY_CFLAGS="{c_flags}"')
|
||||
print(f'PY_INC_PATH="{include_path}"')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
46
.github/run-faber.sh
vendored
Executable file
46
.github/run-faber.sh
vendored
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
echo "cxx version: $CXX $($CXX --version)"
|
||||
echo "cxx std: $CXX_STD"
|
||||
echo "python3 path: $(which python3)"
|
||||
echo "python3 version: $(python3 --version)"
|
||||
|
||||
if ! which faber > /dev/null; then
|
||||
echo "Installing faber..."
|
||||
python3 -m pip install --upgrade pip
|
||||
python3 -m pip install -U faber
|
||||
fi
|
||||
echo "faber version: $(faber -v)"
|
||||
|
||||
# find and set PY_LDFLAGS and PY_INC_PATH
|
||||
eval $(python3 .github/get-py-env.py)
|
||||
|
||||
echo "PY_INC_PATH=$PY_INC_PATH"
|
||||
echo "PY_LDFLAGS=$PY_LDFLAGS"
|
||||
|
||||
case $(python3-config --abiflags) in
|
||||
*t*)
|
||||
# When running with free-threaded, we always want to disable the GIL
|
||||
# even for extensions without the mod_gil_not_used() flag
|
||||
export PYTHON_GIL=0
|
||||
;;
|
||||
esac
|
||||
|
||||
# this could be set by LD_LIBRARY_PATH but faber overrides it
|
||||
prefix=$(python3-config --prefix)
|
||||
echo "${prefix}/lib" > /etc/ld.so.conf.d/boost-ci.conf && ldconfig
|
||||
|
||||
sed -e "s/\$PYTHON/python3/g" .ci/faber > $HOME/.faber
|
||||
|
||||
faber \
|
||||
--with-boost-include=${BOOST_PY_DEPS} \
|
||||
--builddir=build \
|
||||
cxx.name="${CXX}" \
|
||||
cxxflags="-std=${CXX_STD}" \
|
||||
cppflags="-std=${CXX_STD}" \
|
||||
include="${PY_INC_PATH}" \
|
||||
ldflags="${PY_LDFLAGS}" \
|
||||
-j`nproc` \
|
||||
"$@"
|
||||
55
.github/workflows/test-ubuntu.yml
vendored
55
.github/workflows/test-ubuntu.yml
vendored
@@ -1,6 +1,10 @@
|
||||
# Test on Ubuntu with various compiler and language standard versions.
|
||||
name: Test Ubuntu
|
||||
|
||||
on: [push, pull_request]
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -9,35 +13,52 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python: [python, python3]
|
||||
python-version: ['3.14']
|
||||
cxx: [g++, clang++]
|
||||
std: [c++11, c++14, c++17]
|
||||
include:
|
||||
# Add the appropriate docker image for each compiler.
|
||||
# The images from teeks99/boost-python-test already have boost::python
|
||||
# pre-reqs installed, see:
|
||||
# https://github.com/teeks99/boost-python-test-docker
|
||||
- cxx: clang++
|
||||
docker-img: teeks99/boost-python-test:clang-21_1.89.0
|
||||
- cxx: g++
|
||||
docker-img: teeks99/boost-python-test:gcc-15_1.89.0
|
||||
# Also test with free-threaded build of Python
|
||||
- python-version: '2.7'
|
||||
cxx: g++
|
||||
std: c++11
|
||||
- python-version: '3.14t'
|
||||
cxx: clang++
|
||||
std: c++17
|
||||
|
||||
container:
|
||||
image: ${{ matrix.docker-img }}
|
||||
# Add the appropriate docker image for the compiler.
|
||||
# The images from teeks99/boost-python-test already have boost::python
|
||||
# pre-reqs installed, see:
|
||||
# https://github.com/teeks99/boost-python-test-docker
|
||||
image: ${{ matrix.cxx == 'g++' &&
|
||||
'teeks99/boost-python-test:gcc-15_1.89.0' ||
|
||||
'teeks99/boost-python-test:clang-21_1.89.0' }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: setup python
|
||||
if: "${{ matrix.python-version != '2.7' }}"
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: setup prerequisites
|
||||
run: |
|
||||
# Warning: this is not necessarily the same Python version as the one configured above !
|
||||
python3 -m pip install -U faber --break-system-packages
|
||||
echo "CXX=${{ matrix.cxx }}" >> "$GITHUB_ENV"
|
||||
echo "CXX_STD=${{ matrix.std }}" >> "$GITHUB_ENV"
|
||||
- name: build
|
||||
if: "${{ matrix.python-version != '2.7' }}"
|
||||
run: |
|
||||
${{ matrix.python }} --version
|
||||
.github/run-faber.sh
|
||||
- name: build
|
||||
if: "${{ matrix.python-version == '2.7' }}"
|
||||
run: |
|
||||
python --version
|
||||
echo ${BOOST_PY_DEPS}
|
||||
${{ matrix.cxx }} --version
|
||||
faber -v
|
||||
sed -e "s/\$PYTHON/${{ matrix.python }}/g" .ci/faber > ~/.faber
|
||||
sed -e "s/\$PYTHON/python/g" .ci/faber > ~/.faber
|
||||
faber \
|
||||
--with-boost-include=${BOOST_PY_DEPS} \
|
||||
--builddir=build \
|
||||
@@ -46,8 +67,14 @@ jobs:
|
||||
cppflags=-std=${{ matrix.std }} \
|
||||
-j`nproc`
|
||||
- name: test
|
||||
if: "${{ matrix.python-version != '2.7' }}"
|
||||
run: |
|
||||
.github/run-faber.sh test.report
|
||||
- name: test
|
||||
if: "${{ matrix.python-version == '2.7' }}"
|
||||
run: |
|
||||
faber \
|
||||
--debug \
|
||||
--with-boost-include=${BOOST_PY_DEPS} \
|
||||
--builddir=build \
|
||||
cxx.name=${{ matrix.cxx }} \
|
||||
|
||||
Reference in New Issue
Block a user