Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libmtime
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
icon-libraries
libmtime
Commits
3458e695
Commit
3458e695
authored
4 months ago
by
Sergey Kosukhin
Browse files
Options
Downloads
Patches
Plain Diff
cmake: install Python interface
parent
0123ab60
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!56
CMake support for the Python interface
Pipeline
#91512
passed
4 months ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+1
-0
1 addition, 0 deletions
CMakeLists.txt
cmake/GNUInstallPythonDirs.cmake
+85
-0
85 additions, 0 deletions
cmake/GNUInstallPythonDirs.cmake
python/CMakeLists.txt
+10
-0
10 additions, 0 deletions
python/CMakeLists.txt
with
96 additions
and
0 deletions
CMakeLists.txt
+
1
−
0
View file @
3458e695
...
...
@@ -35,6 +35,7 @@ if(MTIME_ENABLE_PYTHON)
# Technically, we can produce the Python interface without the interpreter but
# we REQUIRE it for now for the consistency with the Autotools-based building:
find_package
(
Python REQUIRED COMPONENTS Interpreter
)
include
(
GNUInstallPythonDirs
)
add_subdirectory
(
python
)
endif
()
...
...
This diff is collapsed.
Click to expand it.
cmake/GNUInstallPythonDirs.cmake
0 → 100644
+
85
−
0
View file @
3458e695
# Copyright (c) 2013-2024 MPI-M, Luis Kornblueh, Rahul Sinha and DWD, Florian Prill. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
if
(
NOT DEFINED Python_FOUND
)
message
(
AUTHOR_WARNING
"The macro requires Python: you either need to find_package(Python) or "
"make sure that the following variables are set (e.g. you can get valid "
"values under different variable names from find_package(Python3)): "
"Python_FOUND, Python_EXECUTABLE, "
"Python_VERSION_MAJOR, Python_VERSION_MINOR"
)
endif
()
# ~~~
# _GNUInstallPythonDirs_get_sitedir(<plat_specific>,
# <fallback>,
# <variable>,
# <description>)
# ~~~
# Requests ${Python_EXECUTABLE} for the subdirectory for either the general
# (when <plat_specific> is set to 0) or platform-dependent (when <plat_specific>
# is set to 1) library installation. Set the cash <variable> with the provided
# <description> to the result of the request. If the request fails, the
# <variable> is set to the <fallback> value.
#
macro
(
_GNUInstallPythonDirs_get_sitedir plat_specific fallback variable description
)
unset
(
_sitedir
)
if
(
Python_FOUND
)
execute_process
(
COMMAND
${
Python_EXECUTABLE
}
-c
"from distutils import sysconfig as sc;print(sc.get_python_lib(
${
plat_specific
}
,0,''))"
RESULT_VARIABLE _success
OUTPUT_VARIABLE _sitedir
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
)
if
(
NOT _success EQUAL 0
)
unset
(
_sitedir
)
endif
()
unset
(
_success
)
endif
()
if
(
NOT _sitedir
)
set
(
_sitedir
"
${
fallback
}
"
)
endif
()
set
(
${
variable
}
"
${
_sitedir
}
"
CACHE PATH
"
${
description
}
"
)
unset
(
_sitedir
)
endmacro
()
if
(
NOT CMAKE_INSTALL_PYTHON_PURELIBDIR
)
_gnuinstallpythondirs_get_sitedir
(
0
"
${
CMAKE_INSTALL_LIBDIR
}
/python
${
Python_VERSION_MAJOR
}
.
${
Python_VERSION_MINOR
}
/site-packages"
CMAKE_INSTALL_PYTHON_PURELIBDIR
"Python platform-independent libraries"
)
endif
()
if
(
NOT CMAKE_INSTALL_PYTHON_PLATLIB
)
_gnuinstallpythondirs_get_sitedir
(
1
"
${
CMAKE_INSTALL_PYTHON_PURELIBDIR
}
"
CMAKE_INSTALL_PYTHON_PLATLIBDIR
"Python platform-specific libraries"
)
endif
()
foreach
(
dir PYTHON_PURELIBDIR PYTHON_PLATLIBDIR
)
if
(
COMMAND GNUInstallDirs_get_absolute_install_dir
)
GNUInstallDirs_get_absolute_install_dir
(
CMAKE_INSTALL_FULL_
${
dir
}
CMAKE_INSTALL_
${
dir
}
${
dir
}
)
else
()
set
(
CMAKE_INSTALL_FULL_
${
dir
}
"
${
CMAKE_INSTALL_PREFIX
}
/
${
CMAKE_INSTALL_
${
dir
}}
"
)
endif
()
endforeach
()
This diff is collapsed.
Click to expand it.
python/CMakeLists.txt
+
10
−
0
View file @
3458e695
...
...
@@ -34,3 +34,13 @@ file(
dummy
# just don't fail if something goes wrong (e.g. building in-source)
COPY_ON_ERROR SYMBOLIC
)
install
(
TARGETS mtime_py
LIBRARY DESTINATION
${
CMAKE_INSTALL_PYTHON_PLATLIBDIR
}
/
${
module_dir_name
}
)
install
(
FILES
${
module_source_dir
}
/__init__.py
${
module_binary_dir
}
/_mtime.py
DESTINATION
${
CMAKE_INSTALL_PYTHON_PLATLIBDIR
}
/
${
module_dir_name
}
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment