diff --git a/.github/workflows/.python-wheels-manylinux-arch.yml.kate-swp b/.github/workflows/.python-wheels-manylinux-arch.yml.kate-swp new file mode 100644 index 00000000..5b1c5c47 Binary files /dev/null and b/.github/workflows/.python-wheels-manylinux-arch.yml.kate-swp differ diff --git a/.github/workflows/python-wheels-emulated.yml b/.github/workflows/python-wheels-emulated.yml new file mode 100644 index 00000000..e3d599b5 --- /dev/null +++ b/.github/workflows/python-wheels-emulated.yml @@ -0,0 +1,113 @@ +name: Python-manylinux-arch + +on: + workflow_call: + inputs: + os: + description: 'Host OS' + required: false + type: string + default: '["ubuntu-22.04"]' + arch: + description: 'Architecture target' + required: true + type: string + +permissions: write-all + +jobs: + build_wheels: + name: Build Python wheels + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ${{ fromJSON(inputs.os) }} + env: + # Skip 32-bit windows wheels builds. + CIBW_SKIP: "*-win32* *musllinux*" + CIBW_ARCHS: ${{inputs.arch}} + CIBW_ENVIRONMENT_LINUX: "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/project/install/lib" + CIBW_BEFORE_ALL_LINUX: > + echo "Considering vtk-manylinux2014_`uname -m`.tar.gz..." && + mkdir -p vtk && + tar -xvzf vtk-manylinux2014_`uname -m`.tar.gz -C vtk/ && + if [ -d "vtk/lib" ]; then + VTK_DIR=vtk/lib/cmake/vtk-9.2/ + else + VTK_DIR=vtk/lib64/cmake/vtk-9.2/ + fi && + cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -DEXTERNAL_EIGEN:BOOL=OFF -DPYTHON_WRAPPER:BOOL=OFF -DFORTRAN_WRAPPER:BOOL=OFF -DRUST_WRAPPER:BOOL=OFF -DUSE_VTK=ON -DVTK_DIR=$VTK_DIR -DMOORDYN_PACKAGE_IGNORE_VTK_DEPENDENCY=ON -DBUILD_TESTING=OFF && + cmake --build build --config Release && + cmake --install build --config Release + CIBW_BEFORE_ALL_WINDOWS: > + cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install -DEXTERNAL_EIGEN:BOOL=OFF -DPYTHON_WRAPPER:BOOL=OFF -DFORTRAN_WRAPPER:BOOL=OFF -DRUST_WRAPPER:BOOL=OFF -DUSE_VTK=ON -DVTK_DIR=${{github.workspace}}/vtk/lib/cmake/vtk-9.2/ -DMOORDYN_PACKAGE_IGNORE_VTK_DEPENDENCY=ON -DBUILD_TESTING=OFF && + cmake --build ${{github.workspace}}/build --config Release && + cmake --install ${{github.workspace}}/build --config Release + CIBW_BEFORE_ALL_MACOS: > + cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install -DEXTERNAL_EIGEN:BOOL=OFF -DPYTHON_WRAPPER:BOOL=OFF -DFORTRAN_WRAPPER:BOOL=OFF -DRUST_WRAPPER:BOOL=OFF -DUSE_VTK=ON -DMOORDYN_PACKAGE_IGNORE_VTK_DEPENDENCY=ON -DBUILD_TESTING=OFF -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 && + cmake --build ${{github.workspace}}/build --config Release && + cmake --install ${{github.workspace}}/build --config Release + + steps: + - uses: actions/checkout@v4 + + # Used to host cibuildwheel + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Create setup.py + run: | + mv wrappers/python/wheels.github/* ./ + python set_version.py + python set_eigen_data.py + rm set_version.py set_eigen_data.py + cat pyproject.toml + shell: bash + + - name: download pre-built VTK static library (Linux) + uses: suisei-cn/actions-download-file@v1.6.0 + with: + url: https://github.com/sanguinariojoe/vtk-builds/releases/download/VTK-9.2.6-static/vtk-manylinux2014_${{inputs.arch}}.tar.gz + target: ${{github.workspace}}/ + if: runner.os == 'Linux' + + - name: download pre-built VTK static library (Windows) + uses: suisei-cn/actions-download-file@v1.6.0 + with: + url: https://github.com/sanguinariojoe/vtk-builds/releases/download/VTK-9.2.6-static/vtk-Windows-x86_64.tar.gz + target: ${{github.workspace}}/ + if: runner.os == 'Windows' + + - name: Install VTK (MacOS) + run: | + brew install vtk + if: runner.os == 'MacOS' + + - name: Create folders + run: | + mkdir -p ${{github.workspace}}/vtk + mkdir -p ${{github.workspace}}/build + mkdir -p ${{github.workspace}}/install + + - name: Extract VTK tgz (Windows) + run: | + tar -xvzf vtk-Windows-x86_64.tar.gz -C vtk/ + if: runner.os == 'Windows' + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: all + if: runner.os == 'Linux' + + - name: Build wheels + uses: pypa/cibuildwheel@v2.20.0 + with: + output-dir: dist + + - uses: actions/upload-artifact@v4 + id: build_wheels + with: + name: python-wheels-${{runner.os}}_${{inputs.arch}} + path: ./dist/* diff --git a/.github/workflows/python-wheels-manylinux-arch.yml b/.github/workflows/python-wheels-manylinux-arch.yml deleted file mode 100644 index 5afb2462..00000000 --- a/.github/workflows/python-wheels-manylinux-arch.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: Python-manylinux-arch - -on: - workflow_call: - inputs: - arch: - description: 'Architecture target' - required: true - type: string - -permissions: write-all - -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: Release - VTK_VERSION_MAJOR: 9 - VTK_VERSION_MINOR: 2 - VTK_VERSION_PATCH: 6 - -jobs: - build_wheels: - name: Build Python wheels - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-22.04] - - steps: - - uses: actions/checkout@v4 - - # Used to host cibuildwheel - - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - - name: Create setup.py - run: | - mv wrappers/python/wheels.github/* ./ - python set_version.py - python set_eigen_data.py - rm set_version.py set_eigen_data.py - shell: bash - - - name: download pre-built VTK static library - uses: suisei-cn/actions-download-file@v1.6.0 - with: - url: https://github.com/sanguinariojoe/vtk-builds/releases/download/VTK-${{env.VTK_VERSION_MAJOR}}.${{env.VTK_VERSION_MINOR}}.${{env.VTK_VERSION_PATCH}}-static/vtk-manylinux2014_${{inputs.arch}}.tar.gz - target: ${{github.workspace}}/ - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: all - - - name: Build wheels - uses: pypa/cibuildwheel@v2.20.0 - with: - output-dir: dist - env: - # configure cibuildwheel to build native archs ('auto'), and some - # emulated ones - CIBW_ARCHS_LINUX: ${{inputs.arch}} - # Skip 32-bit wheels builds as well as musllinux - CIBW_SKIP: "*-win32 *musllinux*" - CIBW_BEFORE_ALL_LINUX: > - echo "Considering vtk-manylinux2014_`uname -m`.tar.gz..." && - mkdir -p vtk && - tar -xvzf vtk-manylinux2014_`uname -m`.tar.gz -C vtk/ - - - uses: actions/upload-artifact@v4 - id: build_wheels - with: - name: python-wheels-${{inputs.arch}} - path: ./dist/* diff --git a/.github/workflows/python-wheels.yml b/.github/workflows/python-wheels.yml index ada1aae3..ce3977ef 100644 --- a/.github/workflows/python-wheels.yml +++ b/.github/workflows/python-wheels.yml @@ -19,7 +19,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04, windows-latest, macOS-latest] + os: [ubuntu-22.04] steps: - uses: actions/checkout@v4 @@ -34,97 +34,80 @@ jobs: mv wrappers/python/wheels.github/* ./ python set_version.py python set_eigen_data.py - rm set_version.py set_eigen_data.py + rm set_version.py set_eigen_data.py + cat pyproject.toml shell: bash - - name: download pre-built VTK static library (non-Linux) - uses: suisei-cn/actions-download-file@v1.6.0 - with: - url: https://github.com/sanguinariojoe/vtk-builds/releases/download/VTK-${{env.VTK_VERSION_MAJOR}}.${{env.VTK_VERSION_MINOR}}.${{env.VTK_VERSION_PATCH}}-static/vtk-${{runner.os}}-x86_64.tar.gz - target: ${{github.workspace}}/ - if: runner.os != 'Linux' - - - name: download pre-built VTK static library (Linux-x86_64) - uses: suisei-cn/actions-download-file@v1.6.0 - with: - url: https://github.com/sanguinariojoe/vtk-builds/releases/download/VTK-${{env.VTK_VERSION_MAJOR}}.${{env.VTK_VERSION_MINOR}}.${{env.VTK_VERSION_PATCH}}-static/vtk-manylinux2014_x86_64.tar.gz - target: ${{github.workspace}}/ - if: runner.os == 'Linux' - - - name: download pre-built VTK static library (Linux-i686) - uses: suisei-cn/actions-download-file@v1.6.0 - with: - url: https://github.com/sanguinariojoe/vtk-builds/releases/download/VTK-${{env.VTK_VERSION_MAJOR}}.${{env.VTK_VERSION_MINOR}}.${{env.VTK_VERSION_PATCH}}-static/vtk-manylinux2014_i686.tar.gz - target: ${{github.workspace}}/ - if: runner.os == 'Linux' - - - name: Create folders - run: | - mkdir -p ${{github.workspace}}/vtk - if: runner.os != 'Linux' - - - name: Extract VTK tgz - run: | - tar -xvzf vtk-${{runner.os}}-x86_64.tar.gz -C vtk/ - if: runner.os != 'Linux' - - name: Build the source distribution run: | python -m pip install -U pip setuptools python setup.py sdist - if: runner.os == 'Linux' - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: all - if: runner.os == 'Linux' - - - name: Build wheels - uses: pypa/cibuildwheel@v2.20.0 - with: - output-dir: dist - env: - # configure cibuildwheel to build native archs ('auto'), and some - # emulated ones - CIBW_ARCHS_LINUX: auto - # Skip 32-bit wheels builds as well as musllinux - CIBW_SKIP: "*-win32 *musllinux*" - CIBW_BEFORE_ALL_LINUX: > - echo "Considering vtk-manylinux2014_`uname -m`.tar.gz..." && - mkdir -p vtk && - tar -xvzf vtk-manylinux2014_`uname -m`.tar.gz -C vtk/ - uses: actions/upload-artifact@v4 id: build_wheels with: - name: python-wheels-${{runner.os}} + name: python-wheels-sdist path: ./dist/* - build_aarch64: - name: Build Python wheels aarch64 - uses: FloatingArrayDesign/MoorDyn/.github/workflows/python-wheels-manylinux-arch.yml@master + build_Linux_x86_64: + name: Build Linux_x86_64 + uses: FloatingArrayDesign/MoorDyn/.github/workflows/python-wheels-emulated.yml@master + with: + os: '["ubuntu-22.04"]' + arch: "x86_64" + secrets: inherit + + build_Windows_AMD64: + name: Build Windows_AMD64 + uses: FloatingArrayDesign/MoorDyn/.github/workflows/python-wheels-emulated.yml@master + with: + os: '["windows-latest"]' + arch: "AMD64" + secrets: inherit + + build_MacOS_x86_64: + name: Build MacOS_x86_64 + uses: FloatingArrayDesign/MoorDyn/.github/workflows/python-wheels-emulated.yml@master + with: + os: '["macOS-latest"]' + arch: "x86_64" + secrets: inherit + + build_Linux_i686: + name: Build Linux_i686 + uses: FloatingArrayDesign/MoorDyn/.github/workflows/python-wheels-emulated.yml@master + with: + os: '["ubuntu-22.04"]' + arch: "i686" + secrets: inherit + + build_Linux_aarch64: + name: Build Linux_aarch64 + uses: FloatingArrayDesign/MoorDyn/.github/workflows/python-wheels-emulated.yml@master with: + os: '["ubuntu-22.04"]' arch: "aarch64" secrets: inherit - build_ppc64le: - name: Build Python wheels ppc64le - uses: FloatingArrayDesign/MoorDyn/.github/workflows/python-wheels-manylinux-arch.yml@master + build_Linux_ppc64le: + name: Build Linux_ppc64le + uses: FloatingArrayDesign/MoorDyn/.github/workflows/python-wheels-emulated.yml@master with: + os: '["ubuntu-22.04"]' arch: "ppc64le" secrets: inherit - - build_s390x: - name: Build Python wheels s390x - uses: FloatingArrayDesign/MoorDyn/.github/workflows/python-wheels-manylinux-arch.yml@master + + build_Linux_s390x: + name: Build Linux_s390x + uses: FloatingArrayDesign/MoorDyn/.github/workflows/python-wheels-emulated.yml@master with: + os: '["ubuntu-22.04"]' arch: "s390x" secrets: inherit publish: runs-on: ${{ matrix.os }} - needs: [build_wheels, build_aarch64, build_ppc64le, build_s390x] + needs: [build_wheels, build_Linux_x86_64, build_Windows_AMD64, build_MacOS_x86_64, build_Linux_i686, build_Linux_aarch64, build_Linux_ppc64le, build_Linux_s390x] strategy: matrix: os: [ubuntu-22.04] @@ -132,47 +115,25 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Download Linux x86_64 dists - uses: actions/download-artifact@v4 - with: - name: python-wheels-Linux - path: dist/ - - - name: Download MacOS x86_64 dists - uses: actions/download-artifact@v4 - with: - name: python-wheels-macOS - path: dist/ - - - name: Download Windows x86_64 dists - uses: actions/download-artifact@v4 - with: - name: python-wheels-Windows - path: dist/ - - - name: Download Linux aarch64 dists - uses: actions/download-artifact@v4 - with: - name: python-wheels-aarch64 - path: dist/ - - - name: Download Linux ppc64le dists + - name: Download artifacts uses: actions/download-artifact@v4 with: - name: python-wheels-ppc64le path: dist/ + pattern: python-wheels-* + merge-multiple: true - - name: Download Linux s390x dists - uses: actions/download-artifact@v4 + - name: Publish package to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 with: - name: python-wheels-s390x - path: dist/ + password: ${{ secrets.MOORDYN_TESTPYPI_API }} + repository-url: https://test.pypi.org/legacy/ + skip-existing: true + if: github.event_name == 'push' && github.ref != 'refs/heads/main' - name: Publish package to TestPyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - # password: ${{ secrets.MOORDYN_TESTPYPI_API }} - # repository-url: https://test.pypi.org/legacy/ password: ${{ secrets.MOORDYN_PYPI_API }} repository-url: https://upload.pypi.org/legacy/ skip-existing: true + if: github.event_name == 'push' && github.ref == 'refs/heads/main' diff --git a/source/Time.hpp b/source/Time.hpp index fe06e7fa..cf2e65ba 100644 --- a/source/Time.hpp +++ b/source/Time.hpp @@ -782,9 +782,6 @@ class TimeSchemeBase : public TimeScheme */ class StationaryScheme : public TimeSchemeBase<2, 1> { - template - friend class TimeSchemeBase; - public: /** @brief Costructor * @param log Logging handler diff --git a/wrappers/python/wheels.github/setup.py b/wrappers/python/wheels.github/setup.py index f1949e56..1f9ef5c4 100644 --- a/wrappers/python/wheels.github/setup.py +++ b/wrappers/python/wheels.github/setup.py @@ -60,29 +60,13 @@ def arefiles(files): MODULE_PATH = os.path.join('wrappers', 'python', 'moordyn') MOORDYN_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'source') -MOORDYN_SRCS = get_sources('source') -MOORDYN_SRCS.append(os.path.join('wrappers', 'python', 'cmoordyn.cpp')) +MOORDYN_SRCS = [os.path.join('wrappers', 'python', 'cmoordyn.cpp')] if os.path.isdir(MODULE_PATH): # We better copy the moordyn module on the root shutil.rmtree('moordyn', ignore_errors=True) shutil.copytree(MODULE_PATH, 'moordyn') -# Get everything required to compile with VTK support -vtk_version = '9.2' -try: - vtk_version = os.environ['VTK_VERSION_MAJOR'] + "." + \ - os.environ['VTK_VERSION_MINOR'] -except KeyError: - print("$VTK_VERSION_MAJOR.$VTK_VERSION_MINOR env variables missing") -vtk_libraries = ["vtkCommonCore", "vtkIOXML", "vtkIOGeometry", - "vtkIOXMLParser", "vtkIOLegacy", "vtkIOCore", - "vtkCommonExecutionModel", "vtkCommonDataModel", - "vtkCommonTransforms", "vtkCommonMath", "vtkCommonMisc", - "vtkCommonSystem", "vtkFiltersGeneral", "vtkFiltersCore", - "vtkdoubleconversion", "vtklz4", "vtklzma", "vtkzlib", - "vtkkissfft", "vtkpugixml", "vtkexpat", "vtkloguru", "vtksys"] - # Eigen needs at least C++ 14, and Moordyn itself uses C++ 17 extra_compile_args = ["-std=c++17"] if platform.system() == "Windows": @@ -94,32 +78,18 @@ def arefiles(files): ('MOORDYN_MAJOR_VERSION', '${MOORDYN_MAJOR_VERSION}'), ('MOORDYN_MINOR_VERSION', '${MOORDYN_MINOR_VERSION}'), ('MOORDYN_PATCH_VERSION', '${MOORDYN_PATCH_VERSION}')] -include_dirs = [MOORDYN_PATH, "vtk/include/vtk-" + vtk_version] -if platform.system() == "Windows": - extra_link_args = [ - "ws2_32.lib", "dbghelp.lib", "psapi.lib", "kernel32.lib", "user32.lib", - "gdi32.lib", "winspool.lib", "shell32.lib", "ole32.lib", - "oleaut32.lib", "uuid.lib", "comdlg32.lib", "advapi32.lib"] - vtk_libs = ["vtk/lib/" + lib + "-" + vtk_version + ".lib" - for lib in vtk_libraries] -else: - extra_link_args = [] - vtk_libs = ["vtk/lib/lib" + lib + "-" + vtk_version + ".a" - for lib in vtk_libraries] - -if arefiles(vtk_libs): - extra_link_args = vtk_libs + extra_link_args - definitions = definitions + [('USE_VTK', '1'),] -else: - print("WARNING: Installing without VTK support") +include_dirs = [MOORDYN_PATH] +library_dirs = ['install/lib/', 'install/lib64/'] +libraries = ['moordyn'] cmoordyn = Extension('cmoordyn', sources=MOORDYN_SRCS, language='c++', define_macros=definitions, include_dirs=include_dirs, + library_dirs=library_dirs, + libraries=libraries, extra_compile_args=extra_compile_args, - extra_link_args=extra_link_args, ) setup(