From fd0034bc5bd3ded1f151e6cac53806d66b4c3d95 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Fri, 21 Jan 2022 20:11:10 -0700 Subject: [PATCH 01/12] add py310 req and setup --- .github/workflows/testing-and-deployment.yml | 113 ++----------------- pyproject.toml | 7 ++ requirements.txt | 5 - setup.py | 77 ++++++------- 4 files changed, 49 insertions(+), 153 deletions(-) create mode 100644 pyproject.toml delete mode 100644 requirements.txt diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index 01c9ba36..5d85572a 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -1,95 +1,4 @@ -name: GH Actions - -# repo specific gh actions -env: - SHELLOPTS: 'errexit:pipefail' - PACKAGE_NAME: ansys-mapdl-reader - PYVISTA_OFF_SCREEN: true - -on: - pull_request: - push: - tags: - - "*" - branches: - - main - -jobs: - check_style: - name: Style Check - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Setup Python - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - name: Style - run: | - pip install -r requirements_style.txt --disable-pip-version-check - make - - doc_build: - name: Build Documentation - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Setup Python - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - - name: Install XVFB - run: | - sudo apt update - sudo apt-get install libgl1-mesa-glx xvfb - pip install pyvista - xvfb-run python -c "import pyvista; print(pyvista.Report())" - - - name: Install ansys-mapdl-reader - run: | - pip install -r requirements_build.txt --disable-pip-version-check - python setup.py bdist_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 - 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 ./* - - - name: Upload - uses: actions/upload-artifact@v2 - with: - name: ${{ env.PACKAGE_NAME }}-Documentation - path: | - ${{ env.PACKAGE_NAME }}-HTML.zip - doc/build/latex/*.pdf - retention-days: 7 - - - name: Deploy - uses: JamesIves/github-pages-deploy-action@3.7.1 - if: startsWith(github.ref, 'refs/tags/') - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: gh-pages - FOLDER: doc/build/html - CLEAN: true - - build: - name: Build and Test - runs-on: ${{ matrix.os }} - strategy: - matrix: - python-version: ['3.6', '3.7', '3.8', '3.9'] + python-version: ['3.6', '3.7', '3.8', '3.9', '3.10'] os: [ubuntu-latest, windows-latest] steps: @@ -135,9 +44,8 @@ jobs: - name: Build wheel on Windows if: ${{ runner.os == 'Windows' }} run: | - pip install -r requirements_build.txt - python setup.py bdist_wheel - python setup.py sdist + pip install build + python -m build - name: Validate wheel run: | @@ -181,17 +89,16 @@ jobs: sudo apt-get install libgl1-mesa-glx xvfb xvfb-run python -c "import pyvista; print(pyvista.Report())" + - name: Install test requirements + run: pip install -r requirements_test.txt + - name: Test with XVFB - if: ${{ runner.os == 'Linux' }} - run: | - pip install -r requirements_test.txt - xvfb-run pytest -v tests/ --durations=0 + if: ${{ runner.os == 'Linux' }} || ${{ runner.python-version != '3.10' }} + run: xvfb-run pytest -v tests/ --durations=0 - name: Test without XVFB - if: ${{ runner.os == 'Windows' }} - run: | - pip install -r requirements_test.txt - pytest -v tests/ --durations=0 + if: ${{ runner.os == 'Windows' }} || ${{ runner.python-version != '3.10' }} + run: pytest -v tests/ --durations=0 - name: Upload wheel uses: actions/upload-artifact@v2 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..13042943 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,7 @@ +[build-system] +requires = [ + "setuptools>=41.0.0", + "wheel>=0.33.0", + "numpy<1.20.0", + "cython==0.29.24", +] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index c4e7494d..00000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -numpy>=1.14.0 -pyvista>=0.27.2 -appdirs>=1.4.0 -tqdm>=4.45.0 -matplotlib>=3.0.0 diff --git a/setup.py b/setup.py index 7cade675..7503c5c7 100644 --- a/setup.py +++ b/setup.py @@ -1,20 +1,15 @@ """Installation file for ansys-mapdl-reader""" +from io import open as io_open +from setuptools import setup, Extension +from setuptools.command.build_ext import build_ext as _build_ext +import os import platform import re -import subprocess import struct -import os +import subprocess import sys -from io import open as io_open - -from setuptools import setup, Extension -from setuptools.command.build_ext import build_ext as _build_ext - -try: - import numpy as np -except ImportError: - raise Exception('Please install numpy first with "pip install numpy"') +import numpy as np # Facilities to install properly on Mac using clang def is_clang(bin): @@ -24,33 +19,8 @@ def is_clang(bin): return not re.search(r'clang', output) is None -def check_cython(): - """Check if binaries exist and if not check if Cython is installed""" - has_binary_reader = False - for filename in os.listdir('ansys/mapdl/reader'): - if '_binary_reader' in filename: - has_binary_reader = True - - if not has_binary_reader: - # ensure cython is installed before trying to build - try: - import cython - except ImportError: - raise ImportError('\n\n\nTo build pyansys please install Cython with:\n\n' - 'pip install cython\n\n') from None - - -check_cython() - - class build_ext(_build_ext): """ build class that includes numpy directory """ - def finalize_options(self): - _build_ext.finalize_options(self) - # Prevent numpy from thinking it is still in its setup process: - __builtins__.__NUMPY_SETUP__ = False - import numpy - self.include_dirs.append(numpy.get_include()) def build_extensions(self): if os.name != 'nt': @@ -77,7 +47,7 @@ def build_extensions(self): _build_ext.build_extensions(self) -def compilerName(): +def compiler_name(): """ Check compiler and assign compile arguments accordingly """ import re import distutils.ccompiler @@ -104,7 +74,7 @@ def compilerName(): # Assign arguments based on compiler -compiler = compilerName() +compiler = compiler_name() if compiler == 'unix': cmp_arg = ['-O3', '-w'] else: @@ -119,16 +89,19 @@ def compilerName(): # 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'] +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. -if not struct.calcsize("P")*8 == 64: +is64 = struct.calcsize("P") * 8 == 64 +if not is64: try: import vtk except ImportError: @@ -136,7 +109,19 @@ def compilerName(): 'Please check the version of Python installed at\n' '%s' % sys.executable) -# Actual setup + +if sys.version_info.minor == 10 and is64: + # use pip to check if vtk is available or installed + sys_name = platform.system().lower() + if sys_name == 'linux': + install_requires.append( + 'vtk @ https://github.com/pyvista/pyvista-wheels/raw/main/vtk-9.1.0.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl', + ) + elif sys_name == 'windows': + install_requires.append( + 'vtk @ https://github.com/pyvista/pyvista-wheels/raw/main/vtk-9.1.0.dev0-cp310-cp310-win_amd64.whl', + ) + setup( name='ansys-mapdl-reader', packages=['ansys.mapdl.reader', 'ansys.mapdl.reader.examples'], @@ -157,11 +142,13 @@ def compilerName(): 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', ], url='https://github.com/pyansys/pymapdl-reader', # Build cython modules cmdclass={'build_ext': build_ext}, + include_dirs=[np.get_include()], ext_modules=[ Extension('ansys.mapdl.reader._archive', ['ansys/mapdl/reader/cython/_archive.pyx', From 7db0d4d189eb2d46215600f880ad16c32a8d8993 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Fri, 21 Jan 2022 20:14:30 -0700 Subject: [PATCH 02/12] add back missing CI --- .github/workflows/testing-and-deployment.yml | 87 ++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index 5d85572a..a70ab0ff 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -1,3 +1,90 @@ +name: GH Actions + +# repo specific gh actions +env: + SHELLOPTS: 'errexit:pipefail' + PACKAGE_NAME: ansys-mapdl-reader + PYVISTA_OFF_SCREEN: true + +on: + pull_request: + push: + tags: + - "*" + branches: + - main + +jobs: + check_style: + name: Style Check + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Style + run: | + pip install -r requirements_style.txt --disable-pip-version-check + make + doc_build: + name: Build Documentation + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Install XVFB + run: | + sudo apt update + sudo apt-get install libgl1-mesa-glx xvfb + pip install pyvista + xvfb-run python -c "import pyvista; print(pyvista.Report())" + - name: Install ansys-mapdl-reader + run: | + pip install -r requirements_build.txt --disable-pip-version-check + python setup.py bdist_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 + 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 ./* + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: ${{ env.PACKAGE_NAME }}-Documentation + path: | + ${{ env.PACKAGE_NAME }}-HTML.zip + doc/build/latex/*.pdf + retention-days: 7 + + - name: Deploy + uses: JamesIves/github-pages-deploy-action@3.7.1 + if: startsWith(github.ref, 'refs/tags/') + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages + FOLDER: doc/build/html + CLEAN: true + + build: + name: Build and Test + runs-on: ${{ matrix.os }} + strategy: + matrix: python-version: ['3.6', '3.7', '3.8', '3.9', '3.10'] os: [ubuntu-latest, windows-latest] From 6fb53953d43feff2e894c8a32b7d77d5a68d1f99 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Fri, 21 Jan 2022 20:33:33 -0700 Subject: [PATCH 03/12] fix build_wheels.sh --- .ci/build_wheels.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/build_wheels.sh b/.ci/build_wheels.sh index 2d8849de..4e6ca83c 100755 --- a/.ci/build_wheels.sh +++ b/.ci/build_wheels.sh @@ -22,7 +22,7 @@ case $PYTHON_VERSION in PYBIN="/opt/python/cp38-cp38/bin" ;; 3.9) - PYBIN="/opt/python/cp39-cp39/bin" + PYBIN="/opt/python/cp310-cp310/bin" ;; esac From b7976f458ad7f8ef8dd2ce0cb5edf8993ec54b9b Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Fri, 21 Jan 2022 20:44:14 -0700 Subject: [PATCH 04/12] correct terms --- .ci/build_wheels.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.ci/build_wheels.sh b/.ci/build_wheels.sh index 4e6ca83c..14bcc9f6 100755 --- a/.ci/build_wheels.sh +++ b/.ci/build_wheels.sh @@ -22,6 +22,9 @@ case $PYTHON_VERSION in PYBIN="/opt/python/cp38-cp38/bin" ;; 3.9) + PYBIN="/opt/python/cp39-cp39/bin" + ;; +3.10) PYBIN="/opt/python/cp310-cp310/bin" ;; esac From 1ee1dfff86f31b6738c92300b594ef711968790e Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Fri, 21 Jan 2022 20:50:07 -0700 Subject: [PATCH 05/12] upgrade numpy for py 3.10 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 13042943..6a19e417 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,6 @@ requires = [ "setuptools>=41.0.0", "wheel>=0.33.0", - "numpy<1.20.0", + "numpy<=1.22.1", "cython==0.29.24", ] \ No newline at end of file From 786cf68a4c0c86147100eac78124f0ff296e226e Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Fri, 21 Jan 2022 21:11:15 -0700 Subject: [PATCH 06/12] do not use req_build --- .ci/build_wheels.sh | 1 - requirements_build.txt | 5 ----- 2 files changed, 6 deletions(-) delete mode 100644 requirements_build.txt diff --git a/.ci/build_wheels.sh b/.ci/build_wheels.sh index 14bcc9f6..a27c6aab 100755 --- a/.ci/build_wheels.sh +++ b/.ci/build_wheels.sh @@ -31,7 +31,6 @@ esac # build, don't install cd io -"${PYBIN}/pip" install -r requirements_build.txt "${PYBIN}/python" setup.py bdist_wheel auditwheel repair dist/ansys_mapdl_reader*.whl rm -f dist/* diff --git a/requirements_build.txt b/requirements_build.txt deleted file mode 100644 index c79e6c8f..00000000 --- a/requirements_build.txt +++ /dev/null @@ -1,5 +0,0 @@ -setuptools>=41.0.0 -wheel>=0.33.0 -numpy<1.20.0 -cython==0.29.24 -matplotlib From 9c3fa424ebeaf8cb337d0e60e56ea60e174ed2c3 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Fri, 21 Jan 2022 21:29:59 -0700 Subject: [PATCH 07/12] add back in req_build --- requirements_build.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 requirements_build.txt diff --git a/requirements_build.txt b/requirements_build.txt new file mode 100644 index 00000000..97b2b3a3 --- /dev/null +++ b/requirements_build.txt @@ -0,0 +1,6 @@ +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 From c52f11a5361f5446fff992b1bc264711ebb98ef0 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Sat, 22 Jan 2022 08:33:36 -0700 Subject: [PATCH 08/12] use req in build --- .ci/build_wheels.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.ci/build_wheels.sh b/.ci/build_wheels.sh index a27c6aab..14bcc9f6 100755 --- a/.ci/build_wheels.sh +++ b/.ci/build_wheels.sh @@ -31,6 +31,7 @@ esac # build, don't install cd io +"${PYBIN}/pip" install -r requirements_build.txt "${PYBIN}/python" setup.py bdist_wheel auditwheel repair dist/ansys_mapdl_reader*.whl rm -f dist/* From 7d9e9a8f339c76ad25338408a9eb6554f1a5fe1b Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Sat, 22 Jan 2022 08:43:44 -0700 Subject: [PATCH 09/12] attempt to run all tests --- .github/workflows/testing-and-deployment.yml | 4 ++-- requirements_test.txt | 2 +- setup.py | 15 ++++++--------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index a70ab0ff..b17d868f 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -180,11 +180,11 @@ jobs: run: pip install -r requirements_test.txt - name: Test with XVFB - if: ${{ runner.os == 'Linux' }} || ${{ runner.python-version != '3.10' }} + if: ${{ runner.os == 'Linux' }} run: xvfb-run pytest -v tests/ --durations=0 - name: Test without XVFB - if: ${{ runner.os == 'Windows' }} || ${{ runner.python-version != '3.10' }} + if: ${{ runner.os == 'Windows' }} run: pytest -v tests/ --durations=0 - name: Upload wheel diff --git a/requirements_test.txt b/requirements_test.txt index f04789e1..08b95fcc 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -3,6 +3,6 @@ pytest matplotlib pytest pytest-cov -vtk<9.1.0 +vtk<9.1.0;python_version<"3.10" pyvista>=0.24.0 ansys-mapdl-core==0.60.4 diff --git a/setup.py b/setup.py index 7503c5c7..992d74f3 100644 --- a/setup.py +++ b/setup.py @@ -111,15 +111,12 @@ def compiler_name(): if sys.version_info.minor == 10 and is64: - # use pip to check if vtk is available or installed - sys_name = platform.system().lower() - if sys_name == 'linux': - install_requires.append( - 'vtk @ https://github.com/pyvista/pyvista-wheels/raw/main/vtk-9.1.0.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl', - ) - elif sys_name == 'windows': - install_requires.append( - 'vtk @ https://github.com/pyvista/pyvista-wheels/raw/main/vtk-9.1.0.dev0-cp310-cp310-win_amd64.whl', + # use dev wheels from pyvista until kitware releases VTK for 3.10 on PyPI + install_requires.append( + 'vtk @ https://github.com/pyvista/pyvista-wheels/raw/main/vtk-9.1.0.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl;platform_system=="Linux"', + ) + install_requires.append( + 'vtk @ https://github.com/pyvista/pyvista-wheels/raw/main/vtk-9.1.0.dev0-cp310-cp310-win_amd64.whl;platform_system=="Windows"', ) setup( From 0196de094df36d9b98fa2bcc5f106b451575dc8f Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Sat, 22 Jan 2022 09:00:36 -0700 Subject: [PATCH 10/12] fix install req --- setup.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 992d74f3..50501038 100644 --- a/setup.py +++ b/setup.py @@ -111,12 +111,15 @@ def compiler_name(): if sys.version_info.minor == 10 and is64: - # use dev wheels from pyvista until kitware releases VTK for 3.10 on PyPI - install_requires.append( - 'vtk @ https://github.com/pyvista/pyvista-wheels/raw/main/vtk-9.1.0.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl;platform_system=="Linux"', - ) - install_requires.append( - 'vtk @ https://github.com/pyvista/pyvista-wheels/raw/main/vtk-9.1.0.dev0-cp310-cp310-win_amd64.whl;platform_system=="Windows"', + # use pip to check if vtk is available or installed + sys_name = platform.system() + if sys_name == 'Linux': + install_requires.append( + 'vtk @ https://github.com/pyvista/pyvista-wheels/raw/main/vtk-9.1.0.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl', + ) + elif sys_name == 'Windows': + install_requires.append( + 'vtk @ https://github.com/pyvista/pyvista-wheels/raw/main/vtk-9.1.0.dev0-cp310-cp310-win_amd64.whl', ) setup( From 373820a96ca97ca7456f42afaa359493dafff0ae Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Sat, 22 Jan 2022 09:25:01 -0700 Subject: [PATCH 11/12] disable plot testing for 3.10 --- tests/test_cyclic.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_cyclic.py b/tests/test_cyclic.py index 0146aecb..41db732e 100644 --- a/tests/test_cyclic.py +++ b/tests/test_cyclic.py @@ -1,5 +1,6 @@ -import platform import os +import platform +import sys import numpy as np import pytest @@ -32,8 +33,10 @@ result_z = None IS_MAC = platform.system() == 'Darwin' -skip_plotting = pytest.mark.skipif(not system_supports_plotting() or IS_MAC, - reason="Requires active X Server") +skip_plotting = pytest.mark.skipif( + not system_supports_plotting() or IS_MAC or sys.version >= (3, 10), + reason="Plotting disabled for these tests" +) # static result x axis From 28b14b7c566ba576930e4ce398607ed4917987db Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Sat, 22 Jan 2022 09:42:29 -0700 Subject: [PATCH 12/12] check version correctly --- tests/test_cyclic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_cyclic.py b/tests/test_cyclic.py index 41db732e..270e5db1 100644 --- a/tests/test_cyclic.py +++ b/tests/test_cyclic.py @@ -34,7 +34,7 @@ IS_MAC = platform.system() == 'Darwin' skip_plotting = pytest.mark.skipif( - not system_supports_plotting() or IS_MAC or sys.version >= (3, 10), + not system_supports_plotting() or IS_MAC or sys.version_info >= (3, 10), reason="Plotting disabled for these tests" )