Replace setuptools by scikit-build-core to build wheels.#1400
Replace setuptools by scikit-build-core to build wheels.#1400bcoconni merged 26 commits intoJSBSim-Team:masterfrom
setuptools by scikit-build-core to build wheels.#1400Conversation
…clusion/inclusion logic.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1400 +/- ##
=======================================
Coverage 25.30% 25.30%
=======================================
Files 169 169
Lines 18574 18574
=======================================
Hits 4701 4701
Misses 13873 13873 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Looks good. |
|
Merged. Thanks. Oh and by the way, you are welcome to submit better compilation flags for the Windows wheels as I am not so comfortable with the default values I have set (both the build type and compilation flags): jsbsim/python/pyproject.toml.in Lines 72 to 77 in 4a434e0 |
|
I'm assuming CMAKE includes a standard set of C++ flags for a MSVC release build in terms of optimization flags etc. and the ones you've listed above are additional flags? |
You already did this investigation 😉 and found that: Which is making me realize that the However we might want to pick a |
|
Ah, yes, thanks for reminding me 😉 Now just need to double-check the differences between I'd always been used to
So over and above the difference in terms of producing symbolic debugging information, not sure we've ever made use of it to debug an issue, there is a slight difference in aggressiveness with regards to inlining methods. I'm pretty sure all our Windows/MSVC builds in terms of JSBSim.exe and the lib built for the Python bindings have been |
Historically JSBSim has used setuptools to build everything linked to Python. But since PR #866 has been merged, the Python module is built by CMake and
setuptoolsis only used to build the Python wheels that are uploaded to PyPI.As a consequence we are using 2 build systems:
setuptoolsto build the wheels and CMake to build everything else. To avoid manual synchronization, the CMake scripts contain code to collect the source files, compilation flags and libraries to pass them tosetuptools. This makes the CMake scripts more complex than they should be.In addition, the management of compilers by
setuptoolshas an historical limitation inherited fromdistutils: all flags are passed to all compilers, both C and C++. However on MacOSX the clang C compiler has a very strict policy and rejects pure C++ flags such as the flag that requests using C++17. To work around this limitation,setup.pyhas some code that overloads some classes indistutilsto intercept the source file that is currently compiled and adapt the flags to the programming language. This is a brittle hack because it uses some undocumenteddistutilsAPI that may be modified at any time. Fortunately, this API is so obscure that the developers ofsetuptoolshave never messed with it.There is also some logic in
setup.pyto avoid building the JSBSim library if it is already existing. This logic was meant to reduce the duration of the CI job that is building all the wheels.And there is also some homemade code in
setup.pyto find and include the MSVC runtime librairies such asmsvcp140.dll(see #285 (comment) for more details about whymsvcp140.dllis included in the wheels for Windows).This PR is replacing
setuptoolsby scikit-build-core to avoid all these complexities which should reduce the maintenance burden.scikit-build-coreis a Python build backend that is using CMake to build wheels thus saving all the trouble mentioned above:setup.py.scikit-build-coreusesninja(an equivalent tomake) to compile the wheels.ninjais able to detect the files and libraries that have already been compiled and save re-compiling them again.pyproject.tomlrather than buried in the CI scripts. This should allow easier maintenance, especially as far as flags for optimization are concerned.include(InstallRequiredSystemLibraries)which is saving doing that ourselves.Below is a description of additional changes that this PR brings:
SKBUILDto detect that they have been called byscikit-build-coreand avoid compiling code that is irrelevant to the Python wheels (unit tests, aeromatic, etc.).JSBSim.pyhas been modified to be in amainfunction. This is to allow an entry point being declared inpyproject.tomlso thatJSBSim.pyis installed as a binary that can be invoked from the command line.Python-Wheelsjob no longer needs to explicitly build thelibJSBSimtarget before invokingcibuildwheel. This is now all taken care of by CMake. This also allows to avoid installing Doxygen at that stage sincecibuildwheelis now using the source distribution package that is built by theMacOSXjob and that already contains the documentation strings.CMakeis now looking for theDevelopment.Modulecomponent of Python because - according to scikit-build-core docs - "You do not want to find the entireDevelopmentpackage, as that includeEmbedcomponent, which is not always present and is not related to making Python extension modules.". As a consequence of that requirement, the minimum version of CMake is now 3.18installis now used with the targetwheel. This allows a cleaner declaration of the files that are inserted in the wheel.setup.pyandMANIFEST.inare deleted since they are no longer needed.TARGET_DIRECTORYis no longer needed in the CMake scripts. It was used to auto-discover the source files that would be passed tosetup.py.setup.py.StructureandSimgear) have been removed since they were only used to auto-discover source files forsetup.pysrc/CMakeLists.txtthat was used to store the compilation flags and libraries inJSBSIM_COMPILE_DEFINITIONSandJSBSIM_LINK_LIBRARIESand pass them tosetup.pyhas been removed.add_coverageare now guarded byif(CXXTEST_FOUND)to avoid coverage steps to be executed during the compilation of the wheels.This allows to greatly simplify the CMake files and the CI workflow and save approximately 250 lines of build scripts.