Skip to content

Added support for Conan as a dependency manager #720

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

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,5 @@ resources/.DS_Store

#Common plug-ins
plugins/UraniumExample*Plugin
/cmake-build-debug/
/cmake-build-release/
23 changes: 16 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project(uranium NONE)

cmake_minimum_required(VERSION 3.6)
cmake_minimum_required(VERSION 3.13)

message(STATUS ${CMAKE_MODULE_PATH})

Expand All @@ -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)
Expand All @@ -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/ )
Expand Down
4 changes: 2 additions & 2 deletions CPackConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)"
Expand Down
18 changes: 7 additions & 11 deletions cmake/UraniumPluginInstall.cmake
Original file line number Diff line number Diff line change
@@ -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.

#
Expand All @@ -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 ','.")
Expand Down
4 changes: 2 additions & 2 deletions cmake/UraniumTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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}
)
51 changes: 51 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -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()