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

Python 3.10 breaks build #1438

Closed
duanqn opened this issue Dec 4, 2021 · 3 comments · Fixed by #1462
Closed

Python 3.10 breaks build #1438

duanqn opened this issue Dec 4, 2021 · 3 comments · Fixed by #1462
Labels
bug Behaving differently as it should behave lang: python Done in Python code

Comments

@duanqn
Copy link
Contributor

duanqn commented Dec 4, 2021

FindPython.cmake assumes python minor version is single digit.

@duanqn
Copy link
Contributor Author

duanqn commented Dec 4, 2021

Another reason: pyreadline/pyreadline#73

@sarcXD
Copy link
Contributor

sarcXD commented Feb 11, 2022

@duanqn Found this in another issue thread, figured this was the correct place to post this. Firstly, glad I'm not the only one coming across this, almost drove me nuts. Luckily I found a relatively clean and arguably better and cleaner way of setting our ${PYTHON_MIN_VERSION_HEX} variable. I'll outline the relatively simple fix here.
Firstly, this is how cpython does it in their header library

#define PY_VERSION_HEX ((PY_MAJOR_VERSION << 24) | \
                        (PY_MINOR_VERSION << 16) | \
                        (PY_MICRO_VERSION <<  8) | \
                        (PY_RELEASE_LEVEL <<  4) | \
                        (PY_RELEASE_SERIAL << 0))

Now, All we need to do is shift the major version up by 24 bits, and minor version up by 16
Current method:

set(PYTHON_MIN_VERSION_HEX "0x0${Python3_VERSION_MAJOR}0${Python3_VERSION_MINOR}0000")

The fix I made (making, will send a PR after this)

math(EXPR BIT_SHIFT_HEX "${Python3_VERSION_MAJOR} << 24 | ${Python3_VERSION_MINOR} << 16" OUTPUT_FORMAT HEXADECIMAL)
set(PYTHON_MIN_VERSION_HEX "${BIT_SHIFT_HEX}")

see cmake page for math that allows c like bit manipulation operations
That fixes it basically.

@duanqn
Copy link
Contributor Author

duanqn commented Feb 12, 2022

@sarcXD This looks great!
We still have issues with pyreadline, but fixing the hex version is definitely a great improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Behaving differently as it should behave lang: python Done in Python code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants