Skip to content

Commit

Permalink
Merge pull request #13 from howetuft/work
Browse files Browse the repository at this point in the history
Python3.13
  • Loading branch information
howetuft authored Nov 16, 2024
2 parents 289552f + d313005 commit 9bb6943
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 7 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ jobs:
strategy:
fail-fast: false
matrix:
python-minor: ['8', '9', '10', '11', '12']
python-minor: ['8', '9', '10', '11', '12', '13']
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
env:
GH_TOKEN: ${{ github.token }}
CACHE: True
PYTHON_MINOR: ${{ matrix.python-minor }}

steps:

Expand All @@ -46,7 +47,6 @@ jobs:
esac
echo "WORKSPACE=${_workspace}" >> "$GITHUB_ENV"
# TODO Structure cache...
- name: Configure sccache
uses: actions/github-script@v7
with:
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
core.exportVariable('CXX', 'clang++');
core.exportVariable('CC', 'clang');
- name: All - Clean source tree
- name: Patch source tree
shell: bash
run: source $GITHUB_WORKSPACE/scripts/patch_source_tree.sh

Expand Down Expand Up @@ -157,6 +157,7 @@ jobs:
CCACHE_DIRECT
CCACHE_DEPEND
CACHE
PYTHON_MINOR
CIBW_BEFORE_ALL_LINUX: |
if [[ ${{ env.CACHE }} ]]; then
# install ccache
Expand Down
60 changes: 60 additions & 0 deletions deps/conan/boost-python/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,65 @@ def source(self):
"find_package(Python REQUIRED COMPONENTS Development.Module OPTIONAL_COMPONENTS NumPy)",
)

# Numpy >= 2.0
# https://github.com/boostorg/python/pull/432/commits/33ac06ca59a68266d3d26edf08205d31ddab4a6c
numpy2_replacement = """\
int dtype::get_itemsize() const {
#if NPY_ABI_VERSION < 0x02000000
return reinterpret_cast<PyArray_Descr*>(ptr())->elsize;
#else
return PyDataType_ELSIZE(reinterpret_cast<PyArray_Descr*>(ptr()));
#endif
}
"""
numpy2_replaced = """\
int dtype::get_itemsize() const { return reinterpret_cast<PyArray_Descr*>(ptr())->elsize;}"""
replace_in_file(
self,
os.path.join(self.source_folder, "src", "numpy", "dtype.cpp"),
numpy2_replaced,
numpy2_replacement,
)

# Another replacement for numpy >= 2.0
numpy2_replacement = """ return a == b;\n"""
# Nota: do not remove trailing space
numpy2_replaced = """\
// On Windows x64, the behaviour described on
// http://docs.scipy.org/doc/numpy/reference/c-api.array.html for
// PyArray_EquivTypes unfortunately does not extend as expected:
// "For example, on 32-bit platforms, NPY_LONG and NPY_INT are equivalent".
// This should also hold for 64-bit platforms (and does on Linux), but not
// on Windows. Implement an alternative:
#ifdef _MSC_VER
if (sizeof(long) == sizeof(int) &&
// Manually take care of the type equivalence.
((a == dtype::get_builtin<long>() || a == dtype::get_builtin<int>()) &&
(b == dtype::get_builtin<long>() || b == dtype::get_builtin<int>()) ||
(a == dtype::get_builtin<unsigned int>() || a == dtype::get_builtin<unsigned long>()) &&
(b == dtype::get_builtin<unsigned int>() || b == dtype::get_builtin<unsigned long>()))) {
return true;
} else {
return PyArray_EquivTypes(
reinterpret_cast<PyArray_Descr*>(a.ptr()),
reinterpret_cast<PyArray_Descr*>(b.ptr())
);
}
#else
return PyArray_EquivTypes(
reinterpret_cast<PyArray_Descr*>(a.ptr()),
reinterpret_cast<PyArray_Descr*>(b.ptr())
);
#endif
"""
replace_in_file(
self,
os.path.join(self.source_folder, "src", "numpy", "dtype.cpp"),
numpy2_replaced,
numpy2_replacement,
)


def requirements(self):
self.requires("zlib/[>=1.2.11 <2]")
self.requires(f"boost/{self.version}")
Expand Down Expand Up @@ -156,6 +215,7 @@ def generate(self):
# tc.cache_variables["CMAKE_FIND_DEBUG_MODE"] = True # For debugging
tc.preprocessor_definitions["BOOST_ALL_NO_LIB"] = None # No automagic linking
tc.preprocessor_definitions["BOOST_NO_CXX98_FUNCTION_BASE"] = None # No deprecated functions (C++17)
tc.preprocessor_definitions["BOOST_NO_AUTO_PTR"] = None # No auto_ptr
tc.generate()

def build(self):
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ build-backend = "scikit_build_core.build"

[project]
name = "pyluxcore"
version = "2.9a1.post3"
dependencies = ["numpy < 2.0"]
version = "2.9a1.post4"
dependencies = [
"numpy >= 2; python_version > '3.8'",
"numpy < 2; python_version <= '3.8'",
]
requires-python = ">= 3.8"
description = "LuxCore Python bindings"
authors = [{name="Howetuft"}]
Expand All @@ -22,6 +25,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Development Status :: 7 - Inactive",
"Topic :: Multimedia :: Graphics :: 3D Rendering",
]
Expand Down
6 changes: 5 additions & 1 deletion scripts/install_conan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ set -o pipefail
echo "CIBW_BEFORE_BUILD: pip"
pip install conan
pip install ninja
pip install "numpy < 2.0" &
if [[ $PYTHON_MINOR == "8" ]]; then
pip install "numpy < 2" &
else
pip install "numpy >= 2" &
fi

conan_path=$WORKSPACE/deps/conan

Expand Down
3 changes: 2 additions & 1 deletion scripts/patch_source_tree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ fi


echo "Bump version"
replace_anywhere "LUXCORE_VERSION_MINOR 6" "LUXCORE_VERSION_MINOR 9"
replace_anywhere "LUXCORE_VERSION_MINOR 6" "LUXCORE_VERSION_MINOR 9a1"
replace_anywhere "LUXRAYS_VERSION_MINOR 6" "LUXRAYS_VERSION_MINOR 9a1"


echo "Remove all local Find*.cmake"
Expand Down

0 comments on commit 9bb6943

Please sign in to comment.