-
Notifications
You must be signed in to change notification settings - Fork 8
Building wheels on CI #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This PR rewrites a workflow for Github Actions for building wheels on Windows, Linux, MacOS (x86-64 and arm64) and uploading it to PyPI. Since now wheels are being built for all platforms, the PR could be finally closed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really quite a nerdy work. Thanks @jncots.
I'm approving this, however I would like to ask you to update the PR description since it contains stuff unrelated to what the PR is after the many months it was in the pipeline. Also you should rename it, since it is not about Windows. The description is part of the documentation and is really important to keep track of decisions made on the way.
@HDembinski, please also have a look if this is good to go.
I added some comments, but generally this is good to go. Thanks @jncots for all this work. |
@afedynitch and @HDembinski the last 2 issues with this PR should be resolved. When PR will merge, it will try to upload built wheels on PyPI.
If the current API is fine, then after resolving these issues, chromo can be finally uploaded to PyPI. |
This is the old description of PR:There were some problems that prevented to build IMPY on Windows. CMake build system chose wrong toolchain and could not find fortran compiler. It is solved by choosing correct CMake generator. Setting environment variable CMAKE_GENERATOR=MinGW Makefiles solves the problem. On CI the action awvwgk/setup-fortran in workflow file installs gfortran that should be used. Another problem is related also to generators on Windows. cmake_ext.py contains logic for MSVC generator which adds cmake_args += ["-A", arch] which prevents CMake configuration for MinGW and CMake doesn't work. Currently it is solved by commenting the line with cmake_args += ["-A", arch]. There should be correct approach. @HDembinski, what do you think is the way to fix this? Next problem is related, probably, to restricted shell buffer for Windows. To build dpmjetIII191 CMake should execute the python script dpmjetIII191_workaround.py and to pass and accept a long list of files. On Windows there seems to be a problem with length of list. The solution to this is to pass the list of files via temporary file. CMakeLists.txt and dpmjetIII191_workaround.py are changed to a use temporary file if Windows is detected. It turned out that after successful build all library files, the files themselves are not loaded. The attempt of loading gave "ImportError: DLL load failed: The specified module could not be found.". Dependency Walker showed that the libraries depended on gfortran and gcc dlls. The problem is solved by linking these library statically. In file F2Py.cmake the line target_link_libraries(${target_name} PUBLIC "-static") is added. It adds -static string to the end of linking command. In this case the library file is little bit larger but depends only on standard dlls. Maybe there is a better way how to do that. For example add_link_options() function. I haven't tried. Anyway, all models pass tests after building, except: urqmd. It produces ImportError: DLL load failed %1 is not a valid win32 application. I will describe the problem in separate issue. Just mention here: when it is compiled withou O3 flag, the linking step produces multiple error of a kind "relocation truncated to fit: IMAGE_REL_AMD64_REL32 against". Maybe it is related to large static arrays. |
Right. I have to make a new token and register it. I will do that. @jncots and @afedynitch , please create accounts on PyPI if you haven't done so already. Tell me your account names. I will then add you as ownsers of the chromo package on PyPI, then you have full control. Update: I created the token and registered it here on Github, so upload should work now. |
It should work, see https://semver.org/ for the rules. I think 0.3.0rc1 is more appropriate, though. I am in favor of letting the package |
@HDembinski, @afedynitch I going to merge this PR in an hour, so if everything will be go smooth, chromo will uploaded on PyPI. I think introduction of |
Yes, that was my intend, I was not suggesting to add setuptools_scm to this PR. Again, great job @jncots . The solution you found for packaging shared libs will also come handy in other projects. |
The main goal of this PR is to fix the problems which appear on CI when binary wheels are built using
cibuildwheel
. The main artifact isRelease
workflow inrelease.yml
file which describes the process of building wheels and uploading them on PyPI.The following problems were solve (in the order of their solution):
Pythia8
andurqmd34
(see discussions below). So currently these models are excluded from the build. The main trick to solve the problem was adding the following lines inF2Py.cmake
file:Also there was a problem with setting correct generator in CMake and finding
gfortran
.The main problem with Linux was that in Pythia8 there are 2 files: _pythia8 and libpythia8. _pythia8 depends on libpythia8. However, during build time
_pythia8
obtained rpath, which doesn't allow to find libpythia8, if both files in the same directory. It was fixed by addingLINK_FLAGS "-Wl,-rpath...
for_pythia8
target in CMakeLists.txt.With MacOS there were 2 main problems: set correct version of
gfortran
andc++
and linking with Python library.The solution of the problem with compilers was copied from
https://github.com./numpy/numpy/tree/main/tools/wheels
.gfortran_utils.sh
script was copied from numpy to install the correct version of gfortran.The problem with Python library was finally solved in PR avoid linking to Python #126
The last problem solved which is worth to mention is the finding a wrong python version via find_package(Python). The key issue was that
cibuildwheel
uses venv but do not activate it. Because of that find_package(Python) could not find python used in virtual environment. It is solved by setting environment variable VIRTUAL_ENV in setup.py