Skip to content

Commit

Permalink
Python 3.6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
tttapa committed Jul 31, 2022
1 parent 6373a96 commit fc39971
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
3 changes: 2 additions & 1 deletion examples/minimal-program/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[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"]
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",
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal-program/test/test_minimal_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion examples/minimal/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[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"]
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",
Expand Down
9 changes: 8 additions & 1 deletion examples/pybind11-project/cmake/Pybind11Stubgen.cmake
Original file line number Diff line number Diff line change
@@ -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 "$<TARGET_FILE_DIR:${target}>${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
$<TARGET_FILE_BASE_NAME:${target}>
--bare-numpy-ndarray
--no-setup-py
Expand Down
3 changes: 2 additions & 1 deletion examples/pybind11-project/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[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"]
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",
Expand Down
11 changes: 8 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
[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"]
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",
Expand All @@ -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]
Expand Down

0 comments on commit fc39971

Please sign in to comment.