diff --git a/setup.py b/setup.py index 4785a792..1f9640c6 100644 --- a/setup.py +++ b/setup.py @@ -43,11 +43,15 @@ cmake_args = [ f'-DNETGEN_VERSION_PYTHON={version}', ] -if 'NETGEN_ARCH' in os.environ: - arch = os.environ['NETGEN_ARCH'] - name += "-"+arch - flag = '/'+arch if 'win' in sys.platform else '-march=core-avx2' - cmake_args += [f'-DNG_COMPILE_FLAGS={flag}'] +if 'NETGEN_ARCH' in os.environ and os.environ['NETGEN_ARCH'] == 'avx2': + # build for avx2 architecture + if 'darwin' in sys.platform: + flag = "'-Xarch_x86_64;-march=core-avx2'" + elif 'win' in sys.platform: + flag = '/AVX2' + else: + flag = '-march=core-avx2' + cmake_args += [f'-DNG_COMPILE_FLAGS={flag}'] if 'NETGEN_CCACHE' in os.environ: cmake_args += [f'-DUSE_CCACHE=ON'] diff --git a/tests/build_pip.ps1 b/tests/build_pip.ps1 index 68af2952..37fe3049 100644 --- a/tests/build_pip.ps1 +++ b/tests/build_pip.ps1 @@ -6,6 +6,7 @@ if (test-path dist) { } $env:NETGEN_CCACHE = 1 +$env:NETGEN_ARCH = avx2 $pydir=$args[0] & $pydir\python.exe --version diff --git a/tests/build_pip.sh b/tests/build_pip.sh index b4e3299a..363ba584 100755 --- a/tests/build_pip.sh +++ b/tests/build_pip.sh @@ -14,15 +14,11 @@ do $PYDIR/pip install -U pytest-check numpy wheel scikit-build pybind11-stubgen rm -rf _skbuild + NETGEN_ARCH=avx2 $PYDIR/pip wheel . $PYDIR/pip wheel . auditwheel repair netgen_mesher*-cp${pyversion}-*.whl rm netgen_mesher-*.whl - rm -rf _skbuild - NETGEN_ARCH=avx2 $PYDIR/pip wheel . - auditwheel repair netgen_mesher_avx2*-cp${pyversion}-*.whl - rm netgen_mesher_avx2-*.whl - $PYDIR/pip install wheelhouse/netgen_mesher*-cp${pyversion}-*.whl $PYDIR/python3 -c 'import netgen' #cd ../tests/pytest diff --git a/tests/build_pip_mac.sh b/tests/build_pip_mac.sh index f07655e5..22ea0d4f 100755 --- a/tests/build_pip_mac.sh +++ b/tests/build_pip_mac.sh @@ -9,5 +9,6 @@ $PYDIR/python3 --version $PYDIR/pip3 install --user numpy twine scikit-build wheel pybind11-stubgen export CMAKE_OSX_ARCHITECTURES='arm64;x86_64' +export NETGEN_ARCH='avx2' $PYDIR/python3 setup.py bdist_wheel --plat-name macosx-10.15-universal2 -j10 $PYDIR/python3 -m twine upload dist/*.whl