From 153d848b1713803bd3c60790ad1158743d6d5c12 Mon Sep 17 00:00:00 2001 From: RobPasMue Date: Mon, 1 Aug 2022 18:39:26 +0200 Subject: [PATCH 01/18] Reactivating macOS workflow --- .github/workflows/testing-and-deployment.yml | 111 ++++++++++--------- 1 file changed, 56 insertions(+), 55 deletions(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index ca6623a6..54b69036 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Python uses: actions/setup-python@v2 with: @@ -39,7 +39,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Python uses: actions/setup-python@v2 @@ -71,7 +71,7 @@ jobs: zip ../../../${{ env.PACKAGE_NAME }}-HTML.zip ./* - name: Upload - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: ${{ env.PACKAGE_NAME }}-Documentation path: | @@ -97,7 +97,7 @@ jobs: os: [ubuntu-latest, windows-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v1 @@ -105,7 +105,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Linux pip cache - uses: actions/cache@v2 + uses: actions/cache@v3 if: ${{ runner.os == 'Linux' }} with: path: ~/.cache/pip @@ -114,7 +114,7 @@ jobs: Python-${{ runner.os }}-${{ matrix.python-version }} - name: Window pip cache - uses: actions/cache@v2 + uses: actions/cache@v3 if: ${{ runner.os == 'Windows' }} with: path: ~\AppData\Local\pip\Cache @@ -167,7 +167,7 @@ jobs: - name: Get PyVista tools if: ${{ runner.os == 'Windows' }} - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: pyvista/gl-ci-helpers path: pyvista-tools @@ -204,59 +204,60 @@ jobs: name: 'Upload coverage to Codecov' - name: Upload wheel - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: ${{ env.PACKAGE_NAME }}-${{ runner.os }}-${{ matrix.python-version }} path: dist/ retention-days: 7 - # mac_build: - # runs-on: macos-latest - # name: Mac OS Unit Testing - # strategy: - # matrix: - # python-version: ['3.8'] - - # steps: - # - uses: actions/checkout@v2 - - # - name: Set up Python ${{ matrix.python-version }} - # uses: actions/setup-python@v1 - # with: - # python-version: ${{ matrix.python-version }} - - # - name: Build wheels - # uses: joerick/cibuildwheel@v2.0.1 - # env: - # CIBW_BEFORE_BUILD: pip install -r requirements_build.txt - # CIBW_BUILD: cp38-macosx_x86_64 - - # - name: Build wheels - # if: startsWith(github.event.ref, 'refs/tags') - # uses: joerick/cibuildwheel@v2.0.1 - # env: - # CIBW_BEFORE_BUILD: pip install -r requirements_build.txt - # CIBW_SKIP: pp* cp38-macosx_x86_64 - - # - name: Show files - # run: ls -lh wheelhouse - # shell: bash - - # - name: Upload wheels - # uses: actions/upload-artifact@v2 - # with: - # path: wheelhouse/*.whl - - # - name: Install wheel - # run: | - # pip install wheelhouse/*38* - - # - name: Test - # run: | - # pip install -r requirements_test.txt - # cd tests - # pytest -v + mac_build: + runs-on: macos-latest + name: Mac OS Unit Testing + strategy: + matrix: + python-version: ['3.7', '3.8', '3.9', '3.10'] + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: MacOS pip cache + uses: actions/cache@v3 + if: ${{ runner.os == 'macOS' }} + with: + path: ~/Library/Caches/pip + key: Python-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ matrix.extras-version }} + restore-keys: | + Python-${{ runner.os }}-${{ matrix.python-version }} + + - name: Build wheels + uses: joerick/cibuildwheel@v2.0.1 + env: + CIBW_BEFORE_BUILD: pip install -r requirements_build.txt + CIBW_BUILD: cp38-macosx_x86_64 + + - name: Show files + run: ls -lh wheelhouse + shell: bash + + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + path: wheelhouse/*.whl + + - name: Install wheel + run: | + pip install wheelhouse/*38* + + - name: Test + run: | + pip install -r requirements_test.txt + cd tests + pytest -v pymapdl_tests: name: PyMAPDL Unit Testing @@ -293,7 +294,7 @@ jobs: sudo apt install libgl1-mesa-glx xvfb - name: Linux pip cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.cache/pip key: Python-${{ runner.os }}-3.8-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements_*.txt') }} From ebcb7f55244a922073d499320f0c20c70e599f67 Mon Sep 17 00:00:00 2001 From: RobPasMue Date: Tue, 2 Aug 2022 08:48:33 +0200 Subject: [PATCH 02/18] Merge into single stage for all OS --- .github/workflows/testing-and-deployment.yml | 66 ++++---------------- 1 file changed, 13 insertions(+), 53 deletions(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index 54b69036..a5b128bc 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -113,6 +113,15 @@ jobs: restore-keys: | Python-${{ runner.os }}-${{ matrix.python-version }} + - name: MacOS pip cache + uses: actions/cache@v3 + if: ${{ runner.os == 'macOS' }} + with: + path: ~/Library/Caches/pip + key: Python-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements_*.txt') }} + restore-keys: | + Python-${{ runner.os }}-${{ matrix.python-version }} + - name: Window pip cache uses: actions/cache@v3 if: ${{ runner.os == 'Windows' }} @@ -151,8 +160,8 @@ jobs: pip install twine twine check dist/* - - name: Install on Linux - if: ${{ runner.os == 'Linux' }} + - name: Install on Linux / macOS + if: ${{ runner.os == 'Linux' }} || ${{ runner.os == 'macOS' }} run: | pip install wheel pip install dist/*.whl @@ -182,7 +191,7 @@ jobs: python -c "import pyvista; print(pyvista.Report())" - name: Install XVFB on Linux - if: ${{ runner.os == 'Linux' }} + if: ${{ runner.os == 'Linux' }} || ${{ runner.os == 'macOS' }} run: | sudo apt update sudo apt-get install libgl1-mesa-glx xvfb @@ -192,7 +201,7 @@ jobs: run: pip install -r requirements_test.txt - name: Test with XVFB - if: ${{ runner.os == 'Linux' }} + if: ${{ runner.os == 'Linux' }} || ${{ runner.os == 'macOS' }} run: xvfb-run pytest -v tests/ --durations=0 - name: Test without XVFB @@ -210,55 +219,6 @@ jobs: path: dist/ retention-days: 7 - mac_build: - runs-on: macos-latest - name: Mac OS Unit Testing - strategy: - matrix: - python-version: ['3.7', '3.8', '3.9', '3.10'] - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - - name: MacOS pip cache - uses: actions/cache@v3 - if: ${{ runner.os == 'macOS' }} - with: - path: ~/Library/Caches/pip - key: Python-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ matrix.extras-version }} - restore-keys: | - Python-${{ runner.os }}-${{ matrix.python-version }} - - - name: Build wheels - uses: joerick/cibuildwheel@v2.0.1 - env: - CIBW_BEFORE_BUILD: pip install -r requirements_build.txt - CIBW_BUILD: cp38-macosx_x86_64 - - - name: Show files - run: ls -lh wheelhouse - shell: bash - - - name: Upload wheels - uses: actions/upload-artifact@v3 - with: - path: wheelhouse/*.whl - - - name: Install wheel - run: | - pip install wheelhouse/*38* - - - name: Test - run: | - pip install -r requirements_test.txt - cd tests - pytest -v - pymapdl_tests: name: PyMAPDL Unit Testing runs-on: ubuntu-latest From 997baeec8871806d0b736084896b9c684b530877 Mon Sep 17 00:00:00 2001 From: RobPasMue Date: Tue, 2 Aug 2022 09:08:07 +0200 Subject: [PATCH 03/18] Include macOS in buid --- .github/workflows/testing-and-deployment.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index a5b128bc..69ca6416 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -94,7 +94,7 @@ jobs: strategy: matrix: python-version: ['3.7', '3.8', '3.9', '3.10'] - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v3 @@ -161,7 +161,7 @@ jobs: twine check dist/* - name: Install on Linux / macOS - if: ${{ runner.os == 'Linux' }} || ${{ runner.os == 'macOS' }} + if: (${{ runner.os == 'Linux' }}) || (${{ runner.os == 'macOS' }}) run: | pip install wheel pip install dist/*.whl @@ -190,8 +190,8 @@ jobs: pyvista-tools/appveyor/install_opengl.ps1 python -c "import pyvista; print(pyvista.Report())" - - name: Install XVFB on Linux - if: ${{ runner.os == 'Linux' }} || ${{ runner.os == 'macOS' }} + - name: Install XVFB on Linux / macOS + if: (${{ runner.os == 'Linux' }}) || (${{ runner.os == 'macOS' }}) run: | sudo apt update sudo apt-get install libgl1-mesa-glx xvfb @@ -201,7 +201,7 @@ jobs: run: pip install -r requirements_test.txt - name: Test with XVFB - if: ${{ runner.os == 'Linux' }} || ${{ runner.os == 'macOS' }} + if: (${{ runner.os == 'Linux' }}) || (${{ runner.os == 'macOS' }}) run: xvfb-run pytest -v tests/ --durations=0 - name: Test without XVFB From 6f6e3dd28dd0ad9301468c7741b706f7ef0e9695 Mon Sep 17 00:00:00 2001 From: RobPasMue Date: Tue, 2 Aug 2022 09:13:57 +0200 Subject: [PATCH 04/18] Build macOS wheel (stage missing) --- .github/workflows/testing-and-deployment.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index 69ca6416..4a3836f3 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -149,6 +149,12 @@ jobs: if: matrix.python-version == '3.10' run: pip install --find-links https://wheels.pyvista.org/ vtk + - name: Build wheel on macOS + if: ${{ runner.os == 'macOS' }} + run: | + pip install build + python -m build + - name: Build wheel on Windows if: ${{ runner.os == 'Windows' }} run: | From c2b5b853f4e26419994580b7b9cc04c4cdf7dcc2 Mon Sep 17 00:00:00 2001 From: RobPasMue Date: Tue, 2 Aug 2022 09:21:35 +0200 Subject: [PATCH 05/18] Remove xvfb for macOS --- .github/workflows/testing-and-deployment.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index 4a3836f3..b039b06a 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -196,8 +196,8 @@ jobs: pyvista-tools/appveyor/install_opengl.ps1 python -c "import pyvista; print(pyvista.Report())" - - name: Install XVFB on Linux / macOS - if: (${{ runner.os == 'Linux' }}) || (${{ runner.os == 'macOS' }}) + - name: Install XVFB on Linux + if: (${{ runner.os == 'Linux' }}) run: | sudo apt update sudo apt-get install libgl1-mesa-glx xvfb @@ -207,11 +207,11 @@ jobs: run: pip install -r requirements_test.txt - name: Test with XVFB - if: (${{ runner.os == 'Linux' }}) || (${{ runner.os == 'macOS' }}) + if: (${{ runner.os == 'Linux' }}) run: xvfb-run pytest -v tests/ --durations=0 - name: Test without XVFB - if: ${{ runner.os == 'Windows' }} + if: (${{ runner.os == 'Windows' }}) || (${{ runner.os == 'macOS' }}) run: pytest -v tests/ --durations=0 - uses: codecov/codecov-action@v2 From 560ada38e874bb6e48b8d0717e36da09ae074099 Mon Sep 17 00:00:00 2001 From: RobPasMue Date: Tue, 2 Aug 2022 09:30:08 +0200 Subject: [PATCH 06/18] Remove parenthesis --- .github/workflows/testing-and-deployment.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index b039b06a..e6e42d33 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -197,7 +197,7 @@ jobs: python -c "import pyvista; print(pyvista.Report())" - name: Install XVFB on Linux - if: (${{ runner.os == 'Linux' }}) + if: ${{ runner.os == 'Linux' }} run: | sudo apt update sudo apt-get install libgl1-mesa-glx xvfb @@ -207,7 +207,7 @@ jobs: run: pip install -r requirements_test.txt - name: Test with XVFB - if: (${{ runner.os == 'Linux' }}) + if: ${{ runner.os == 'Linux' }} run: xvfb-run pytest -v tests/ --durations=0 - name: Test without XVFB From 5f156e732c5847d491865544444ab48f6ce7defa Mon Sep 17 00:00:00 2001 From: RobPasMue Date: Tue, 2 Aug 2022 09:37:24 +0200 Subject: [PATCH 07/18] Implementing OR conditional properly --- .github/workflows/testing-and-deployment.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index e6e42d33..4054f9d3 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -167,7 +167,7 @@ jobs: twine check dist/* - name: Install on Linux / macOS - if: (${{ runner.os == 'Linux' }}) || (${{ runner.os == 'macOS' }}) + if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }} run: | pip install wheel pip install dist/*.whl @@ -211,7 +211,7 @@ jobs: run: xvfb-run pytest -v tests/ --durations=0 - name: Test without XVFB - if: (${{ runner.os == 'Windows' }}) || (${{ runner.os == 'macOS' }}) + if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }} run: pytest -v tests/ --durations=0 - uses: codecov/codecov-action@v2 From 715ca63915441e32e08e1da47c5a0b15b11223a0 Mon Sep 17 00:00:00 2001 From: RobPasMue Date: Tue, 2 Aug 2022 09:37:59 +0200 Subject: [PATCH 08/18] Typo --- .github/workflows/testing-and-deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index 4054f9d3..ba0bac9d 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -211,7 +211,7 @@ jobs: run: xvfb-run pytest -v tests/ --durations=0 - name: Test without XVFB - if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }} + if: ${{ runner.os == 'Windows' || runner.os == 'macOS' }} run: pytest -v tests/ --durations=0 - uses: codecov/codecov-action@v2 From 4e88bf7bc362abfc16527b58f6422356f59cd95a Mon Sep 17 00:00:00 2001 From: RobPasMue Date: Tue, 2 Aug 2022 18:00:22 +0200 Subject: [PATCH 09/18] Trial using cibuildwheel --- .github/workflows/testing-and-deployment.yml | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index ba0bac9d..37b66bf0 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -225,6 +225,36 @@ jobs: path: dist/ retention-days: 7 + build_wheels_macos: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest] + + steps: + - uses: actions/checkout@v3 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.8.0 + + # - uses: actions/upload-artifact@v3 + # with: + # path: ./wheelhouse/*.whl + + - name: Install on Linux / macOS + if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }} + run: | + pip install wheel + pip install wheelhouse/*.whl + pip list + + - name: Install test requirements + run: pip install -r requirements_test.txt + + - name: Test without XVFB + run: pytest -v tests/ --durations=0 + pymapdl_tests: name: PyMAPDL Unit Testing runs-on: ubuntu-latest From 51f4cdd7a861b4a04092a32505b936fae4197c34 Mon Sep 17 00:00:00 2001 From: RobPasMue Date: Tue, 2 Aug 2022 18:23:45 +0200 Subject: [PATCH 10/18] New trial --- .github/workflows/testing-and-deployment.yml | 28 +++++++++++--------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index 37b66bf0..f6b3dc23 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -230,30 +230,34 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-latest] + os: [macos-10.15] steps: - uses: actions/checkout@v3 - name: Build wheels - uses: pypa/cibuildwheel@v2.8.0 + uses: pypa/cibuildwheel@v2.8.1 + + - name: List generated wheels + run: | + ls ./wheelhouse/* # - uses: actions/upload-artifact@v3 # with: # path: ./wheelhouse/*.whl - - name: Install on Linux / macOS - if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }} - run: | - pip install wheel - pip install wheelhouse/*.whl - pip list + # - name: Install on Linux / macOS + # if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }} + # run: | + # pip install wheel + # pip install wheelhouse/*.whl + # pip list - - name: Install test requirements - run: pip install -r requirements_test.txt + # - name: Install test requirements + # run: pip install -r requirements_test.txt - - name: Test without XVFB - run: pytest -v tests/ --durations=0 + # - name: Test without XVFB + # run: pytest -v tests/ --durations=0 pymapdl_tests: name: PyMAPDL Unit Testing From fa6f762ad689417692d19fc4a70486ca81f2f3b3 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Thu, 4 Aug 2022 01:17:55 +0000 Subject: [PATCH 11/18] fix pyproject settings --- pyproject.toml | 34 +++++++++-- requirements_build.txt | 6 -- requirements_test.txt | 7 +-- setup.py | 131 +++++++++-------------------------------- 4 files changed, 59 insertions(+), 119 deletions(-) delete mode 100644 requirements_build.txt diff --git a/pyproject.toml b/pyproject.toml index 6a19e417..75a5b04a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,31 @@ [build-system] +build-backend = "setuptools.build_meta" requires = [ - "setuptools>=41.0.0", - "wheel>=0.33.0", - "numpy<=1.22.1", - "cython==0.29.24", -] \ No newline at end of file + "cython>=0.29", + "oldest-supported-numpy", + "setuptools>=45.0", + "wheel>=0.37.0", +] + +[tool.pytest.ini_options] +junit_family= "legacy" +filterwarnings = [ + "ignore::FutureWarning", + "ignore::PendingDeprecationWarning", + "ignore::DeprecationWarning", + # bogus numpy ABI warning (see numpy/#432) + "ignore:.*numpy.dtype size changed.*:RuntimeWarning", + "ignore:.*numpy.ufunc size changed.*:RuntimeWarning", + "ignore:.*Distutils was imported before Setuptools*", +] + +[tool.cibuildwheel] +archs = ["auto64"] # 64-bit only +skip = "pp* *musllinux*" # disable PyPy and musl-based wheels +test-requires = "ansys-mapdl-core>=0.60.4 matplotlib pytest scipy" +test-command = "pytest {project}/tests" + +[tool.cibuildwheel.macos] +# https://cibuildwheel.readthedocs.io/en/stable/faq/#apple-silicon +archs = ["x86_64"] # , "universal2" +test-skip = ["*_arm64", "*_universal2:arm64"] diff --git a/requirements_build.txt b/requirements_build.txt deleted file mode 100644 index 97b2b3a3..00000000 --- a/requirements_build.txt +++ /dev/null @@ -1,6 +0,0 @@ -setuptools>=41.0.0 -wheel>=0.33.0 -numpy<1.20.0;python_version<"3.10" -numpy==1.22.1;python_version>="3.10" -cython==0.29.24 -matplotlib diff --git a/requirements_test.txt b/requirements_test.txt index fc683985..9bfdd1f7 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,8 +1,5 @@ -scipy -pytest +ansys-mapdl-core>=0.60.4 matplotlib pytest pytest-cov -vtk<9.1.0;python_version<"3.10" -pyvista>=0.24.0 -ansys-mapdl-core>=0.60.4 +scipy diff --git a/setup.py b/setup.py index fd269ed2..9e4aac12 100644 --- a/setup.py +++ b/setup.py @@ -1,86 +1,26 @@ """Installation file for ansys-mapdl-reader""" from io import open as io_open import os -import platform -import re -import struct -import subprocess -import sys import numpy as np from setuptools import Extension, setup -from setuptools.command.build_ext import build_ext as _build_ext +if os.name == "nt": # windows + extra_compile_args = ["/openmp", "/O2", "/w", "/GS"] +elif os.name == "posix": # linux/mac os + extra_compile_args = ["-O3", "-w"] -# Facilities to install properly on Mac using clang -def is_clang(bin): - proc = subprocess.Popen([bin, "-v"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdout, stderr = proc.communicate() - output = str(b"\n".join([stdout, stderr]).decode("ascii", "ignore")) - return not re.search(r"clang", output) is None - - -class build_ext(_build_ext): - """build class that includes numpy directory""" - - def build_extensions(self): - if os.name != "nt": - binary = self.compiler.compiler[0] - if is_clang(binary): - for e in self.extensions: - e.extra_compile_args.append("-stdlib=libc++") - - if platform.system() == "Darwin": - # get the minor version - mac_version, _, _ = platform.mac_ver() - minor = [int(n) for n in mac_version.split(".")][1] - - # libstdc++ is deprecated in recent versions of XCode - if minor >= 9: - e.extra_compile_args.append("-mmacosx-version-min=10.9") - e.extra_compile_args.append("-stdlib=libc++") - e.extra_link_args.append("-mmacosx-version-min=10.9") - e.extra_link_args.append("-stdlib=libc++") - else: - e.extra_compile_args.append("-mmacosx-version-min=10.7") - e.extra_link_args.append("-mmacosx-version-min=10.7") - - _build_ext.build_extensions(self) - - -def compiler_name(): - """Check compiler and assign compile arguments accordingly""" - import distutils.ccompiler - import re - - comp = distutils.ccompiler.get_default_compiler() - getnext = False - - for a in sys.argv[2:]: - if getnext: - comp = a - getnext = False - continue - # separated by space - if a == "--compiler" or re.search("^-[a-z]*c$", a): - getnext = True - continue - # without space - m = re.search("^--compiler=(.+)", a) - if m is None: - m = re.search("^-[a-z]*c(.+)", a) - if m: - comp = m.group(1) - - return comp - - -# Assign arguments based on compiler -compiler = compiler_name() -if compiler == "unix": - cmp_arg = ["-O3", "-w"] -else: - cmp_arg = ["/Ox", "-w"] + # # different compiler options on Mac OS + # if platform.system() == "Darwin": + # # Assume clang + # # Note, openmp requires: + # # brew install llvm libomp + # # + # # Might need: + # # export LDFLAGS="-L/usr/local/opt/llvm/lib" + # # export CPPFLAGS="-I/usr/local/opt/llvm/include" + # os.environ["CC"] = "/usr/local/opt/llvm/bin/clang" + # os.environ["CXX"] = "/usr/local/opt/llvm/bin/clang++" # Get version from version info @@ -91,27 +31,6 @@ def compiler_name(): # execute file from raw string exec(fd.read()) -install_requires = [ - "numpy>=1.16.0", - "pyvista>=0.32.0", - "appdirs>=1.4.0", - "matplotlib>=3.0.0", - "tqdm>=4.45.0", -] - -# perform python version checking -# this is necessary to avoid the new pip package checking as vtk does -# not support Python 32-bit as of 17 June 2021. -is64 = struct.calcsize("P") * 8 == 64 -if not is64: - try: - import vtk # noqa: F401 - except ImportError: - raise RuntimeError( - "\n\n``ansys-mapdl-reader`` requires 64-bit Python due to vtk.\n" - "Please check the version of Python installed at\n" - "%s" % sys.executable - ) setup( name="ansys-mapdl-reader", @@ -137,7 +56,7 @@ def compiler_name(): ], url="https://github.com/pyansys/pymapdl-reader", # Build cython modules - cmdclass={"build_ext": build_ext}, + # cmdclass={"build_ext": build_ext}, include_dirs=[np.get_include()], ext_modules=[ Extension( @@ -146,7 +65,7 @@ def compiler_name(): "ansys/mapdl/reader/cython/_archive.pyx", "ansys/mapdl/reader/cython/archive.c", ], - extra_compile_args=cmp_arg, + extra_compile_args=extra_compile_args, language="c", ), Extension( @@ -156,19 +75,19 @@ def compiler_name(): "ansys/mapdl/reader/cython/reader.c", "ansys/mapdl/reader/cython/vtk_support.c", ], - extra_compile_args=cmp_arg, + extra_compile_args=extra_compile_args, language="c", ), Extension( "ansys.mapdl.reader._relaxmidside", ["ansys/mapdl/reader/cython/_relaxmidside.pyx"], - extra_compile_args=cmp_arg, + extra_compile_args=extra_compile_args, language="c", ), Extension( "ansys.mapdl.reader._cellqual", ["ansys/mapdl/reader/cython/_cellqual.pyx"], - extra_compile_args=cmp_arg, + extra_compile_args=extra_compile_args, language="c", ), Extension( @@ -177,7 +96,7 @@ def compiler_name(): "ansys/mapdl/reader/cython/_binary_reader.pyx", "ansys/mapdl/reader/cython/binary_reader.cpp", ], - extra_compile_args=cmp_arg, + extra_compile_args=extra_compile_args, language="c++", ), ], @@ -193,5 +112,11 @@ def compiler_name(): "sector.cdb", ] }, - install_requires=install_requires, + install_requires=[ + "numpy>=1.16.0", + "pyvista>=0.32.0", + "appdirs>=1.4.0", + "matplotlib>=3.0.0", + "tqdm>=4.45.0", + ], ) From 3aca3eae90262e9d2f0cd447f7cdaf1b08b71d68 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Thu, 4 Aug 2022 01:23:08 +0000 Subject: [PATCH 12/18] fix mac OS runner --- .github/workflows/testing-and-deployment.yml | 58 +++++--------------- 1 file changed, 15 insertions(+), 43 deletions(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index f6b3dc23..0c3c7344 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -18,6 +18,10 @@ on: branches: - main +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: check_style: name: Style Check @@ -55,18 +59,17 @@ jobs: - name: Install ansys-mapdl-reader run: | - pip install -r requirements_build.txt --disable-pip-version-check - python setup.py bdist_wheel + pip install build + python -m build --wheel pip install dist/ansys*.whl --disable-pip-version-check cd tests/ xvfb-run python -c "from ansys.mapdl import reader as pymapdl_reader; print(pymapdl_reader.Report())" - name: Build Documentation run: | - sudo apt install pandoc -qy + sudo apt-get install zip pandoc -qy pip install -r requirements_docs.txt --disable-pip-version-check xvfb-run make -C doc html - sudo apt install zip cd doc/build/html/ zip ../../../${{ env.PACKAGE_NAME }}-HTML.zip ./* @@ -94,7 +97,7 @@ jobs: strategy: matrix: python-version: ['3.7', '3.8', '3.9', '3.10'] - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-latest, windows-latest] steps: - uses: actions/checkout@v3 @@ -113,15 +116,6 @@ jobs: restore-keys: | Python-${{ runner.os }}-${{ matrix.python-version }} - - name: MacOS pip cache - uses: actions/cache@v3 - if: ${{ runner.os == 'macOS' }} - with: - path: ~/Library/Caches/pip - key: Python-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements_*.txt') }} - restore-keys: | - Python-${{ runner.os }}-${{ matrix.python-version }} - - name: Window pip cache uses: actions/cache@v3 if: ${{ runner.os == 'Windows' }} @@ -149,12 +143,6 @@ jobs: if: matrix.python-version == '3.10' run: pip install --find-links https://wheels.pyvista.org/ vtk - - name: Build wheel on macOS - if: ${{ runner.os == 'macOS' }} - run: | - pip install build - python -m build - - name: Build wheel on Windows if: ${{ runner.os == 'Windows' }} run: | @@ -167,7 +155,7 @@ jobs: twine check dist/* - name: Install on Linux / macOS - if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }} + if: ${{ runner.os == 'Linux' }} run: | pip install wheel pip install dist/*.whl @@ -211,7 +199,7 @@ jobs: run: xvfb-run pytest -v tests/ --durations=0 - name: Test without XVFB - if: ${{ runner.os == 'Windows' || runner.os == 'macOS' }} + if: ${{ runner.os == 'Windows' }} run: pytest -v tests/ --durations=0 - uses: codecov/codecov-action@v2 @@ -226,11 +214,8 @@ jobs: retention-days: 7 build_wheels_macos: - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [macos-10.15] + name: Build wheels on MacOS + runs-on: macos-latest steps: - uses: actions/checkout@v3 @@ -242,22 +227,9 @@ jobs: run: | ls ./wheelhouse/* - # - uses: actions/upload-artifact@v3 - # with: - # path: ./wheelhouse/*.whl - - # - name: Install on Linux / macOS - # if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }} - # run: | - # pip install wheel - # pip install wheelhouse/*.whl - # pip list - - # - name: Install test requirements - # run: pip install -r requirements_test.txt - - # - name: Test without XVFB - # run: pytest -v tests/ --durations=0 + - uses: actions/upload-artifact@v3 + with: + path: ./wheelhouse/*.whl pymapdl_tests: name: PyMAPDL Unit Testing From d63219705335a2db00eb5a197912b8de8915d160 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Thu, 4 Aug 2022 01:26:26 +0000 Subject: [PATCH 13/18] use build in docker --- .ci/build_wheels.sh | 13 ++-------- .github/workflows/testing-and-deployment.yml | 25 +++++++++----------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/.ci/build_wheels.sh b/.ci/build_wheels.sh index 14bcc9f6..4c24a3e4 100755 --- a/.ci/build_wheels.sh +++ b/.ci/build_wheels.sh @@ -6,15 +6,6 @@ set -e -x # build based on python version from args PYTHON_VERSION="$1" case $PYTHON_VERSION in -2.7) - PYBIN="/opt/python/cp27-cp27m/bin" - ;; -3.5) - PYBIN="/opt/python/cp35-cp35m/bin" - ;; -3.6) - PYBIN="/opt/python/cp36-cp36m/bin" - ;; 3.7) PYBIN="/opt/python/cp37-cp37m/bin" ;; @@ -31,8 +22,8 @@ esac # build, don't install cd io -"${PYBIN}/pip" install -r requirements_build.txt -"${PYBIN}/python" setup.py bdist_wheel +"${PYBIN}/pip" install build +"${PYBIN}/python" -m build --wheel auditwheel repair dist/ansys_mapdl_reader*.whl rm -f dist/* mv wheelhouse/*manylinux* dist/ diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index 0c3c7344..d29eae7b 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -27,16 +27,19 @@ jobs: name: Style Check runs-on: ubuntu-latest + stylecheck: + name: Style Check + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v2.2.2 with: - python-version: 3.9 - - name: Style - run: | - pip install -r requirements_style.txt --disable-pip-version-check - make + python-version: '3.10' + - name: Install pre-commit + run: pip install pre-commit + - name: Run pre-commit + run: pre-commit run --all-files || ( git status --short ; git diff ; exit 1 ) doc_build: name: Build Documentation @@ -59,9 +62,7 @@ jobs: - name: Install ansys-mapdl-reader run: | - pip install build - python -m build --wheel - pip install dist/ansys*.whl --disable-pip-version-check + pip install -e . cd tests/ xvfb-run python -c "from ansys.mapdl import reader as pymapdl_reader; print(pymapdl_reader.Report())" @@ -139,10 +140,6 @@ jobs: quay.io/pypa/manylinux2014_x86_64 \ /io/.ci/build_wheels.sh ${{ matrix.python-version }} - - name: Install VTK on Python 3.10 - if: matrix.python-version == '3.10' - run: pip install --find-links https://wheels.pyvista.org/ vtk - - name: Build wheel on Windows if: ${{ runner.os == 'Windows' }} run: | From 7d7e89414097807774042b74c95aa65969b57bfb Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Thu, 4 Aug 2022 01:30:56 +0000 Subject: [PATCH 14/18] fix stylecheck --- .github/workflows/testing-and-deployment.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index d29eae7b..f487c514 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -23,10 +23,6 @@ concurrency: cancel-in-progress: true jobs: - check_style: - name: Style Check - runs-on: ubuntu-latest - stylecheck: name: Style Check runs-on: ubuntu-latest @@ -310,7 +306,7 @@ jobs: Release: if: github.event_name == 'push' && contains(github.ref, 'refs/tags') - needs: [check_style, doc_build, build, pymapdl_tests] # , mac_build + needs: [stylecheck, doc_build, build, pymapdl_tests] # , mac_build runs-on: ubuntu-latest steps: - name: Set up Python From 444158b18471865888b0eb09d82e601ff908c465 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Thu, 4 Aug 2022 01:40:52 +0000 Subject: [PATCH 15/18] fix stylecheck --- doc/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 646cb167..7a350708 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -2,9 +2,9 @@ import os import warnings +from ansys_sphinx_theme import pyansys_logo_black import pyvista from sphinx_gallery.sorting import FileNameSortKey -from ansys_sphinx_theme import pyansys_logo_black from ansys.mapdl import reader as pymapdl_reader From 09aacbec388bd2c1feddbd08408426dbb9e43f82 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Thu, 4 Aug 2022 01:56:53 +0000 Subject: [PATCH 16/18] build mac only on release --- .github/workflows/testing-and-deployment.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index f487c514..b780db03 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -206,7 +206,8 @@ jobs: path: dist/ retention-days: 7 - build_wheels_macos: + mac_build: + if: github.event_name == 'push' && contains(github.ref, 'refs/tags') name: Build wheels on MacOS runs-on: macos-latest @@ -306,7 +307,7 @@ jobs: Release: if: github.event_name == 'push' && contains(github.ref, 'refs/tags') - needs: [stylecheck, doc_build, build, pymapdl_tests] # , mac_build + needs: [stylecheck, doc_build, build, pymapdl_tests, mac_build] runs-on: ubuntu-latest steps: - name: Set up Python From 53e355255746c4e5c005e3cd2f75cf47b4439f06 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Thu, 4 Aug 2022 02:03:00 +0000 Subject: [PATCH 17/18] skip windows plotting tests --- .github/workflows/testing-and-deployment.yml | 2 +- setup.py | 12 ------------ tests/test_cyclic.py | 4 ++++ 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index b780db03..e99894a3 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -147,7 +147,7 @@ jobs: pip install twine twine check dist/* - - name: Install on Linux / macOS + - name: Install on Linux if: ${{ runner.os == 'Linux' }} run: | pip install wheel diff --git a/setup.py b/setup.py index 9e4aac12..3ce0ab5b 100644 --- a/setup.py +++ b/setup.py @@ -10,18 +10,6 @@ elif os.name == "posix": # linux/mac os extra_compile_args = ["-O3", "-w"] - # # different compiler options on Mac OS - # if platform.system() == "Darwin": - # # Assume clang - # # Note, openmp requires: - # # brew install llvm libomp - # # - # # Might need: - # # export LDFLAGS="-L/usr/local/opt/llvm/lib" - # # export CPPFLAGS="-I/usr/local/opt/llvm/include" - # os.environ["CC"] = "/usr/local/opt/llvm/bin/clang" - # os.environ["CXX"] = "/usr/local/opt/llvm/bin/clang++" - # Get version from version info __version__ = None diff --git a/tests/test_cyclic.py b/tests/test_cyclic.py index ebcbabab..ea710656 100644 --- a/tests/test_cyclic.py +++ b/tests/test_cyclic.py @@ -37,6 +37,9 @@ reason="Plotting disabled for these tests", ) +skip_windows = pytest.mark.skipif( + os.name == "nt", reason="Test fails due to OSMESA on Windows" +) # static result x axis @pytest.fixture(scope="module") @@ -109,6 +112,7 @@ def test_non_cyclic(): rst = CyclicResult(examples.rstfile) +@skip_windows @skip_plotting @pytest.mark.skipif(result_z is None, reason="Requires result file") def test_plot_sectors(tmpdir): From 7a5e4971511b1426e377683e7e72a7054734fc78 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Thu, 4 Aug 2022 03:19:44 +0000 Subject: [PATCH 18/18] skip plotting tests on windows --- tests/test_cyclic.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_cyclic.py b/tests/test_cyclic.py index ea710656..d4dbf7e6 100644 --- a/tests/test_cyclic.py +++ b/tests/test_cyclic.py @@ -123,6 +123,7 @@ def test_plot_sectors(tmpdir): assert os.path.isfile(filename) +@skip_windows @skip_plotting def test_plot_sectors_x(result_x): cpos = result_x.plot_sectors() @@ -130,6 +131,7 @@ def test_plot_sectors_x(result_x): assert isinstance(cpos, CameraPosition) +@skip_windows @skip_plotting @pytest.mark.skipif(result_z is None, reason="Requires result file") def test_plot_z_cyc(): @@ -138,6 +140,7 @@ def test_plot_z_cyc(): assert isinstance(cpos, CameraPosition) +@skip_windows @skip_plotting def test_plot_x_cyc(result_x): cpos = result_x.plot() @@ -145,6 +148,7 @@ def test_plot_x_cyc(result_x): assert isinstance(cpos, CameraPosition) +@skip_windows @skip_plotting def test_plot_component_rotor(cyclic_v182_z_with_comp): cyclic_v182_z_with_comp.plot_nodal_solution( @@ -287,6 +291,7 @@ def test_full_z_nodal_solution_phase(cyclic_v182_z): assert np.allclose(disp[:, mask], tmp) +@skip_windows @skip_plotting def test_full_x_nodal_solution_plot(result_x): result_x.plot_nodal_solution(0) @@ -358,6 +363,7 @@ def test_full_x_principal_nodal_stress(result_x): assert np.allclose(stress[:, mask], tmp, atol=4e-3) # too loose +@skip_windows @skip_plotting @pytest.mark.skipif(not HAS_FFMPEG, reason="requires imageio_ffmpeg") @pytest.mark.skipif(result_z is None, reason="Requires result file") @@ -389,16 +395,19 @@ def test_cyclic_z_harmonic_displacement(): assert np.allclose(disp[:, mask], tmp, atol=1e-5) +@skip_windows @skip_plotting def test_plot_nodal_stress(result_x): result_x.plot_nodal_stress(0, "z") +@skip_windows @skip_plotting def test_plot_nodal_stress(result_x): result_x.plot_nodal_stress(0, "z") +@skip_windows @skip_plotting def test_plot_principal_nodal_stress(result_x): result_x.plot_principal_nodal_stress(0, "seqv") @@ -420,6 +429,7 @@ def test_nodal_elastic_strain_cyclic(result_x): assert np.allclose(stress, stress_ans) +@skip_windows @skip_plotting def test_plot_nodal_elastic_strain(result_x): result_x.plot_nodal_elastic_strain(0, "X") @@ -441,6 +451,7 @@ def test_nodal_temperature(result_x): assert np.allclose(temp[mask], temp_ans[:, mask], equal_nan=True) +@skip_windows @skip_plotting def test_plot_nodal_nodal_temperature(result_x): result_x.plot_nodal_temperature(0) @@ -461,6 +472,7 @@ def test_nodal_thermal_strain_cyclic(result_x): assert np.allclose(strain, strain_ans) +@skip_windows @skip_plotting def test_plot_nodal_thermal_strain(result_x): result_x.plot_nodal_thermal_strain(0, "X")