Skip to content
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macos-11]
os: [ubuntu-22.04, windows-2019, macos-11]

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Build wheels
uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_ARCHS_MACOS: x86_64 arm64
CIBW_TEST_SKIP: "*_arm64 *_universal2:arm64"
uses: pypa/cibuildwheel@v2.17.0

- name: Show files
run: ls -lh wheelhouse
Expand Down
45 changes: 44 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,49 @@
requires = [
"setuptools>=42",
"wheel",
"pybind11~=2.6",
"pybind11==2.12.0",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe put a >= in here?

"tomli>=0.10; python_version<'3.11'",
]
build-backend = "setuptools.build_meta"

[project]
name = "mapbox_earcut"
version = "1.0.2"
requires-python = ">=3.7"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be >=3.9:

  1. 3.7 is getting pretty old

  2. numpy 2.0 isn't available for < 3.9 anyway.

authors = [{name = "Samuel Kogler", email = "samuel.kogler@gmail.com"}]
license = {file = "LICENSE.md"}
description = "Python bindings for the mapbox earcut C++ polygon triangulation library."
dependencies = ["numpy>=1.19.0"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe > 1.24? -- not entirely sure how far back the 2.0 compatibility goes -- but no on e needs an ancient numpy :-)


[project.urls]
Source = "https://github.com/skogler/mapbox_earcut_python"
CSource = "https://github.com/mapbox/earcut.hpp"

[project.readme]
file = "README.md"
content-type = "text/markdown"

[tool.setuptools]
zip-safe = false
include-package-data = true

[project.optional-dependencies]
test = ["pytest"]


[tool.cibuildwheel]
# install the `test` extra
test-extras = ["test"]

# Run the package tests using `pytest`
# also test against pre-release Numpy
# TODO : when numpy 2.0 releases this can be reduced to just one pytest
test-command = ["pytest {package}/tests",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this work? the tests aren't in the sdist -- I had to put acopy of the test fijles in the conda recipe to get the tests to run.

really, they should be installed with the package -- they are small, and it's realy good to be able to directly test the installed distro with a compiled package like this.

"pip install --force-reinstall --upgrade --pre numpy",
"pytest {package}/tests"]

# don't test on PyPy as it will re-build numpy

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this workin PyPy at all? I give up on that on the conda-forge build.

test-skip = "*_arm64 *_universal2:arm64 pp*"

[tool.cibuildwheel.macos]
archs = ["x86_64", "arm64"]
62 changes: 33 additions & 29 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,44 @@
from setuptools import setup

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we really should move to a "modern" build -- e.g. not putting code in setup.py.

maybe even scikit build?

from pybind11.setup_helpers import Pybind11Extension, build_ext

FILE_DIR = os.path.dirname(os.path.abspath(__file__))
VERSION = '1.0.1'

def _get_version() -> str:
"""
Get the version defined in `pyproject.toml` to prevent
requiring the version to be specified in two places.

Note that Python only introduced a TOML parser in
Python 3.11 so this requires `pip install tomli` for older
versions of Python.
"""
try:
# we could also do this with
# if `sys.version_info >= (3, 11)`
from tomllib import load
except BaseException:
# a parser with the same API from pypi
from tomli import load

# current working directory
cwd = os.path.abspath(os.path.expanduser(os.path.dirname(__file__)))
# file-relative pyproject path
path = os.path.join(cwd, "pyproject.toml")
with open(path, "rb") as f:
pyproject = load(f)

return pyproject["project"]["version"]


ext_modules = [
Pybind11Extension('mapbox_earcut',
['src/main.cpp'],
include_dirs=['include'],
define_macros = [('VERSION_INFO', VERSION)],
),
Pybind11Extension(
"mapbox_earcut",
["src/main.cpp"],
include_dirs=["include"],
define_macros=[("VERSION_INFO", _get_version())],
),
]

def get_readme_contents():
with open(os.path.join(FILE_DIR, 'README.md'), 'r') as readme_file:
return readme_file.read()

setup(
name='mapbox_earcut',
version=VERSION,
url='https://github.com/skogler/mapbox_earcut_python',
author='Samuel Kogler',
author_email='samuel.kogler@gmail.com',
description=
'Python bindings for the mapbox earcut C++ polygon triangulation library.',
long_description=get_readme_contents(),
long_description_content_type='text/markdown',
license='ISC',
ext_modules=ext_modules,
install_requires=['numpy'],
extras_require={'test': 'pytest'},
cmdclass=dict(build_ext=build_ext),
zip_safe=False,
project_urls={
'Source': 'https://github.com/skogler/mapbox_earcut_python',
'Original C++ Source': 'https://github.com/mapbox/earcut.hpp',
},
include_package_data = True
)
1 change: 0 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ PYBIND11_MODULE(mapbox_earcut, m)
m.def("triangulate_float64", &triangulate<double, uint32_t>);

#ifdef VERSION_INFO

m.attr("__version__") = MACRO_TO_STR(VERSION_INFO) ;
#else
m.attr("__version__") = "dev";
Expand Down