Skip to content

Commit 674ed9b

Browse files
authored
Merge pull request #126 from nschloe/new-pybind11
New pybind11
2 parents f5e7d9f + c171b47 commit 674ed9b

4 files changed

Lines changed: 15 additions & 108 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ jobs:
3434
- uses: actions/checkout@v2
3535
with:
3636
lfs: true
37-
- name: Install CGAL 5 from PPA
37+
- name: Install CGAL 5
3838
run: |
39-
sudo apt-get install -y software-properties-common
40-
sudo apt-add-repository -y ppa:nschloe/cgal-backports
41-
sudo apt update
39+
# Leave that here in case we ever need a PPA again
40+
# sudo apt-get install -y software-properties-common
41+
# sudo apt-add-repository -y ppa:nschloe/cgal-backports
42+
# sudo apt update
4243
sudo apt install -y libcgal-dev
4344
- name: Install other dependencies
4445
run: |
@@ -47,5 +48,4 @@ jobs:
4748
run: |
4849
pip install tox
4950
CC="clang" tox
50-
- name: Submit to codecov
51-
run: bash <(curl -s https://codecov.io/bash)
51+
- uses: codecov/codecov-action@v1

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[build-system]
2-
requires = ["setuptools>=42", "wheel"]
2+
requires = ["setuptools>=42", "wheel", "pybind11>=2.6.0"]
33
build-backend = "setuptools.build_meta"

setup.cfg

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[metadata]
22
name = pygalmesh
3-
version = 0.9.1
3+
version = 0.9.2
44
url = https://github.com/nschloe/pygalmesh
55
author = Nico Schlömer
66
author_email = nico.schloemer@gmail.com
77
description = Python frontend to CGAL's mesh generation capabilities
88
long_description = file: README.md
99
long_description_content_type = text/markdown
1010
license = GPL-3.0-or-later
11-
license_files = LICENSE
11+
license_file = LICENSE
1212
classifiers =
1313
Development Status :: 4 - Beta
1414
License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
@@ -31,12 +31,10 @@ keywords =
3131
3232
[options]
3333
packages = find:
34-
setup_requires = pybind11 >= 2.5
3534
install_requires =
3635
importlib_metadata;python_version<"3.8"
3736
meshio >= 4.0.0, < 5.0.0
3837
numpy
39-
pybind11 >= 2.5
4038
python_requires = >=3.6
4139
4240
[options.entry_points]

setup.py

Lines changed: 6 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,11 @@
11
import os
2-
import sys
3-
4-
import setuptools
5-
from setuptools import Extension, setup
6-
from setuptools.command.build_ext import build_ext
7-
8-
9-
# <https://github.com/pybind/python_example/blob/master/setup.py>
10-
class get_pybind_include(object):
11-
"""Helper class to determine the pybind11 include path
12-
The purpose of this class is to postpone importing pybind11
13-
until it is actually installed, so that the ``get_include()``
14-
method can be invoked."""
15-
16-
def __str__(self):
17-
import pybind11
18-
19-
return pybind11.get_include()
20-
21-
22-
# cf http://bugs.python.org/issue26689
23-
def has_flag(compiler, flagname):
24-
"""Return a boolean indicating whether a flag name is supported on
25-
the specified compiler.
26-
"""
27-
import os
28-
import tempfile
29-
30-
with tempfile.NamedTemporaryFile("w", suffix=".cpp", delete=False) as f:
31-
f.write("int main (int argc, char **argv) { return 0; }")
32-
fname = f.name
33-
try:
34-
compiler.compile([fname], extra_postargs=[flagname])
35-
except setuptools.distutils.errors.CompileError:
36-
return False
37-
finally:
38-
try:
39-
os.remove(fname)
40-
except OSError:
41-
pass
42-
return True
43-
44-
45-
def cpp_flag(compiler):
46-
"""Return the -std=c++[11/14/17] compiler flag.
47-
The newer version is prefered over c++11 (when it is available).
48-
"""
49-
flags = ["-std=c++17", "-std=c++14", "-std=c++11"]
50-
51-
for flag in flags:
52-
if has_flag(compiler, flag):
53-
return flag
54-
55-
raise RuntimeError("Unsupported compiler -- at least C++11 support " "is needed!")
56-
57-
58-
class BuildExt(build_ext):
59-
"""A custom build extension for adding compiler-specific options."""
60-
61-
c_opts = {
62-
"msvc": ["/EHsc"],
63-
"unix": [],
64-
}
65-
l_opts = {
66-
"msvc": [],
67-
"unix": [],
68-
}
69-
70-
if sys.platform == "darwin":
71-
darwin_opts = ["-stdlib=libc++", "-mmacosx-version-min=10.7"]
72-
c_opts["unix"] += darwin_opts
73-
l_opts["unix"] += darwin_opts
74-
75-
def build_extensions(self):
76-
ct = self.compiler.compiler_type
77-
opts = self.c_opts.get(ct, [])
78-
link_opts = self.l_opts.get(ct, [])
79-
if ct == "unix":
80-
opts.append(cpp_flag(self.compiler))
81-
if has_flag(self.compiler, "-fvisibility=hidden"):
82-
opts.append("-fvisibility=hidden")
83-
84-
for ext in self.extensions:
85-
ext.define_macros = [
86-
("VERSION_INFO", '"{}"'.format(self.distribution.get_version()))
87-
]
88-
ext.extra_compile_args = opts
89-
ext.extra_link_args = link_opts
90-
build_ext.build_extensions(self)
912

3+
from pybind11.setup_helpers import Pybind11Extension, build_ext
4+
from setuptools import setup
925

6+
# https://github.com/pybind/python_example/
937
ext_modules = [
94-
Extension(
8+
Pybind11Extension(
959
"_pygalmesh",
9610
# Sort input source files to ensure bit-for-bit reproducible builds
9711
# (https://github.com/pybind/python_example/pull/53)
@@ -107,20 +21,15 @@ def build_extensions(self):
10721
"src/pybind11.cpp",
10822
]
10923
),
110-
include_dirs=[
111-
os.environ.get("EIGEN_INCLUDE_DIR", "/usr/include/eigen3/"),
112-
# Path to pybind11 headers
113-
get_pybind_include(),
114-
],
115-
language="c++",
24+
include_dirs=[os.environ.get("EIGEN_INCLUDE_DIR", "/usr/include/eigen3/")],
11625
# no CGAL libraries necessary from CGAL 5.0 onwards
11726
libraries=["gmp", "mpfr"],
11827
)
11928
]
12029

12130
if __name__ == "__main__":
12231
setup(
123-
cmdclass={"build_ext": BuildExt},
32+
cmdclass={"build_ext": build_ext},
12433
ext_modules=ext_modules,
12534
zip_safe=False,
12635
)

0 commit comments

Comments
 (0)