Skip to content

Commit

Permalink
fixed builds for cython
Browse files Browse the repository at this point in the history
  • Loading branch information
akaszynski committed Jul 1, 2020
1 parent 939a736 commit b673532
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 142 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pymeshfix/cython/_meshfix.cpp

# Pip generated folders #
#########################
*.egg-info/
*.egg*
build/
dist/

Expand Down
17 changes: 0 additions & 17 deletions build.sh

This file was deleted.

45 changes: 0 additions & 45 deletions docker.sh

This file was deleted.

42 changes: 0 additions & 42 deletions dockerbuild.sh

This file was deleted.

2 changes: 1 addition & 1 deletion pymeshfix/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""pymeshfix version"""
version_info = 0, 14, 1
version_info = 0, 14, 2
__version__ = '.'.join(map(str, version_info))
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools >= 40.6.0", "wheel", "numpy", "cython"]
build-backend = "setuptools.build_meta"
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

40 changes: 33 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import os
import builtins

# workaround for *.toml https://github.com/pypa/pip/issues/7953
import site
site.ENABLE_USER_SITE = "--user" in sys.argv[1:]


from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext as _build_ext

Expand Down Expand Up @@ -37,6 +42,26 @@
# readme file
readme_file = os.path.join(filepath, 'README.rst')


def needs_cython():
"""Check if cython source exist"""
tgt_path = os.path.join('pymeshfix', 'cython')
has_cython_src = any(['_meshfix.cpp' in fname for fname in os.listdir(tgt_path)])
if not has_cython_src:
try:
import cython
except:
raise ImportError('Please install cython to build ``pymeshfix``')
return not has_cython_src


def needs_numpy():
"""Check if cython source exist"""
tgt_path = os.path.join('pymeshfix')
has_cython_src = any(['_meshfix' in fname for fname in os.listdir(tgt_path)])
return not has_cython_src


# for: the cc1plus: warning: command line option '-Wstrict-prototypes'
class build_ext(_build_ext):
def finalize_options(self):
Expand All @@ -56,12 +81,12 @@ def build_extensions(self):
pass
_build_ext.build_extensions(self)

try:
import numpy
except ImportError:
build_requires = ['numpy']
else:
build_requires = []

setup_requires = []
if needs_cython():
setup_requires.extend(['cython'])
if needs_numpy():
setup_requires.extend(['numpy'])


setup(
Expand Down Expand Up @@ -114,5 +139,6 @@ def build_extensions(self):
package_data={'pymeshfix/examples': ['StanfordBunny.ply',
'planar_mesh.ply']},
install_requires=['numpy>1.11.0',
'pyvista>=0.23.0']
'pyvista>=0.23.0'],
setup_requires=setup_requires,
)
27 changes: 0 additions & 27 deletions windows_build.bat

This file was deleted.

0 comments on commit b673532

Please sign in to comment.