Skip to content

Commit 4a434e0

Browse files
authored
Replace setuptools by scikit-build-core to build wheels. (#1400)
1 parent 0238e96 commit 4a434e0

25 files changed

Lines changed: 465 additions & 716 deletions

File tree

.github/workflows/cpp-python-build.yml

Lines changed: 22 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,6 @@ jobs:
375375
build/src/RelWithDebInfo/JSBSim.lib
376376
build/src/RelWithDebInfo/JSBSim.exe
377377
build/utils/aeromatic++/RelWithDebInfo/aeromatic.exe
378-
build/python/setup.py
379378
MSVC_version.txt
380379
381380
Windows-installer:
@@ -497,18 +496,10 @@ jobs:
497496
working-directory: build
498497
run: ctest --parallel $(sysctl -n hw.logicalcpu) --output-on-failure
499498
- name: Build the source package for Python
500-
if: env.release == 'true'
501-
working-directory: build/python
502499
run: |
503-
echo "::group::Generate the type hints stub"
504-
python ../../python/pyxstubgen.py --pyxfile=_jsbsim.pyx --output=jsbsim/_jsbsim.pyi
505-
touch jsbsim/py.typed
506-
echo "::endgroup::"
507-
508-
echo "::group::Build the source package"
509-
rm -f _jsbsim.cxx # Make sure that jsbsim.cxx is not stored in the source distribution
500+
python python/pyxstubgen.py --pyxfile=build/python/_jsbsim.pyx --output=python/_jsbsim.pyi
501+
cp build/python/pyproject.toml .
510502
python -m build --sdist
511-
echo "::endgroup::"
512503
- name: Check reset for real time execution
513504
run: |
514505
start_time=$(date +%s)
@@ -532,16 +523,12 @@ jobs:
532523
533524
- name: Upload Files for Release
534525
uses: actions/upload-artifact@v7
535-
if: env.release == 'true'
536526
with:
537527
name: ${{ runner.os }}.binaries
538528
path: |
539-
build/src/libJSBSim.a
540-
build/python/setup.py
541-
build/python/dist/*.tar.gz
529+
dist/*.tar.gz
542530
543531
Test-Build-PyPackage-From-Source:
544-
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))
545532
name: Build Python Module from Source
546533
needs: MacOSX
547534
strategy:
@@ -560,14 +547,9 @@ jobs:
560547
uses: actions/download-artifact@v8
561548
with:
562549
name: macOS.binaries
563-
- name: Build Python module from sources (Linux & MacOSX)
564-
if: runner.os != 'Windows'
565-
run: pip install python/dist/*.tar.gz -vv
566-
- name: Build Python module from sources (Windows)
567-
if: runner.os == 'Windows'
568-
run: |
569-
$PyPackage = Get-ChildItem -Path python\dist -Filter *.tar.gz | Select-Object -First 1
570-
pip install $PyPackage.FullName -vv
550+
- name: Build Python module from sources
551+
shell: bash
552+
run: pip install *.tar.gz -vv
571553
- name: Test Python module
572554
shell: python
573555
run: |
@@ -582,6 +564,8 @@ jobs:
582564
run: |
583565
echo "import jsbsim" > test.py
584566
mypy test.py
567+
- name: Test JSBSim.py script
568+
run: jsbsim --help
585569

586570
Python-Wheels:
587571
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
@@ -596,83 +580,32 @@ jobs:
596580
steps:
597581
- name: Checkout JSBSim
598582
uses: actions/checkout@v6
599-
- name: Set up Python 3.10
600-
uses: actions/setup-python@v6
601-
with:
602-
python-version: '3.10'
603-
- name: Install Python packages
604-
run: pip install -U cython 'numpy>=1.20' mypy
605-
- name: Install Doxygen (Linux)
606-
if: matrix.os == 'ubuntu-latest'
607-
run: |
608-
sudo apt-get update
609-
sudo apt-get install doxygen
610-
- name: Install Doxygen (MacOSX)
611-
if: matrix.os == 'macos-14'
612-
run: brew install doxygen
613-
- name: Install Doxygen (Windows)
614-
if: runner.os == 'Windows'
615-
run: choco install doxygen.install
616-
- name: Configure Doxygen
617-
run: |
618-
# We don't want Doxygen to generate the HTML docs in this job (saves time)
619-
# Set GENERATE_HTML and HAVE_DOT to NO
620-
perl -i -pe 's/^(GENERATE_HTML\s*=\s*)YES/\1NO/g' doc/JSBSim.dox.in
621-
perl -i -pe 's/^(HAVE_DOT\s*=\s*)YES/\1NO/g' doc/JSBSim.dox.in
622583
- name: Download source package
623584
uses: actions/download-artifact@v8
624585
with:
625586
name: macOS.binaries
626-
- name: Configure JSBSim (BSD/Unix)
627-
if: runner.os != 'Windows'
587+
- name: Identify the source distribution
588+
shell: bash
628589
run: |
629-
echo "::group::Run CMake"
630-
mkdir build && cd build
631-
cmake ..
632-
echo "::endgroup::"
633-
634-
echo "::group::Get Python package sources"
635-
touch python/jsbsim/py.typed
636-
cd ../python/dist
637-
tar zxvf *.tar.gz
638-
cp -R jsbsim-*/jsbsim/*.pyi ../../build/python/jsbsim/.
639-
echo "::endgroup::"
640-
- name: Configure JSBSim (Windows)
641-
if: runner.os == 'Windows'
642-
run: |
643-
echo "::group::Run CMake"
644-
New-Item -Path .\build -ItemType Directory -Force
645-
cd build
646-
cmake ..
647-
cmake --build . --target libJSBSim --config RelWithDebInfo --parallel $Env:NUMBER_OF_PROCESSORS
648-
echo "::endgroup::"
649-
650-
echo "::group::Get Python package sources"
651-
New-Item python\jsbsim\py.typed
652-
cd ..\python\dist
653-
$PyPackage = Get-ChildItem .\*.tar.gz -Name
654-
tar zxvf $PyPackage
655-
Copy-Item -Path .\JSBSim-*\jsbsim\*.pyi -Destination ..\..\build\python\jsbsim
656-
echo "::endgroup::"
590+
SDIST_PATH=$(ls jsbsim-*.tar.gz | head -n 1)
591+
echo "SDIST_PATH=$SDIST_PATH" >> $GITHUB_ENV
657592
- name: Build wheels
658593
uses: pypa/cibuildwheel@v3.3
659594
env:
660-
CIBW_BEFORE_ALL_LINUX: |
661-
cd build
662-
rm -f CMakeCache.txt
663-
cmake -DCMAKE_C_FLAGS_RELEASE="-g -O2 -DNDEBUG -fno-math-errno" -DCMAKE_CXX_FLAGS_RELEASE="-g -O2 -DNDEBUG -fno-math-errno" -DCMAKE_BUILD_TYPE=Release ..
664-
cmake --build . --target libJSBSim --parallel $(nproc)
665-
CIBW_BEFORE_ALL_MACOS: |
666-
cd build
667-
rm -f CMakeCache.txt
668-
cmake -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_C_FLAGS_RELEASE="-g -O2 -DNDEBUG -fno-math-errno -fno-fast-math" -DCMAKE_CXX_FLAGS_RELEASE="-g -O2 -DNDEBUG -fno-math-errno -fno-fast-math" -DCMAKE_BUILD_TYPE=Release ..
669-
cmake --build . --target libJSBSim --parallel $(sysctl -n hw.logicalcpu)
670595
CIBW_ARCHS_MACOS: universal2
671596
CIBW_SKIP: cp*-musllinux_*
672597
CIBW_ARCHS_WINDOWS: native
673-
JSBSIM_BUILD_CONFIG: RelWithDebInfo
598+
# Force the buid directory to allow reusing compiled files.
599+
CIBW_CONFIG_SETTINGS_LINUX: "build-dir=${{ runner.temp }}/jsbsim_build_cache"
600+
SKBUILD_BUILD_DIR: "${{ runner.temp }}/jsbsim_build_cache"
601+
with:
602+
package-dir: ${{ env.SDIST_PATH }}
603+
- name: Set up Python 3.10
604+
uses: actions/setup-python@v6
674605
with:
675-
package-dir: build/python
606+
python-version: '3.10'
607+
- name: Install Python packages
608+
run: pip install -U 'numpy>=1.20' mypy
676609
- name: Test wheel package
677610
run: |
678611
echo "::group::Test module execution"
@@ -733,7 +666,6 @@ jobs:
733666
run: |
734667
mkdir dist
735668
find . -type f -name *.exe -exec cp {} dist/. \;
736-
find . -type f -name *.whl -exec cp {} dist/. \;
737669
find . -type f -name *.deb -exec cp {} dist/. \;
738670
- name: Rolling release
739671
uses: softprops/action-gh-release@v2
@@ -748,7 +680,6 @@ jobs:
748680
(branch ${{ github.ref }} commit ${{ github.sha}})
749681
files: |
750682
dist/*.exe
751-
dist/*.whl
752683
dist/*.deb
753684
754685
Stable-Release:

CMakeLists.txt

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required (VERSION 3.15)
1+
cmake_minimum_required (VERSION 3.18)
22

33
################################################################################
44
# Project description #
@@ -28,14 +28,20 @@ function(get_tail INPUT_STRING OUTPUT_STRING SEPARATOR)
2828
set(${OUTPUT_STRING} ${TAIL} PARENT_SCOPE)
2929
endfunction()
3030

31-
find_package(PkgConfig)
31+
if(NOT SKBUILD)
32+
find_package(PkgConfig)
33+
find_package(CxxTest)
34+
endif(NOT SKBUILD)
3235

3336
################################################################################
3437
# Build JSBSim libs and exec #
3538
################################################################################
3639

37-
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/tests/unit_tests/CMakeModules)
38-
find_package(codecov)
40+
if(CXXTEST_FOUND)
41+
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/tests/unit_tests/CMakeModules)
42+
find_package(codecov)
43+
endif(CXXTEST_FOUND)
44+
3945
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
4046
add_subdirectory(src)
4147

@@ -72,16 +78,18 @@ option(INSTALL_JSBSIM_PYTHON_MODULE "Set to ON to install the Python module for
7278
if (BUILD_PYTHON_MODULE)
7379
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/python/CMakeModules)
7480
cmake_policy(SET CMP0094 NEW) # makes FindPython3 prefer activated virtualenv Python to the latest version
75-
find_package(Python3 COMPONENTS Interpreter Development)
81+
find_package(Python3 COMPONENTS Interpreter Development.Module)
7682
find_package(Cython)
7783

7884
if (CYTHON_FOUND)
79-
if (Python3_Development_FOUND)
80-
enable_testing()
81-
add_subdirectory(tests)
85+
if (Python3_Development.Module_FOUND)
86+
if (NOT SKBUILD)
87+
enable_testing()
88+
add_subdirectory(tests)
89+
endif(NOT SKBUILD)
8290
add_subdirectory(python)
83-
endif(Python3_Development_FOUND)
84-
elseif(NOT Python3_Development_FOUND)
91+
endif(Python3_Development.Module_FOUND)
92+
elseif(NOT Python3_Development.Module_FOUND)
8593
message(WARNING "JSBSim Python module and test suite will not be built")
8694
endif(CYTHON_FOUND)
8795
endif(BUILD_PYTHON_MODULE)
@@ -111,8 +119,6 @@ endif(BUILD_MATLAB_SFUNCTION)
111119
# Build the unit tests (needs CxxTest) #
112120
################################################################################
113121

114-
find_package(CxxTest)
115-
116122
if (CXXTEST_FOUND)
117123
enable_testing()
118124
add_subdirectory(tests/unit_tests)
@@ -243,7 +249,7 @@ endif()
243249
# Windows installer #
244250
################################################################################
245251

246-
if(WIN32)
252+
if(WIN32 AND NOT SKBUILD)
247253
configure_file(${PROJECT_SOURCE_DIR}/JSBSim.iss.in JSBSim.iss)
248254
endif()
249255

@@ -277,12 +283,17 @@ set(CPACK_SOURCE_IGNORE_FILES "${CMAKE_BINARY_DIR}/"
277283
"/CVS/"
278284
"TAGS"
279285
"${CPACK_SOURCE_IGNORE_FILES}")
280-
include (CPack)
286+
if(NOT SKBUILD)
287+
set(CPACK_COMPONENTS_ALL "devel" "pymodules" "runtime")
288+
include (CPack)
289+
endif(NOT SKBUILD)
281290

282291
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
283292

284293
################################################################################
285294
# Build the utilities #
286295
################################################################################
287296

288-
add_subdirectory(utils)
297+
if(NOT SKBUILD)
298+
add_subdirectory(utils)
299+
endif(NOT SKBUILD)

0 commit comments

Comments
 (0)