Skip to content

Commit 58bb0e2

Browse files
committed
feat: use pyproject.toml instead
1 parent 2c99526 commit 58bb0e2

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

.github/workflows/wheels.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ on:
1212

1313
env:
1414
CIBW_TEST_COMMAND: python {project}/tests/test.py
15-
# This can be removed if pyproject.toml is used
16-
CIBW_BEFORE_BUILD: pip install pybind11
1715

1816

1917
jobs:

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[build-system]
2+
requires = [
3+
"setuptools>=42",
4+
"wheel",
5+
"pybind11>=2.6.0",
6+
]
7+
8+
build-backend = "setuptools.build_meta"

setup.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
from setuptools import setup
22

3-
# With setup_requires, this runs twice - once without setup_requires, and once
4-
# with. The build only happens the second time.
5-
try:
6-
from pybind11.setup_helpers import Pybind11Extension, build_ext
7-
from pybind11 import get_cmake_dir
8-
except ImportError:
9-
from setuptools import Extension as Pybind11Extension
10-
from setuptools.command.build_ext import build_ext
3+
# Available at setup time due to pyproject.toml
4+
from pybind11.setup_helpers import Pybind11Extension, build_ext
5+
from pybind11 import get_cmake_dir
116

127
import sys
138

@@ -39,10 +34,6 @@
3934
description="A test project using pybind11",
4035
long_description="",
4136
ext_modules=ext_modules,
42-
# Note: You have to add pybind11 to both setup and install requires to make
43-
# it available during the build. Using PEP 518's pyproject.toml is better!
44-
setup_requires=["pybind11==2.6.0"],
45-
install_requires=["pybind11==2.6.0"],
4637
extras_require={"test": "pytest"},
4738
# Currently, build_ext only provides an optional "highest supported C++
4839
# level" feature, but in the future it may provide more features.

0 commit comments

Comments
 (0)