Skip to content

DO NOT MERGE: trying out setuptools PR #3711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
matrix:
runs-on: [ubuntu-latest, windows-2022, macos-latest]
python:
- '3.6'
- '3.7'
- '3.9'
- '3.10'
- 'pypy-3.7'
Expand All @@ -41,12 +41,12 @@ jobs:
include:
# Just add a key
- runs-on: ubuntu-latest
python: '3.6'
python: '3.7'
args: >
-DPYBIND11_FINDPYTHON=ON
-DCMAKE_CXX_FLAGS="-D_=1"
- runs-on: windows-2019
python: '3.6'
python: '3.7'
args: >
-DPYBIND11_FINDPYTHON=ON
# Inject a couple Windows 2019 runs
Expand All @@ -66,7 +66,7 @@ jobs:

- name: Setup Boost (Linux)
# Can't use boost + define _
if: runner.os == 'Linux' && matrix.python != '3.6'
if: runner.os == 'Linux' && matrix.python != '3.7'
run: sudo apt-get install libboost-dev

- name: Setup Boost (macOS)
Expand Down Expand Up @@ -705,7 +705,6 @@ jobs:
fail-fast: false
matrix:
python:
- 3.6
- 3.7
- 3.8
- 3.9
Expand Down Expand Up @@ -762,7 +761,6 @@ jobs:
fail-fast: false
matrix:
python:
- 3.6
- 3.7
std:
- 14
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ env:

jobs:
# This builds the sdists and wheels and makes sure the files are exactly as
# expected. Using Windows and Python 3.6, since that is often the most
# expected. Using Windows and Python 3.7, since that is often the most
# challenging matrix element.
test-packaging:
name: 🐍 3.6 • 📦 tests • windows-latest
name: 🐍 3.7 • 📦 tests • windows-latest
runs-on: windows-latest

steps:
- uses: actions/checkout@v2

- name: Setup 🐍 3.6
- name: Setup 🐍 3.7
uses: actions/setup-python@v2
with:
python-version: 3.6
python-version: 3.7

- name: Prepare env
run: |
Expand Down
25 changes: 21 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from pathlib import Path

import nox

Expand Down Expand Up @@ -48,7 +49,7 @@ def tests_packaging(session: nox.Session) -> None:
"""

session.install("-r", "tests/requirements.txt", "--prefer-binary")
session.run("pytest", "tests/extra_python_package")
session.run("pytest", "tests/extra_python_package", *session.posargs)


@nox.session(reuse_venv=True)
Expand Down Expand Up @@ -92,6 +93,22 @@ def build(session: nox.Session) -> None:
session.log("Building normal files")
session.run("python", "-m", "build", *session.posargs)
session.log("Building pybind11-global files (PYBIND11_GLOBAL_SDIST=1)")
session.run(
"python", "-m", "build", *session.posargs, env={"PYBIND11_GLOBAL_SDIST": "1"}
)

# Temporarily change the project name (static project metadata)
pyproject = Path("pyproject.toml")
config = pyproject.read_text("utf-8")
global_config = config.replace('name = "pybind11"', 'name = "pybind11_global"')
os.rename("pyproject.toml", ".pyproject.orig")
pyproject.write_text(global_config, "utf-8")

try:
session.run(
"python",
"-m",
"build",
*session.posargs,
env={"PYBIND11_GLOBAL_SDIST": "1"},
)
finally:
pyproject.unlink()
os.rename(".pyproject.orig", "pyproject.toml")
50 changes: 48 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,53 @@
[build-system]
requires = ["setuptools>=42", "cmake>=3.18", "ninja"]
requires = [
"setuptools @ git+https://github.com/pypa/setuptools@experimental/support-pyproject",
"cmake>=3.18",
"ninja"
]
build-backend = "setuptools.build_meta"

[project]
name = "pybind11"
description = "Seamless operability between C++11 and Python"
authors = [{name = "Wenzel Jakob", email = "wenzel.jakob@epfl.ch"}]
readme = "README.rst"
license = {text = "BSD"}
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Utilities",
"Programming Language :: C++",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: C++",
"Topic :: Software Development :: Libraries :: Python Modules",
]
keywords = [
"C++11",
"Python bindings",
]
dynamic = ["version"]
requires-python = ">=3.6"

[project.urls]
Homepage = "https://github.com/pybind/pybind11"
Documentation = "https://pybind11.readthedocs.io/"
"Bug Tracker" = "https://github.com/pybind/pybind11/issues"
Discussions = "https://github.com/pybind/pybind11/discussions"
Changelog = "https://pybind11.readthedocs.io/en/latest/changelog.html"
Chat = "https://gitter.im/pybind/Lobby"

[tool.setuptools]
zip-safe = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this option is even necessary nowadays.

According to the docs: it will consider the project unsafe if it contains any C extensions or datafiles whatsoever.

But more importantly... This flag works for eggs right? I believe pip will always extract the package anyway...


[tool.check-manifest]
ignore = [
"tests/**",
Expand Down Expand Up @@ -41,7 +87,7 @@ log_cli_level = "info"
testpaths = [
"tests",
]
timeout=300
timeout = 300


[tool.pylint]
Expand Down
43 changes: 0 additions & 43 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,46 +1,3 @@
[metadata]
long_description = file: README.rst
long_description_content_type = text/x-rst
description = Seamless operability between C++11 and Python
author = Wenzel Jakob
author_email = wenzel.jakob@epfl.ch
url = https://github.com/pybind/pybind11
license = BSD

classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
Topic :: Software Development :: Libraries :: Python Modules
Topic :: Utilities
Programming Language :: C++
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
License :: OSI Approved :: BSD License
Programming Language :: Python :: Implementation :: PyPy
Programming Language :: Python :: Implementation :: CPython
Programming Language :: C++
Topic :: Software Development :: Libraries :: Python Modules

keywords =
C++11
Python bindings

project_urls =
Documentation = https://pybind11.readthedocs.io/
Bug Tracker = https://github.com/pybind/pybind11/issues
Discussions = https://github.com/pybind/pybind11/discussions
Changelog = https://pybind11.readthedocs.io/en/latest/changelog.html
Chat = https://gitter.im/pybind/Lobby

[options]
python_requires = >=3.6
zip_safe = False


[flake8]
max-line-length = 120
show_source = True
Expand Down
53 changes: 38 additions & 15 deletions tests/extra_python_package/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import sys
import tarfile
import zipfile
from contextlib import contextmanager
from pathlib import Path

# These tests must be run explicitly
# They require CMake 3.15+ (--install)
Expand Down Expand Up @@ -165,23 +167,44 @@ def test_build_sdist(monkeypatch, tmpdir):
assert pyproject_toml == contents


@contextmanager
def global_package(monkeypatch):
pyproject = Path("pyproject.toml")
config = pyproject.read_text("utf-8")
config = config.replace('name = "pybind11"', 'name = "pybind11_global"')
assert 'name = "pybind11_global"' in config

os.rename("pyproject.toml", ".pyproject.orig")
pyproject.write_text(config, "utf-8")

try:
with monkeypatch.context() as m:
m.setenv("PYBIND11_GLOBAL_SDIST", "1")
yield
finally:
pyproject.unlink()
os.rename(".pyproject.orig", "pyproject.toml")


def test_build_global_dist(monkeypatch, tmpdir):

monkeypatch.chdir(MAIN_DIR)
monkeypatch.setenv("PYBIND11_GLOBAL_SDIST", "1")
out = subprocess.check_output(
[
sys.executable,
"-m",
"build",
"--sdist",
"--outdir",
str(tmpdir),
]
)

with global_package(monkeypatch):
out = subprocess.check_output(
[
sys.executable,
"-m",
"build",
"--sdist",
"--outdir",
str(tmpdir),
]
)

if hasattr(out, "decode"):
out = out.decode()
print(out)

(sdist,) = tmpdir.visit("*.tar.gz")

Expand Down Expand Up @@ -247,11 +270,11 @@ def tests_build_wheel(monkeypatch, tmpdir):

def tests_build_global_wheel(monkeypatch, tmpdir):
monkeypatch.chdir(MAIN_DIR)
monkeypatch.setenv("PYBIND11_GLOBAL_SDIST", "1")

subprocess.check_output(
[sys.executable, "-m", "pip", "wheel", ".", "-w", str(tmpdir)]
)
with global_package(monkeypatch):
subprocess.check_output(
[sys.executable, "-m", "pip", "wheel", ".", "-w", str(tmpdir)]
)

(wheel,) = tmpdir.visit("*.whl")

Expand Down