From 04ceb2b2c458cc1483dbeab47c7496f302e74983 Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Sun, 15 Dec 2024 13:17:45 +0100 Subject: [PATCH 1/4] Only apply changes in C standard and intergers.h.in --- CMakeLists.txt | 9 +++++++-- src/utils/integers.h.in | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97cd40abc..359ad0b03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,8 +70,13 @@ option(WITH_STATIC_PYTHON "Whether to compile with static python libraries" NO) # Append our cmake-modules to CMAKE_MODULE_PATH list(APPEND CMAKE_MODULE_PATH ${dlite_SOURCE_DIR}/cmake) -# Enable C99 -set(CMAKE_C_STANDARD 99) +# Select C standard to be consistent with Python. Default to c11 +if(WIN32 OR (PYTHON_VERSION AND PYTHON_VERSION VERSION_LESS "3.11")) + set(CMAKE_C_STANDARD 99) +else() + set(CMAKE_C_STANDARD 11) +endif() +message(STATUS "CMAKE_C_STANDARD=${CMAKE_C_STANDARD}") # Set default cmake configurations include(SetDefaults) diff --git a/src/utils/integers.h.in b/src/utils/integers.h.in index 4a96090db..ab7ccf552 100644 --- a/src/utils/integers.h.in +++ b/src/utils/integers.h.in @@ -41,14 +41,30 @@ #cmakedefine HAVE_STDINT_H #endif +#ifndef HAVE_UINT8_T #cmakedefine HAVE_UINT8_T +#endif +#ifndef HAVE_UINT16_T #cmakedefine HAVE_UINT16_T +#endif +#ifndef HAVE_UINT32_T #cmakedefine HAVE_UINT32_T +#endif +#ifndef HAVE_UINT64_T #cmakedefine HAVE_UINT64_T +#endif +#ifndef HAVE_UINT128_T #cmakedefine HAVE_UINT128_T +#endif +#ifndef HAVE___UINT128_T #cmakedefine HAVE___UINT128_T +#endif +#ifndef HAVE_INT128_T #cmakedefine HAVE_INT128_T +#endif +#ifndef HAVE___INT128_T #cmakedefine HAVE___INT128_T +#endif #cmakedefine HAVE_LONG_LONG #cmakedefine HAVE_INTMAX_T From 3cbe0bb98bb98cb8772a392a06fb2e9f66ec22c3 Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Sun, 15 Dec 2024 13:40:16 +0100 Subject: [PATCH 2/4] Build wheels with numpy==2.0.2 to avoid problems with PyMutex_Unlock being undefined --- doc/contributors_guide/tips_and_tricks.md | 7 +++---- python/pyproject.toml | 7 +++---- requirements.txt | 3 ++- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/doc/contributors_guide/tips_and_tricks.md b/doc/contributors_guide/tips_and_tricks.md index 971653f14..bec06f1f6 100644 --- a/doc/contributors_guide/tips_and_tricks.md +++ b/doc/contributors_guide/tips_and_tricks.md @@ -21,16 +21,15 @@ This can be done as follows: 2. Build the wheel - cd python - python setup.py bdist_wheel + cd dlite # root of source directory + pip wheel -w python/dist ./python 3. Install the wheel with pip in a newly created environment (the version numbers may differ for your case) - pip install dist/DLite_Python-0.5.22-cp311-cp311-linux_x86_64.whl + pip install python/dist/DLite_Python-0.5.26-cp311-cp311-linux_x86_64.whl 4. Finally, test by importing dlite in the standard manner - cd .. python >>> import dlite diff --git a/python/pyproject.toml b/python/pyproject.toml index afd048a52..49bbb374b 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,10 +1,9 @@ [build-system] requires = [ - "numpy>=1.14.5,<2.1.3", + # numpy>=2.1.0 fails with with "undefined symbol: PyMutex_Unlock" on Python 3.13 + "numpy==2.0.2", "swig==4.3.0", "cmake==3.31.1", - #"setuptools==57.5.0; python_version<'3.9'", - #"setuptools==75.3.0; python_version>='3.9'", "setuptools==75.3.0", "wheel==0.41.3", ] @@ -15,7 +14,7 @@ build-frontend = "pip" build-verbosity = 1 [tool.cibuildwheel.windows] -before-test = "python -m pip install -r {project}\\requirements.txt -r {project}\\requirements_dev.txt" +before-test = "python -m pip install -r {project}\\requirements_dev.txt" test-command = "python {package}\\..\\bindings\\python\\tests\\test_python_bindings.py" [tool.cibuildwheel.linux] diff --git a/requirements.txt b/requirements.txt index 99617567c..1e42d623e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -numpy>=1.14.5,<2.1.3 +numpy>=1.14.5 +numpy<2.1.0; python_version>='3.13' From a576d9f74b93d3f7cbbf6835bc0d4011a56ba632 Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Sun, 15 Dec 2024 13:46:50 +0100 Subject: [PATCH 3/4] Relax version of numpy to build against since it depends heavily on Python version --- python/pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index 49bbb374b..c09ebd81d 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,7 +1,8 @@ [build-system] requires = [ # numpy>=2.1.0 fails with with "undefined symbol: PyMutex_Unlock" on Python 3.13 - "numpy==2.0.2", + "numpy>=1.14.5", + "numpy<2.1.0; python_version>='3.13'", "swig==4.3.0", "cmake==3.31.1", "setuptools==75.3.0", From 269adbd899a2a16ebf40517b079412779cd1106a Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Sun, 15 Dec 2024 14:35:23 +0100 Subject: [PATCH 4/4] Ensure that windows also gets requirements.txt for testing --- python/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index c09ebd81d..900f3cffb 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -15,7 +15,7 @@ build-frontend = "pip" build-verbosity = 1 [tool.cibuildwheel.windows] -before-test = "python -m pip install -r {project}\\requirements_dev.txt" +before-test = "python -m pip install -r {project}\\requirements.txt -r {project}\\requirements_dev.txt" test-command = "python {package}\\..\\bindings\\python\\tests\\test_python_bindings.py" [tool.cibuildwheel.linux]