Skip to content

Commit fc12654

Browse files
authored
feat: use pyproject.toml instead (#64)
* feat: use pyproject.toml instead * ci: travis updates * fix: just install on travis * fix: include macOS version * Update .travis.yml
1 parent 2c99526 commit fc12654

File tree

5 files changed

+17
-20
lines changed

5 files changed

+17
-20
lines changed

.appveyor.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ install:
1616
- ps: |
1717
if ($env:PLATFORM -eq "x64") { $env:PYTHON = "$env:PYTHON-x64" }
1818
$env:PATH = "C:\Python$env:PYTHON\;C:\Python$env:PYTHON\Scripts\;$env:PATH"
19-
python -m pip install --disable-pip-version-check --upgrade --no-warn-script-location pip setuptools
19+
python -m pip install --disable-pip-version-check --upgrade --no-warn-script-location pip build
2020
build_script:
2121
- ps: |
22-
python setup.py sdist
22+
python -m build -s
2323
cd dist
2424
python -m pip install --verbose python_example-0.0.1.tar.gz
2525
cd ..

.github/workflows/wheels.yml

+2-4
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:
@@ -25,10 +23,10 @@ jobs:
2523
- uses: actions/setup-python@v2
2624

2725
- name: Install deps
28-
run: python -m pip install "setuptools>=42" "setuptools_scm[toml]>=4.1.0" twine
26+
run: python -m pip install twine build
2927

3028
- name: Build SDist
31-
run: python setup.py sdist
29+
run: python -m build -s
3230

3331
- name: Check metadata
3432
run: twine check dist/*

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ before_install:
2424
if [ -n "$PYTHON" ]; then
2525
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
2626
export PATH="/Users/travis/Library/Python/2.7/bin:$PATH"
27+
export MACOSX_DEPLOYMENT_TARGET="10.13"
2728
if [ "${PYTHON:0:1}" = "3" ]; then
2829
brew update; brew install python3;
2930
fi
@@ -46,8 +47,7 @@ before_install:
4647
install:
4748
- |
4849
if [ -n "$PYTHON" ]; then
49-
python setup.py sdist
50-
python -m pip install --verbose dist/*.tar.gz
50+
python -m pip install .
5151
elif [ -n "$CONDA" ]; then
5252
conda build conda.recipe --python $CONDA
5353
conda install --use-local python_example

pyproject.toml

+8
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

+3-12
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)