diff --git a/.gitignore b/.gitignore index 4577e1cb59..eb7f1cb783 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,5 @@ resources/.DS_Store #Common plug-ins plugins/UraniumExample*Plugin +/cmake-build-debug/ +/cmake-build-release/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e64f48cfb..f3a5c7f3a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ project(uranium NONE) -cmake_minimum_required(VERSION 3.6) +cmake_minimum_required(VERSION 3.13) message(STATUS ${CMAKE_MODULE_PATH}) @@ -10,19 +10,28 @@ include(UraniumTranslationTools) include(GNUInstallDirs) -find_package(PythonInterp 3 REQUIRED) +if(NOT DEFINED Python_VERSION) + set(Python_VERSION + 3.8 + CACHE STRING "Python Version" FORCE) + message(STATUS "Setting Python version to ${Python_VERSION}. Set Python_VERSION if you want to compile against an other version.") +endif() +if(APPLE) + set(Python3_FIND_FRAMEWORK NEVER) +endif() +find_package(Python3 ${Python_VERSION} EXACT REQUIRED COMPONENTS Interpreter) -message("Using python version ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}") +message("Using Python version ${Python3_VERSION}") # # Checks using pylint # Note that we use exit 0 here to not mark the build as a failure on check failure # In addition, the specified pylint configuration uses the spellchecker plugin. This required python-enchant to be installed. add_custom_target(check) -add_custom_command(TARGET check POST_BUILD COMMAND "PYTHONPATH=${CMAKE_SOURCE_DIR}" ${PYTHON_EXECUTABLE} -m pylint --rcfile=${CMAKE_SOURCE_DIR}/pylint.cfg UM --msg-template=\"{path}:{line}: [{msg_id}({symbol}) , {obj}] {msg}\" > ${CMAKE_BINARY_DIR}/pylint.log || exit 0 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) +add_custom_command(TARGET check POST_BUILD COMMAND "PYTHONPATH=${CMAKE_SOURCE_DIR}" ${Python3_EXECUTABLE} -m pylint --rcfile=${CMAKE_SOURCE_DIR}/pylint.cfg UM --msg-template=\"{path}:{line}: [{msg_id}({symbol}) , {obj}] {msg}\" > ${CMAKE_BINARY_DIR}/pylint.log || exit 0 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) # # Check using Mypy add_custom_target(typecheck) -add_custom_command(TARGET typecheck POST_BUILD COMMAND ${PYTHON_EXECUTABLE} run_mypy.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) +add_custom_command(TARGET typecheck POST_BUILD COMMAND ${Python3_EXECUTABLE} run_mypy.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) # # Tests include(UraniumTests) @@ -49,9 +58,9 @@ CREATE_TRANSLATION_TARGETS() if(EXISTS /etc/debian_version) - install(DIRECTORY UM DESTINATION lib${LIB_SUFFIX}/python${PYTHON_VERSION_MAJOR}/dist-packages) + install(DIRECTORY UM DESTINATION lib${LIB_SUFFIX}/python${Python3_VERSION_MAJOR}/dist-packages) else() - install(DIRECTORY UM DESTINATION lib${LIB_SUFFIX}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages) + install(DIRECTORY UM DESTINATION lib${LIB_SUFFIX}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages) endif() install(FILES ${CMAKE_SOURCE_DIR}/cmake/UraniumTranslationTools.cmake DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake-${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}/Modules/ ) diff --git a/CPackConfig.cmake b/CPackConfig.cmake index b104d646a3..874df96190 100644 --- a/CPackConfig.cmake +++ b/CPackConfig.cmake @@ -7,7 +7,7 @@ set(CPACK_PACKAGE_VERSION_PATCH 93) set(CPACK_GENERATOR "DEB;RPM") set(RPM_REQUIRES - "python3 >= 3.5.0" + "python3 >= ${Python3_VERSION}" "python3-qt5 >= 5.6.0" "qt5-qtquickcontrols >= 5.6.0" "arcus >= 15.05.90" @@ -16,7 +16,7 @@ string(REPLACE ";" "," RPM_REQUIRES "${RPM_REQUIRES}") set(CPACK_RPM_PACKAGE_REQUIRES ${RPM_REQUIRES}) set(DEB_DEPENDS - "python3 (>= 3.5.0)" + "python3 (>= ${Python3_VERSION})" "python3-pyqt5 (>= 5.6.0)" "python3-pyqt5.qtopengl (>= 5.6.0)" "python3-pyqt5.qtquick (>= 5.6.0)" diff --git a/cmake/UraniumPluginInstall.cmake b/cmake/UraniumPluginInstall.cmake index e170024ef7..8915286dba 100644 --- a/cmake/UraniumPluginInstall.cmake +++ b/cmake/UraniumPluginInstall.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Ultimaker B.V. +# Copyright (c) 2021 Ultimaker B.V. # UraniumPluginInstall.cmake is released under the terms of the LGPLv3 or higher. # @@ -10,17 +10,13 @@ # # FIXME: Remove the code for CMake <3.12 once we have switched over completely. -# FindPython3 is a new module since CMake 3.12. It deprecates FindPythonInterp and FindPythonLibs. The FindPython3 -# module is copied from the CMake repository here so in CMake <3.12 we can still use it. -if(${CMAKE_VERSION} VERSION_LESS 3.12) - # Use FindPythonInterp and FindPythonLibs for CMake <3.12 - find_package(PythonInterp 3 REQUIRED) - - set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE}) -else() - # Use FindPython3 for CMake >=3.12 - find_package(Python3 REQUIRED COMPONENTS Interpreter) +if(NOT DEFINED Python_VERSION) + set(Python_VERSION + 3.8 + CACHE STRING "Python Version" FORCE) + message(STATUS "Setting Python version to ${Python_VERSION}. Set Python_VERSION if you want to compile against an other version.") endif() +find_package(Python3 ${Python_VERSION} EXACT REQUIRED COMPONENTS Interpreter) # Options or configuration variables set(UM_NO_INSTALL_PLUGINS "" CACHE STRING "A list of plugins that should not be installed, separated with ';' or ','.") diff --git a/cmake/UraniumTests.cmake b/cmake/UraniumTests.cmake index 332b24c0f5..effde8dad3 100644 --- a/cmake/UraniumTests.cmake +++ b/cmake/UraniumTests.cmake @@ -32,7 +32,7 @@ function(uranium_add_test) add_test( NAME ${_NAME} - COMMAND ${PYTHON_EXECUTABLE} -m pytest --junitxml=${CMAKE_BINARY_DIR}/junit-${_NAME}.xml ${_DIRECTORY} + COMMAND ${Python3_EXECUTABLE} -m pytest --junitxml=${CMAKE_BINARY_DIR}/junit-${_NAME}.xml ${_DIRECTORY} ) set_tests_properties(${_NAME} PROPERTIES ENVIRONMENT LANG=C) set_tests_properties(${_NAME} PROPERTIES ENVIRONMENT "PYTHONPATH=${_PYTHONPATH}") @@ -52,5 +52,5 @@ endforeach() #Add code style test. add_test( NAME "code-style" - COMMAND ${PYTHON_EXECUTABLE} run_mypy.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${Python3_EXECUTABLE} run_mypy.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) \ No newline at end of file diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000000..3e7ad6aaed --- /dev/null +++ b/conanfile.py @@ -0,0 +1,51 @@ +import os +import pathlib + +from conans import ConanFile, tools +from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake + + +class UraniumConan(ConanFile): + name = "Uranium" + version = "4.12.0" + license = "LGPL-3.0" + author = "Ultimaker B.V." + url = "https://github.com/Ultimaker/uranium" + description = "A Python framework for building Desktop applications." + topics = ("conan", "python", "pyqt5", "qt", "3d-graphics", "3d-models", "python-framework") + settings = "os", "compiler", "build_type", "arch" + revision_mode = "scm" + build_policy = "missing" + exports = "LICENSE" + exports_sources = "plugins/*", "resources/*", "UM/*" + no_copy_source = True + scm = { + "type": "git", + "subfolder": ".", + "url": "auto", + "revision": "auto" + } + + def configure(self): + self.options["Arcus"].shared = self.settings.os != "Windows" + + def requirements(self): + self.requires(f"Python/3.8.10@python/testing") + self.requires(f"Arcus/4.11.0@ultimaker/testing") + + def package(self): + self.copy("*", src = os.path.join(self.source_folder, "plugins"), dst = os.path.join("site-packages", "plugins")) + self.copy("*", src = os.path.join(self.source_folder, "resources"), dst = os.path.join("site-packages", "resources")) + self.copy("*", src = os.path.join(self.source_folder, "UM"), dst = os.path.join("site-packages", "UM")) + self.copy("*.cmake", src = os.path.join(self.package_folder, "share"), dst = "cmake", keep_path=False) + + def package_info(self): + if self.in_local_cache: + self.user_info.URANIUM_CMAKE_PATH = str(os.path.join(self.package_folder, "cmake")) + self.runenv_info.prepend_path("PYTHONPATH", os.path.join(self.package_folder, "site-packages")) + else: + self.user_info.URANIUM_CMAKE_PATH = str(os.path.join(str(pathlib.Path(__file__).parent.absolute()), "cmake")) + self.runenv_info.prepend_path("PYTHONPATH", str(pathlib.Path(__file__).parent.absolute())) + + def package_id(self): + self.info.header_only()