Commit Graph

23 Commits

Author SHA1 Message Date
Henry Schreiner
522c59ceb2
chore: drop Python 3.5 (#3719)
* chore: drop Python 3.5 support

* chore: more fstrings with flynt's help

* ci: drop Python 3.5

* chore: bump dependency versions

* docs: touch up py::args

* tests: remove deprecation warning

* Ban smartquotes

* Very minor tweaks (by-product of reviewing PR #3719).

Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
2022-02-11 19:06:16 -05:00
Ralf W. Grosse-Kunstleve
6493f496e3
Python 2 removal part 1: tests (C++ code is intentionally ~untouched) (#3688)
* `#error BYE_BYE_GOLDEN_SNAKE`

* Removing everything related to 2.7 from ci.yml

* Commenting-out Centos7

* Removing `PYTHON: 27` from .appveyor.yml

* "PY2" removal, mainly from tests. C++ code is not touched.

* Systematic removal of `u` prefix from `u"..."` and `u'...'` literals. Collateral cleanup of a couple minor other things.

* Cleaning up around case-insensitive hits for `[^a-z]py.*2` in tests/.

* Removing obsolete Python 2 mention in compiling.rst

* Proper `#error` for Python 2.

* Using PY_VERSION_HEX to guard `#error "PYTHON 2 IS NO LONGER SUPPORTED.`

* chore: bump pre-commit

* style: run pre-commit for pyupgrade 3+

* tests: use sys.version_info, not PY

* chore: more Python 2 removal

* Uncommenting Centos7 block (PR #3691 showed that it is working again).

* Update pre-commit hooks

* Fix pre-commit hook

* refactor: remove Python 2 from CMake

* refactor: remove Python 2 from setup code

* refactor: simplify, better static typing

* feat: fail with nice messages

* refactor: drop Python 2 C++ code

* docs: cleanup for Python 3

* revert: intree

revert: intree

* docs: minor touchup to py2 statement

Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
2022-02-10 18:28:08 -08:00
Mattia Basaglia
dc4717bac2
fix: module extension detection for python 3.10 (#3663)
* Fix module extension detection for python 3.10

* Fix for python < 3.10

* Use importlib
2022-01-31 11:10:45 -05:00
Henry Schreiner
90707b46f2
fix(build): support conan's multiple includes of all files (#3420) 2021-10-27 15:06:02 -04:00
Henry Schreiner
d58699c9ab
fix(cmake): reduce chance for variable collision (#3302) 2021-09-24 17:47:03 -04:00
Wenzel Jakob
409be8336f CMake: react to python version changes
The new FindPython-based variant of the CMake scripts caches information
about the chosen Python version that can become stale. For example,
suppose I configure a simple pybind11-based project as follows

```
cmake -S . -B build -GNinja -DPython_ROOT=<path to python 3.8>
```

which will generate `my_extension.cpython-38-x86_64-linux-gnu.so`.
A subsequent change to the python version like

```
cmake -S . -B build -GNinja -DPython_ROOT=<path to python 3.9>
```

does not update all necessary build system information. In particular,
the compiled file is still called
`my_extension.cpython-38-x86_64-linux-gnu.so`.

This commit fixes the problem by detecting changes in
`Python_EXECUTABLE` and re-running Python as needed.

Note that the previous way of detecting Python does not seem to be
affected, it always specifies the right suffix.
2021-09-24 17:42:06 +02:00
Weiming Zhao
4f0727f280
Fix the enabling of default extension handling (#2938) 2021-04-05 23:50:50 -04:00
Henry Schreiner
eb83feefff
style: avoid using unintialized variables (#2806)
* style: avoid using unintialized variables

Tested with cmake --warn-unintialized -S . -B build

* refactor: use function for possibly uninit vars
2021-01-19 18:48:22 -05:00
heyer2
76a160070b
fix: STATIC and SHARED flags not being detected (#2796)
* Fix STATIC and SHARED flags not being detected

* fix: use classic naming for all lib types

Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
2021-01-14 19:51:41 +01:00
Henry Schreiner
230fa53f16
fix: Don't override global settings for VISIBILITY if set (#2793)
Sometimes programmers want to control this, and while it can be changed after the fact, it's commonly set via a CMAKE_ variable; if that variable is set, we should respect that (like the CMAKE_INTERPROCEDURAL_OPTIMIZATION setting).
2021-01-14 08:31:48 -05:00
Henry Schreiner
ffb113d1d8
fix: regression with installed pybind11 overriding local one (#2716)
* fix: regression with installed pybind11 overriding discovered one

Closes #2709

* docs: wording incorrect
2020-12-15 21:55:14 -05:00
Frank
f8b8107b46
fix: make FindPython2 and FindPython3 work (#2662) 2020-11-15 11:55:42 -05:00
Henry Schreiner
3e4d54bc01
fix: match new extension discovery with changes to classic discovery (#2640)
* fix: match new extension discovery with changes to classic discovery

Followup to #2638 - this was fixed in 2.6.0, but only for classic Python

* fix: followup to avoid warnings
2020-11-05 14:37:11 -05:00
Henry Schreiner
b8dc60ec8f
fix: Python include directory was missing from DIRS (#2636) 2020-11-02 20:45:54 -05:00
Henry Schreiner
d46f3322a4
fix: allow cmake varibles from Python calls to be cached (#2570) 2020-10-09 17:33:45 -04:00
Henry Schreiner
2a2f52201d
fix: find_import didn't work properly for classic tools (#2550)
* fix: find_import didn't work properly for classic tools

* ci: fix all files not being checked in style run
2020-10-05 15:31:00 -04:00
Wenzel Jakob
3232e59b83
Check if module file extension could be queried correctly (#2538)
On very incomplete python installations (e.g. within Docker), it's
possible that distutils is not installed. In that case, the
``execute_command`` statement that queries distutils for the Python
module extension fails, and pybind11 uses the empty string. This commit
adds an extra check that causes a CMake failure with more actionable
information (just spent a lot of time trying to track down this problem :))
2020-09-30 17:49:11 -04:00
Henry Schreiner
e01f492462
fix: Add a nice CMake error when Interpreter component is missing. (#2519)
Closes #2515, found by @rhjdjong
2020-09-21 18:34:48 -04:00
Henry Schreiner
fd61f5038e
feat: setup.py redesign and helpers (#2433)
* feat: setup.py redesign and helpers

* refactor: simpler design with two outputs

* refactor: helper file update and Windows support

* fix: review points from @YannickJadoul

* refactor: fixes to naming and more docs

* feat: more customization points

* feat: add entry point pybind11-config

* refactor: Try Extension-focused method

* refactor: rename alt/inplace to global

* fix: allow usage with git modules, better docs

* feat: global as an extra (@YannickJadoul's suggestion)

* feat: single version location

* fix: remove the requirement that setuptools must be imported first

* fix: some review points from @wjacob

* fix: use .in, add procedure to docs

* refactor: avoid monkeypatch copy

* docs: minor typos corrected

* fix: minor points from @YannickJadoul

* fix: typo on Windows C++ mode

* fix: MSVC 15 update 3+ have c++14 flag

See <https://docs.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version?view=vs-2019>

* docs: discuss making SDists by hand

* ci: use pep517.build instead of manual setup.py

* refactor: more comments from @YannickJadoul

* docs: updates from @ktbarrett

* fix: change to newly recommended tool instead of pep517.build

This was intended as a proof of concept; build seems to be the correct replacement.

See https://github.com/pypa/pep517/pull/83

* docs: updates from @wjakob

* refactor: dual version locations

* docs: typo spotted by @wjakob
2020-09-16 17:13:41 -04:00
Wenzel Jakob
36c666f027 pybind11_add_module(): OPT_SIZE target 2020-09-06 16:46:38 +02:00
Henry Schreiner
ce1a07ef45
fix: use classic extension handling unless otherwise requested (#2462)
* fix: use classic extension handling unless otherwise requested

* fix: variable must be cached to be used externally
2020-09-04 21:54:09 -04:00
Henry Schreiner
56df3c4649
fix: a couple more places where pybind11 is missing 11 (#2421) 2020-08-21 15:27:21 -04:00
Henry Schreiner
1729aae96f
feat: new FindPython support (#2370)
* feat: FindPython support

* refactor: rename to PYBIND11_FINDPYTHON

* docs: Caps fixes

* feat: NOPYTHON mode

* test: check simple call

* docs: add changelog/upgrade guide

* feat: Support Python3 and Python2

* refactor: Use targets in tests

* fix: support CMake 3.4+

* feat: classic search also finds virtual environments

* docs: some updates from @wjakob's review

* fix: wrong name for QUIET mode variable, reported by @skoslowski

* refactor: cleaner output messaging

* fix: support debug Python's in FindPython mode too

* fixup! refactor: cleaner output messaging

* fix: missing pybind11_FOUND and pybind11_INCLUDE_DIR restored to subdir mode

* fix: nicer reporting of Python / PyPy

* fix: out-of-order variable fix

* docs: minor last-minute cleanup
2020-08-19 12:26:26 -04:00