Skip to content

Commit

Permalink
build python 3.10 (#101)
Browse files Browse the repository at this point in the history
* add py310 req and setup

* add back missing CI

* fix build_wheels.sh

* correct terms

* upgrade numpy for py 3.10

* do not use req_build

* add back in req_build

* use req in build

* attempt to run all tests

* fix install req

* disable plot testing for 3.10

* check version correctly
  • Loading branch information
akaszynski authored Jan 31, 2022
1 parent 4480491 commit 0861e9f
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 69 deletions.
3 changes: 3 additions & 0 deletions .ci/build_wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ case $PYTHON_VERSION in
3.9)
PYBIN="/opt/python/cp39-cp39/bin"
;;
3.10)
PYBIN="/opt/python/cp310-cp310/bin"
;;
esac

# build, don't install
Expand Down
22 changes: 8 additions & 14 deletions .github/workflows/testing-and-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
run: |
pip install -r requirements_style.txt --disable-pip-version-check
make
doc_build:
name: Build Documentation
runs-on: ubuntu-latest
Expand All @@ -48,15 +47,13 @@ jobs:
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
Expand All @@ -65,7 +62,6 @@ jobs:
sudo apt install zip
cd doc/build/html/
zip ../../../${{ env.PACKAGE_NAME }}-HTML.zip ./*
- name: Upload
uses: actions/upload-artifact@v2
with:
Expand All @@ -89,7 +85,7 @@ jobs:
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:
Expand Down Expand Up @@ -135,9 +131,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: |
Expand Down Expand Up @@ -181,17 +176,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
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
run: pytest -v tests/ --durations=0

- name: Upload wheel
uses: actions/upload-artifact@v2
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build-system]
requires = [
"setuptools>=41.0.0",
"wheel>=0.33.0",
"numpy<=1.22.1",
"cython==0.29.24",
]
5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

3 changes: 2 additions & 1 deletion requirements_build.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
setuptools>=41.0.0
wheel>=0.33.0
numpy<1.20.0
numpy<1.20.0;python_version<"3.10"
numpy==1.22.1;python_version>="3.10"
cython==0.29.24
matplotlib
2 changes: 1 addition & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
77 changes: 32 additions & 45 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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':
Expand All @@ -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
Expand All @@ -104,7 +74,7 @@ def compilerName():


# Assign arguments based on compiler
compiler = compilerName()
compiler = compiler_name()
if compiler == 'unix':
cmp_arg = ['-O3', '-w']
else:
Expand All @@ -119,24 +89,39 @@ 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:
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)

# Actual setup

if sys.version_info.minor == 10 and is64:
# 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(
name='ansys-mapdl-reader',
packages=['ansys.mapdl.reader', 'ansys.mapdl.reader.examples'],
Expand All @@ -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',
Expand Down
9 changes: 6 additions & 3 deletions tests/test_cyclic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import platform
import os
import platform
import sys

import numpy as np
import pytest
Expand Down Expand Up @@ -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_info >= (3, 10),
reason="Plotting disabled for these tests"
)


# static result x axis
Expand Down

0 comments on commit 0861e9f

Please sign in to comment.