Skip to content
Snippets Groups Projects

dune-python migration

Merged Dominic Kempf requested to merge feature/dune-python-migration into master

As decided on the Dune developer meeting, I will migrate the python build system infrastructure currently located in dune-python to dune-common. I will try to split the migration into 3 parts:

  • !218 (merged) is kinda unrelated, but used in the project (for sake of simplicity, this MR builds upon that branch)
  • This MR will contain all the stuff that I consider useful for all python related projects, such as
    • finding interpreter and libraries
    • checking availability of python packages
    • defining installation rules for python packages
    • run python test commands during ctest
  • An upcoming merge request (!220 (merged)) will implement everything that relates to the configure-time envsetup currently used by projects that need to run python from cmake.

To grasp the changes of this MR:

  • DunePythonCommonMacros is the entry-level module, where all the logic that is executed during configuration of dune-common is located
  • All the cmake modules prefixed with DunePython contain code that is intended to be used by users. It is documented with Sphinx.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Dominic Kempf added 1 commit

    added 1 commit

    • 6c0b497f - [bugfix] Exit the version checking script if a version has been found

    Compare with previous version

  • Dominic Kempf added 1 commit

    added 1 commit

    • 2d78e897 - Add dune_python_install_package command

    Compare with previous version

  • Dominic Kempf resolved all discussions

    resolved all discussions

  • 26 include(DunePythonFindPackage)
    27 include(DunePythonInstallPackage)
    28 include(DunePythonRequireVersion)
    29
    30 # Find the Python Interpreter
    31 set(_VERSION_STRING "")
    32 if(DUNE_PYTHON_FORCE_PYTHON2 AND DUNE_PYTHON_FORCE_PYTHON3)
    33 message(FATAL_ERROR "Cannot enforce both python2 *and* python3")
    34 endif()
    35 if(DUNE_PYTHON_FORCE_PYTHON2)
    36 set(_VERSION_STRING "2")
    37 endif()
    38 if(DUNE_PYTHON_FORCE_PYTHON3)
    39 set(_VERSION_STRING "3")
    40 endif()
    41 find_package(PythonInterp ${_VERSION_STRING})
    • We had to add

      set(Python_ADDITIONAL_VERSIONS 3.4)

      for Python 3.4 to be found. I don't know if this is still necessary, though.

    • I do not think the Python_ADDITIONAL_VERSIONS is shadowed by the checking performed by find_package, but I will check.

    • So you're suggesting the user should set Python_ADDITIONAL_VERSIONS instead of the build system?is this a bug in the Distribution? On Debian Stretch (CMake 3.7) all Python versions are automatically looked for.

    • There is an inherent chicken-egg problem with the buildsystem setting Python_ADDITIONAL_VERSIONS: The check is triggered from dune-common, but other modules can pose constraints on the interpreter version. My current approach is: Find the interpreter and nag afterwards, if it was not sufficiently new. This of course relies on distributions to define reasonably new default interpreters. Then again, in the case of the system interpreter being in a virtualenv, it is the correct procedure anyway, as the user needs to actively choose the interpreter when setting up the env (so the buildsystem does not even have a choice).

    • @martin.nolte Oh, I just found out I completely misunderstood the purpose of Python_ADDITIONAL_VERSIONS. I always interpreted its semantics totally different... So it turns out it IS needed to have old cmake find new pythons (Why, only the cmake god knows (if existent)). I am very sorry.

    • This is fixed now on the branch.

    • (Why, only the cmake god knows (if existent)).

      I am sure there is no cmake god. Just lots of devils like for all buildsystems.

    • Please register or sign in to reply
  • Dominic Kempf added 2 commits

    added 2 commits

    • a6a6d225 - Honour the 'none' option for install location
    • ef80dd26 - [bugfix] Install install_python_package.cmake correctly

    Compare with previous version

  • While working on it, I decided to omit the functionality to install standalone python scripts , as it is so hard to correctly determine the location to move them to. If somebody direly needs scripts, I recommend adding a dummy setup.py and have it be installed as a python package to have pip figure out the correct paths. Shout, if you disagree.

  • So if I've already have them in setup.py, I'm good? https://github.com/dune-community/dune-xt-common/blob/master/python/setup.py

    In case that's true, than I'm not shouting :wink:

  • @rene.milk Exactly, that is the way I am promoting as clean solution.

  • Dominic Kempf added 3 commits

    added 3 commits

    • 4b7fd590 - [bugfix] DUNE_PYTHON_IS_VIRTUALENV -> DUNE_PYTHON_SYSTEM_IS_VIRTUALENV
    • 738234eb - Implement dune_python_add_test to wrap python testing for the cmake build system
    • 5921fc89 - Fix some typos/cp bugs

    Compare with previous version

  • Dominic Kempf added 1 commit

    added 1 commit

    • 984645b2 - [bugfix] 'Correctly' pass list arguments to CMake script

    Compare with previous version

  • Dominic Kempf added 1 commit

    added 1 commit

    • f707196e - [doc] Document how to invoke the python interpreter in test commands

    Compare with previous version

  • Dominic Kempf added 2 commits

    added 2 commits

    • 3af49c60 - Move the application of default on DUNE_PYTHON_INSTALL_LOCATION to the common macros
    • 3a8c6fda - Check for the presence of pip, if installation is requested

    Compare with previous version

  • Dominic Kempf added 2 commits

    added 2 commits

    • ddec4ca9 - [bugfix] Set a list of uptodate python versions
    • 815e47c5 - Also find the python libraries from CMake

    Compare with previous version

  • Dominic Kempf added 1 commit

    added 1 commit

    • 26ded7f5 - Check that install location 'user' is not used inside virtual environments

    Compare with previous version

  • The branch is now in a state that includes all the features I was envisioning for it. I have redesigned many interfaces (in comparison to dune-python), so it requires thorough testing although I am using similar concepts for quite a while already. Any feedback is welcome. I will now go on and implement the MR on top that does the virtualenv stuff, as I need that to do meaningful testing with my existing projects.

  • Dominic Kempf added 1 commit

    added 1 commit

    • 0f58c7ca - Simplify some logic about whether a package was found

    Compare with previous version

  • Dominic Kempf added 1 commit

    added 1 commit

    • c804884a - Have dune_python_find_package take an alternative interpreter

    Compare with previous version

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading