Skip to content
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

fix: respect PYTHON_VERSION if set in classic mode #2414

Merged
merged 2 commits into from
Aug 26, 2020

Conversation

henryiii
Copy link
Collaborator

@henryiii henryiii commented Aug 19, 2020

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
Collaborator

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

@henryiii
Copy link
Collaborator Author

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

@bstaletic
Copy link
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
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
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?

Copy link
Collaborator

@bstaletic bstaletic left a comment

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

tools/pybind11Tools.cmake Show resolved Hide resolved
@henryiii henryiii requested a review from YannickJadoul August 26, 2020 04:10
Copy link
Collaborator

@YannickJadoul YannickJadoul left a comment

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!

tools/pybind11Tools.cmake Show resolved Hide resolved
@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