From fc39971bdc1872ec78c3d2d664e1af9dc3981187 Mon Sep 17 00:00:00 2001 From: Pieter Pas Date: Sun, 31 Jul 2022 17:07:06 +0200 Subject: [PATCH] Python 3.6 support --- examples/minimal-program/pyproject.toml | 3 ++- examples/minimal-program/test/test_minimal_program.py | 2 +- examples/minimal/pyproject.toml | 3 ++- examples/pybind11-project/cmake/Pybind11Stubgen.cmake | 9 ++++++++- examples/pybind11-project/pyproject.toml | 3 ++- pyproject.toml | 11 ++++++++--- 6 files changed, 23 insertions(+), 8 deletions(-) diff --git a/examples/minimal-program/pyproject.toml b/examples/minimal-program/pyproject.toml index 972a2d3..7c12cce 100644 --- a/examples/minimal-program/pyproject.toml +++ b/examples/minimal-program/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "minimal-program" readme = "README.md" -requires-python = ">=3.7" +requires-python = ">=3.6" license = { "file" = "LICENSE" } authors = [{ "name" = "Pieter P", "email" = "pieter.p.dev@outlook.com" }] keywords = ["program", "script", "binary", "executable"] @@ -9,6 +9,7 @@ classifiers = [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", diff --git a/examples/minimal-program/test/test_minimal_program.py b/examples/minimal-program/test/test_minimal_program.py index 69d9be0..8596f3f 100644 --- a/examples/minimal-program/test/test_minimal_program.py +++ b/examples/minimal-program/test/test_minimal_program.py @@ -2,5 +2,5 @@ import os def test_run_program(): - res = subprocess.run(["minimal_program"], capture_output=True) + res = subprocess.run(["minimal_program"], stdout=subprocess.PIPE) assert res.stdout.decode("utf-8") == "Hello, world!" + os.linesep diff --git a/examples/minimal/pyproject.toml b/examples/minimal/pyproject.toml index cdce3af..b650eed 100644 --- a/examples/minimal/pyproject.toml +++ b/examples/minimal/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "minimal" readme = "README.md" -requires-python = ">=3.7" +requires-python = ">=3.6" license = { "file" = "LICENSE" } authors = [{ "name" = "Pieter P", "email" = "pieter.p.dev@outlook.com" }] keywords = ["addition", "subtraction", "pybind11"] @@ -9,6 +9,7 @@ classifiers = [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", diff --git a/examples/pybind11-project/cmake/Pybind11Stubgen.cmake b/examples/pybind11-project/cmake/Pybind11Stubgen.cmake index fd56cdc..1ba112b 100644 --- a/examples/pybind11-project/cmake/Pybind11Stubgen.cmake +++ b/examples/pybind11-project/cmake/Pybind11Stubgen.cmake @@ -1,8 +1,15 @@ function(pybind11_stubgen target) find_package(Python3 REQUIRED COMPONENTS Interpreter) + execute_process(COMMAND ${Python3_EXECUTABLE} + -c "import os; print(os.pathsep)" + OUTPUT_VARIABLE PY_PATH_SEP + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REPLACE ";" "\\;" PY_PATH_SEP "${PY_PATH_SEP}") + set(PY_PATH "$${PY_PATH_SEP}$ENV{PYTHONPATH}") add_custom_command(TARGET ${target} POST_BUILD - COMMAND ${Python3_EXECUTABLE} -m pybind11_stubgen + COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH="${PY_PATH}" + ${Python3_EXECUTABLE} -m pybind11_stubgen $ --bare-numpy-ndarray --no-setup-py diff --git a/examples/pybind11-project/pyproject.toml b/examples/pybind11-project/pyproject.toml index ca34835..8cfb6df 100644 --- a/examples/pybind11-project/pyproject.toml +++ b/examples/pybind11-project/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "pybind11-project" # Name on PyPI readme = "README.md" -requires-python = ">=3.7" +requires-python = ">=3.6" license = { "file" = "LICENSE" } authors = [{ "name" = "Pieter P", "email" = "pieter.p.dev@outlook.com" }] keywords = ["addition", "subtraction", "pybind11"] @@ -9,6 +9,7 @@ classifiers = [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", diff --git a/pyproject.toml b/pyproject.toml index c30072a..0647e59 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,12 @@ [build-system] -requires = ["distlib", "flit"] +requires = ["distlib", "flit", "dataclasses; python_version < '3.7'"] build-backend = "py_build_cmake.build" backend-path = ["src"] [project] name = "py-build-cmake" readme = "README.md" -requires-python = ">=3.7" +requires-python = ">=3.6" license = { "file" = "LICENSE" } authors = [{ "name" = "Pieter P", "email" = "pieter.p.dev@outlook.com" }] keywords = ["pep517", "cmake"] @@ -14,6 +14,7 @@ classifiers = [ "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", @@ -22,7 +23,11 @@ classifiers = [ "Operating System :: Microsoft :: Windows", "Operating System :: MacOS", ] -dependencies = ["distlib~=0.3.5", "flit~=3.7"] +dependencies = [ + "distlib~=0.3.5", + "flit~=3.7", + "dataclasses; python_version < '3.7'", +] dynamic = ["version", "description"] [project.urls]