{"action":"created","issue":{"url":"https://api.github.com/repos/OpenImageIO/oiio/issues/1760","repository_url":"https://api.github.com/repos/OpenImageIO/oiio","labels_url":"https://api.github.com/repos/OpenImageIO/oiio/issues/1760/labels{/name}","comments_url":"https://api.github.com/repos/OpenImageIO/oiio/issues/1760/comments","events_url":"https://api.github.com/repos/OpenImageIO/oiio/issues/1760/events","html_url":"https://github.com/OpenImageIO/oiio/pull/1760","id":254810380,"number":1760,"title":"Make boost_python and python detection more generic","user":{"login":"dracwyrm","id":9150058,"avatar_url":"https://avatars1.githubusercontent.com/u/9150058?v=4","gravatar_id":"","url":"https://api.github.com/users/dracwyrm","html_url":"https://github.com/dracwyrm","followers_url":"https://api.github.com/users/dracwyrm/followers","following_url":"https://api.github.com/users/dracwyrm/following{/other_user}","gists_url":"https://api.github.com/users/dracwyrm/gists{/gist_id}","starred_url":"https://api.github.com/users/dracwyrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dracwyrm/subscriptions","organizations_url":"https://api.github.com/users/dracwyrm/orgs","repos_url":"https://api.github.com/users/dracwyrm/repos","events_url":"https://api.github.com/users/dracwyrm/events{/privacy}","received_events_url":"https://api.github.com/users/dracwyrm/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2017-09-02T13:01:42Z","updated_at":"2017-09-15T09:48:38Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/OpenImageIO/oiio/pulls/1760","html_url":"https://github.com/OpenImageIO/oiio/pull/1760","diff_url":"https://github.com/OpenImageIO/oiio/pull/1760.diff","patch_url":"https://github.com/OpenImageIO/oiio/pull/1760.patch"},"body":"## Description\r\nCurrently, there is redundant code when it comes to boost_python detection. The code in externalpackages.cmake never worked with Gentoo, however, the code in python's CMakeLists.txt did. I made the code more variable, so it doesn't need to be changed for newer versions of python and package maintainers should be able to change anything they want, or add newer version detection before OpenImageIO is updated. Also, there is redundant code when it comes to python 2 and 3 detection and compiling. CMake provides python version detection, so we can remove the separate code dealing with different versions of python and just use variables.\r\n\r\nThe boost_python detection was solely moved to src/python/CMakeLists.txt so it is run only once and only if USE_PYTHON is selected.\r\n\r\nSince python site-packages directory changes from distro to distro, in fact, it's not even called site-packages on some, I run a python command to get the directory. Then strip the CMake compile directory structure from the path leaving only the correct destination. The final directory can be overridden.\r\n\r\n## Tests\r\nGentoo uses different formatting and this was able to find the boost_python module and install to the correct site-packages directory.\r\n\r\n## Checklist:\r\n\r\n<!-- Put an 'x' in the boxes as you complete the checklist items -->\r\n\r\n- [X] I have read the [contribution guidelines](../CONTRIBUTING.md).\r\n- [X] If this is more extensive than a small change to existing code, I\r\n  have previously submitted a Contributor License Agreement\r\n  ([individual](../src/doc/CLA-INDIVIDUAL), and if there is any way my\r\n  employers might think my programming belongs to them, then also\r\n  [corporate](../src/doc/CLA-CORPORATE)).\r\n- [ ] I have updated the documentation, if applicable.\r\n- [ ] I have ensured that the change is tested somewhere in the testsuite\r\n  (adding new test cases if necessary).\r\n- [ ] My code follows the prevailing code style of this project.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/OpenImageIO/oiio/issues/comments/329735852","html_url":"https://github.com/OpenImageIO/oiio/pull/1760#issuecomment-329735852","issue_url":"https://api.github.com/repos/OpenImageIO/oiio/issues/1760","id":329735852,"user":{"login":"dracwyrm","id":9150058,"avatar_url":"https://avatars1.githubusercontent.com/u/9150058?v=4","gravatar_id":"","url":"https://api.github.com/users/dracwyrm","html_url":"https://github.com/dracwyrm","followers_url":"https://api.github.com/users/dracwyrm/followers","following_url":"https://api.github.com/users/dracwyrm/following{/other_user}","gists_url":"https://api.github.com/users/dracwyrm/gists{/gist_id}","starred_url":"https://api.github.com/users/dracwyrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dracwyrm/subscriptions","organizations_url":"https://api.github.com/users/dracwyrm/orgs","repos_url":"https://api.github.com/users/dracwyrm/repos","events_url":"https://api.github.com/users/dracwyrm/events{/privacy}","received_events_url":"https://api.github.com/users/dracwyrm/received_events","type":"User","site_admin":false},"created_at":"2017-09-15T09:48:38Z","updated_at":"2017-09-15T09:48:38Z","author_association":"CONTRIBUTOR","body":"@devurandom That's an idea I need to investigate. :)\r\n\r\n@lgritz I pushed through an update which makes the change to the original, original way.\r\n```\r\nif (NOT DEFINED PYTHON_SITE_DIR)\r\n    set (PYTHON_SITE_DIR \"${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION_FOUND}/site-packages\")\r\nendif ()\r\n```\r\nWe can always push another update later that makes site/dist dir finding more robust on all systems. I was trying to find a regex that would take the last occurrence of Python and select everything to the end because on the appveyor system, they have Python\\Python27\\site-packages, so it's a double Python and the 27 doesn't have a '.' character. This is why I'm trying to find it dynamically.\r\n\r\nThere is one way I thought involves using calls to both python -m site --user-site and python -m site --user-base. I tried it on the appveyor system and it worked, but it's a double python call. This is the test code I used (I know the variables can be reused, but I had messages outputting them):\r\n```\r\nexecute_process (COMMAND ${PYTHON_EXECUTABLE} -m site --user-base\r\n                 OUTPUT_VARIABLE _py_full_site_base\r\n                 OUTPUT_STRIP_TRAILING_WHITESPACE)\r\n\r\nexecute_process (COMMAND ${PYTHON_EXECUTABLE} -m site --user-site\r\n                 OUTPUT_VARIABLE _py_full_site_dir\r\n                 OUTPUT_STRIP_TRAILING_WHITESPACE)\r\n\r\n# Remove the base path\r\nstring (REPLACE \"${_py_full_site_base}\" \"\" _py_partial_site_dir \"${_py_full_site_dir}\"\r\n\r\n# Cut off the temporary compile dir\r\nstring (REGEX MATCH \"([pP]ython.*)\" _py_site_dir ${_py_partial_site_dir})\r\n\r\n# Construct proper install path \r\nset (PYTHON_SITE_DIR \"${CMAKE_INSTALL_LIBDIR}/${_py_site_dir}\")\r\n```\r\nThat is a lot and a bit messy, so I'm hoping to find a better way."}}
{"actor":{"display_login":"dracwyrm"}}