From 7cc261865d918b6ec088161e48ac470791745abf Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 22 Oct 2020 21:42:45 -0400 Subject: [PATCH 1/5] feat: use pyproject.toml instead --- .appveyor.yml | 4 ++-- .github/workflows/wheels.yml | 6 ++---- pyproject.toml | 8 ++++++++ setup.py | 15 +++------------ 4 files changed, 15 insertions(+), 18 deletions(-) create mode 100644 pyproject.toml diff --git a/.appveyor.yml b/.appveyor.yml index cf8ccf8..5cbe4b8 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -16,10 +16,10 @@ install: - ps: | if ($env:PLATFORM -eq "x64") { $env:PYTHON = "$env:PYTHON-x64" } $env:PATH = "C:\Python$env:PYTHON\;C:\Python$env:PYTHON\Scripts\;$env:PATH" - python -m pip install --disable-pip-version-check --upgrade --no-warn-script-location pip setuptools + python -m pip install --disable-pip-version-check --upgrade --no-warn-script-location pip build build_script: - ps: | - python setup.py sdist + python -m build -s cd dist python -m pip install --verbose python_example-0.0.1.tar.gz cd .. diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 94df2a6..5679998 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -12,8 +12,6 @@ on: env: CIBW_TEST_COMMAND: python {project}/tests/test.py - # This can be removed if pyproject.toml is used - CIBW_BEFORE_BUILD: pip install pybind11 jobs: @@ -25,10 +23,10 @@ jobs: - uses: actions/setup-python@v2 - name: Install deps - run: python -m pip install "setuptools>=42" "setuptools_scm[toml]>=4.1.0" twine + run: python -m pip install twine build - name: Build SDist - run: python setup.py sdist + run: python -m build -s - name: Check metadata run: twine check dist/* diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..89ae1ed --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,8 @@ +[build-system] +requires = [ + "setuptools>=42", + "wheel", + "pybind11>=2.6.0", +] + +build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index b494a9d..38ea7f7 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,8 @@ from setuptools import setup -# With setup_requires, this runs twice - once without setup_requires, and once -# with. The build only happens the second time. -try: - from pybind11.setup_helpers import Pybind11Extension, build_ext - from pybind11 import get_cmake_dir -except ImportError: - from setuptools import Extension as Pybind11Extension - from setuptools.command.build_ext import build_ext +# Available at setup time due to pyproject.toml +from pybind11.setup_helpers import Pybind11Extension, build_ext +from pybind11 import get_cmake_dir import sys @@ -39,10 +34,6 @@ description="A test project using pybind11", long_description="", ext_modules=ext_modules, - # Note: You have to add pybind11 to both setup and install requires to make - # it available during the build. Using PEP 518's pyproject.toml is better! - setup_requires=["pybind11==2.6.0"], - install_requires=["pybind11==2.6.0"], extras_require={"test": "pytest"}, # Currently, build_ext only provides an optional "highest supported C++ # level" feature, but in the future it may provide more features. From 39717fc8dea77cf8a18ad43b5ca06077baa62fee Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 23 Oct 2020 11:06:57 -0400 Subject: [PATCH 2/5] ci: travis updates --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 00b06da..d033e75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,6 +31,7 @@ before_install: python -m pip install --user virtualenv virtualenv -p python${PYTHON:0:1} venv source venv/bin/activate + python -m pip install build elif [ -n "$CONDA" ]; then if [ "$TRAVIS_OS_NAME" = "linux" ]; then OS=Linux-x86_64; else OS=MacOSX-x86_64; fi wget -O miniconda.sh https://repo.continuum.io/miniconda/Miniconda${CONDA:0:1}-latest-$OS.sh @@ -46,7 +47,7 @@ before_install: install: - | if [ -n "$PYTHON" ]; then - python setup.py sdist + python -m build -s python -m pip install --verbose dist/*.tar.gz elif [ -n "$CONDA" ]; then conda build conda.recipe --python $CONDA From 0a593c363d9d631bedd5d18979d1cf96bdbbedb5 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 23 Oct 2020 23:15:35 -0400 Subject: [PATCH 3/5] fix: just install on travis --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d033e75..d530a16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,6 @@ before_install: python -m pip install --user virtualenv virtualenv -p python${PYTHON:0:1} venv source venv/bin/activate - python -m pip install build elif [ -n "$CONDA" ]; then if [ "$TRAVIS_OS_NAME" = "linux" ]; then OS=Linux-x86_64; else OS=MacOSX-x86_64; fi wget -O miniconda.sh https://repo.continuum.io/miniconda/Miniconda${CONDA:0:1}-latest-$OS.sh @@ -47,8 +46,7 @@ before_install: install: - | if [ -n "$PYTHON" ]; then - python -m build -s - python -m pip install --verbose dist/*.tar.gz + python -m pip install . elif [ -n "$CONDA" ]; then conda build conda.recipe --python $CONDA conda install --use-local python_example From b9bdc6a6106f361a88736297c75c87dc3675c420 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 23 Oct 2020 23:59:15 -0400 Subject: [PATCH 4/5] fix: include macOS version --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index d530a16..b9c07fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,7 @@ before_install: if [ -n "$PYTHON" ]; then if [ "$TRAVIS_OS_NAME" = "osx" ]; then export PATH="/Users/travis/Library/Python/2.7/bin:$PATH" + export MACOSX_DEPLOYMENT_TARGET="10_13" if [ "${PYTHON:0:1}" = "3" ]; then brew update; brew install python3; fi From 61e2a1fef1d2ed673d8b2fff73475a5a513a6f4d Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Sat, 24 Oct 2020 00:46:02 -0400 Subject: [PATCH 5/5] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b9c07fa..8af5883 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ before_install: if [ -n "$PYTHON" ]; then if [ "$TRAVIS_OS_NAME" = "osx" ]; then export PATH="/Users/travis/Library/Python/2.7/bin:$PATH" - export MACOSX_DEPLOYMENT_TARGET="10_13" + export MACOSX_DEPLOYMENT_TARGET="10.13" if [ "${PYTHON:0:1}" = "3" ]; then brew update; brew install python3; fi