Skip to content

fix: respect PYTHON_VERSION if set in classic mode#2414

Merged
henryiii merged 2 commits into
pybind:masterfrom
henryiii:feat/pyver
Aug 26, 2020
Merged

fix: respect PYTHON_VERSION if set in classic mode#2414
henryiii merged 2 commits into
pybind:masterfrom
henryiii:feat/pyver

Conversation

@henryiii

@henryiii henryiii commented Aug 19, 2020

Copy link
Copy Markdown
Collaborator

If PYBIND11_PYTHON_VERSION is not set, but PYTHON_VERSION is, on the first run, use that for the hint. We could add a warning or error instead - but the current behavior is a bit odd and unhelpful.

@henryiii henryiii closed this Aug 20, 2020
@henryiii henryiii reopened this Aug 20, 2020
@bstaletic

Copy link
Copy Markdown
Collaborator

Why don't we also show a warning in the branch where we allow the old variable?

@henryiii

Copy link
Copy Markdown
Collaborator Author

You mean a warning if PYBIND11_PYTHON_VERSION is set instead of PYTHON_VERSION?

@bstaletic

Copy link
Copy Markdown
Collaborator

The other way around. The "legacy" way of doing things is using PYTHON_VERSION. Right? In that case showing a warning seems like a good idea.

@henryiii

Copy link
Copy Markdown
Collaborator Author

That's what I suggest at the top ("We could add a warning or error instead"). The old way of doing things is with PYBIND11_PYTHON_VERSION. However, since PYTHON_VERSION is the output variable, it is a natural thing to set PYTHON_VERSION instead when looking for Python; currently this messes up the search. I can add a warning but still do the "right" thing, then?

With FindPython, there is no version-based search variable that is available like this (though I'm discussing it in an issue). PYBIND11_* variables do not affect FindPython. The recommendation is to use:

find_package(Python EXACT 3.7 ...)

(But I'm arguing this can't be done from the command line, and is rather a package requirement).

@bstaletic

Copy link
Copy Markdown
Collaborator

The old way of doing things is with PYBIND11_PYTHON_VERSION. However, since PYTHON_VERSION is the output variable, it is a natural thing to set PYTHON_VERSION

Oh, thanks for clarifying!

I can add a warning but still do the "right" thing, then?

Right. Any reason not to?

Comment thread tools/pybind11Tools.cmake

@bstaletic bstaletic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

With the added warning, I'm fine with this. Thanks @henryiii

Comment thread tools/pybind11Tools.cmake
@henryiii
henryiii requested a review from YannickJadoul August 26, 2020 04:10

@YannickJadoul YannickJadoul left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good, yes. More of a fix/convenience, indeed, so do merge when you're happy with it, AFAIC!

Comment thread tools/pybind11Tools.cmake
@henryiii
henryiii merged commit 9b8cb02 into pybind:master Aug 26, 2020
@henryiii
henryiii deleted the feat/pyver branch August 26, 2020 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants