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
cmake: enabled py3 only build #20064
Conversation
@tchaikov Nope. BuildBoost still can't find the python headers:
The build is currently running, but I expect it to fail on I will look how boost is packaged in openSUSE - maybe I can find a clue. |
@smithfarm no worries. i will try again in my testbed tomorrow. |
Based on my reading of https://build.opensuse.org/package/view_file/openSUSE:Factory:Staging:O/boost/boost.spec?expand=1 the py3-only build needs to create a jam file with something like the following contents:
I guess the RPM/DEB packaging will need to explicitly specify the Python 3 version on the cmake command line. |
cmake/modules/BuildBoost.cmake
Outdated
" : ${PYTHON_VERSION_STRING}" | ||
" : ${PYTHON_EXECUTABLE}" | ||
" : ${PYTHON_INCLUDE_DIRS}" | ||
" : ${PYTHON_LIBRARIES}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that:
- in the py2/py3 environment, these variables are populated by FindPython{Interp,Libs}.cmake and they point to Python 2.7
- in the py3-only environment,
FindPython{Interp,Libs}.cmake
is not run. Instead,FindPython3{Interp,Libs}.cmake
is run and does not populate these variables. Instead ofPYTHON_VERSION_STRING
, for example, it populatesPYTHON3_VERSION_STRING
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tchaikov Please ignore the above comment - I found that FindPython{Interp,Libs}.cmake
are properly populated in the py3-only env.
cmake/modules/BuildBoost.cmake
Outdated
if(with_python GREATER -1) | ||
file(APPEND ${source_dir}/user-config.jam | ||
"using python" | ||
" : ${PYTHON_VERSION_STRING}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From http://www.boost.org/doc/libs/1_58_0/libs/python/doc/building.html#python-configuration-parameters
version
the version of Python to use. Should be in Major.Minor format, for example, 2.3. Do not include the subminor version (i.e. not 2.5.1).
Except ${PYTHON_VERSION_STRING}
expands to a value that DOES include the subminor version:
PYTHON_VERSION_STRING 3.6.4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now testing:
- " : ${PYTHON_VERSION_STRING}"
+ " : ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}"
40bc768
to
f707306
Compare
I've tried a number of things, but nothing seems to make the "No python installation configured and autoconfiguration" warning go away. What's worse, I can't find the source code where this warning is generated, so I can't see what's triggering it. |
jenkins re-test this please |
|
^^^ this is weird, because BuildBoost.cmake sets source_dir to [EDITED] . . . but only when the |
From the Jenkins console log:
(strange that it says "tar xfz" when the tarball is compressed with bz2 - shouldn't it say "tar xfj"?) |
1f3e069
to
5cb94cd
Compare
5cb94cd
to
438136d
Compare
changelog
|
438136d
to
1263b16
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @tchaikov !
This PR passed a rados run here: http://pulpito.ceph.com/smithfarm-2018-01-24_19:46:55-rados-wip-smithfarm-testing-distro-basic-smithi/ 198 of 202 tests passed. Failed tests:
One "dead" test:
|
I'm re-running the failed tests. The "Address already in use" from module "prometheus" failure looks like it might be relevant to this PR. Reading the log - http://qa-proxy.ceph.com/teuthology/smithfarm-2018-01-24_19:46:55-rados-wip-smithfarm-testing-distro-basic-smithi/2106392/teuthology.log - I can see that the module selftests (tasks.mgr.test_module_selftest) complete successfully. Several awful-sounding log messages (e.g. MGR_DOWN, etc.) are whitelisted, so maybe the "Address already in use" message could be whitelisted as well? UPDATE: in two subsequent reruns, the same test fails on a different log message: "2018-01-25 09:32:00.117463 mgr.y client.4393 172.21.15.28:0/3800875254 1 : cluster [ERR] Unhandled exception from module 'prometheus' while running on mgr.y: IOError("Port 9283 not free on '::'",)" in cluster log UPDATE 2: the same test fails on master as well: http://pulpito.ceph.com/smithfarm-2018-01-25_11:32:09-rados-master-distro-basic-smithi/ (but in this case it fails outright, not on a log message) UPDATE 3: the test should be fixed by #20047 |
@tchaikov I did a rados run with positive results, but now this needs a rebase. |
Signed-off-by: Kefu Chai <kchai@redhat.com>
1263b16
to
99badd3
Compare
@smithfarm rebased on master, and repushed. |
src/mgr/PyModule.cc
Outdated
|
||
// Initialize module | ||
#if PY_MAJOR_VERSION >= 3 | ||
PyObject *ceph_module = PyModule_Create(&ceph_module_def); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We switch to PyModule_Create here but continue to use Py_InitModule for ceph_logger
above. Also it seems like the ceph_logger_module
struct is unused, so I guess the intent was to migrate both calls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @jcsp , the change related to ceph_logger_module
was lost while rebasing against master. and i put it back in the latest change.
I've checked this is compiling and working in my local (python2) environment, so combined with the earlier rados run I think we can be reasonably confident it isn't breaking anything |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not an expert in the cmake bits but it all seems reasonable, so I'm happy with this once the Py_InitModule/PyModule_Create comment is done.
CMakeLists.txt
Outdated
set(Python_ADDITIONAL_VERSIONS 2.7) | ||
find_package(PythonInterp 2.7 REQUIRED) | ||
find_package(PythonLibs 2.7 REQUIRED) | ||
set(MGR_PYTHON_VERSION "2.7" CACHE STRING "python runtime for running mgr plugins") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we put a comment above this line:
# MGR_PYTHON_VERSION specifies the required Python major version and minimum minor version
# within that major version.
# To build in a Python 3-only environment, override with, e.g. -DMGR_PYTHON_VERSION=3.6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smithfarm this setting set the minimal required version of python, not the major and minor version. say, if we need to use python3 for running mgr plugins, but do not care which minor version is:
-DMGR_PYTHON_VERSION=3
would suffice. i updated the wording of the doc string of this cached string. HTH.
99badd3
to
e48db01
Compare
changelog
|
CMakeLists.txt
Outdated
find_package(PythonInterp 2.7 REQUIRED) | ||
find_package(PythonLibs 2.7 REQUIRED) | ||
set(MGR_PYTHON_VERSION "2.7" CACHE | ||
STRING "minimal required version of python runtime for running mgr plugins") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tchaikov Cmake is a build system, so if a special non-default setting is necessary to build in a py3-only environment, the parameter definition/explanation should note that.
I will try the py3-only build again without overriding this value, and if it fails (as I remember it doing), will post the exact error message.
Thanks for suggesting -DMGR_PYTHON_VERSION=3
- I'll try that as well.
In short, I find this help text "minimal required version of python runtime for running mgr plugins" to be incomplete in the sense that it omits a fact that is important for someone trying to build (not just run) MGR in a py3-only environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smithfarm as you noted, cmake is a building system. so
a fact that is important for someone trying to build (not just run) MGR in a py3-only environment.
i think the help message implies that one need to ready the building environment also. if we went further in this direction, shall we note that LTTng is both a build-time and run-time dependency/feature as well? the list can grow longer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tchaikov So, the point I'm trying to make is that the current help string says (or implies) that 2.7 is the minimal required version to build. But this only hold true on a system with Python 2 installed. In a Python 3 (only) system, the minimum required version is 3.
That's why I suggested a comment to help folks who might be affected by the build failure because they neglect to override this default (cached) value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please note a a cached variable is a user-facing setting. see https://cmake.org/cmake/help/v3.6/command/set.html#set-cache-entry .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so you're saying it should be obvious to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the parameter definition says this specifies the minimum required version, the default is 2.7, and I have 3, then logic dictates that I don't need to change the setting. But in reality I do need to change it. This is not obvious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smithfarm yes, it should be obvious to a maintainer who's working on cmake projects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, it's not important - I can add the comment in a separate PR.
* add WITH_PYTHON2 option, so we can build python3 bindings only. * change the default value of WITH_PYTHON3 option to "OFF", as the option() command in cmake only allow the initial value to be "ON" or "OFF". we could use a cached string for this option, but i think it would be more explicit to continue using the option() command. * fix the installation dir of "ceph_rest_api.py". please note, we still have a *default* python version, which is specified by the last element of ${py_vers}. for instance, ${PYTHON_VERSION} will be 3 if ${py_vers} is 2;3. in this change, 2 is still the default python version, if both WITH_PYTHON2 and WITH_PYTHON3 are enabled. Signed-off-by: Kefu Chai <kchai@redhat.com>
e48db01
to
fd079c4
Compare
@smithfarm updated and repushed. |
@tchaikov LGTM. Will merge when test build finishes. |
* add an option named "MGR_PYTHON_VERSION", so we can build ceph-mgr which use py3 for running plugins * also drop the line to specify the "Python_ADDITIONAL_VERSIONS", because 2.7 is listed by all the the FindPythonInterp and FindPythonLibs in cmake 2.8.12 and up. * use ${MGR_PYTHON_EXECUTABLE} for holding the path to the python interpreter used by mgr. because this variable might be overwritten by "find_package(PythonInterp 2 REQUIRED)" when checking for building env of pybinding for python2. Signed-off-by: Kefu Chai <kchai@redhat.com>
so ceph-mgr can be compiled using py3 Signed-off-by: Kefu Chai <kchai@redhat.com>
fd079c4
to
4600307
Compare
No description provided.