-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bash command line completion for xAH_run.py in CMake (#1038)
* allow for argcomplete with CMake-based releases * update docs * inject register-python-arguments into ${ATLAS_PLATFORM}/setup.sh
- Loading branch information
Showing
7 changed files
with
164 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
### Install python packages | ||
|
||
# for setuptools | ||
find_package( pytools ) | ||
|
||
# Helper macro for building and installing the packages. Documentation | ||
# to be written later... | ||
function( setup_python_package name file md5 ) | ||
|
||
# Parse the optional argument(s): | ||
cmake_parse_arguments( ARG "SINGLE_VERSION" "" | ||
"DEPENDS;EXTRA_ARGS;PATCH" ${ARGN} ) | ||
|
||
# Extra argument(s) for the installation: | ||
if( ARG_SINGLE_VERSION ) | ||
set( _extraArg ) | ||
else() | ||
set( _extraArg --single-version-externally-managed ) | ||
endif() | ||
|
||
if ( ARG_PATCH ) | ||
set( _patchCmd PATCH_COMMAND patch -p1 < ${ARG_PATCH} ) | ||
endif() | ||
|
||
# Build the package with the help of python's distutils: | ||
ExternalProject_Add( ${name} | ||
PREFIX ${CMAKE_BINARY_DIR} | ||
URL ${file} | ||
URL_MD5 ${md5} | ||
BUILD_IN_SOURCE 1 | ||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo | ||
"Configuring the build of ${name}" | ||
${_patchCmd} | ||
BUILD_COMMAND ${CMAKE_BINARY_DIR}/atlas_build_run.sh | ||
python setup.py ${ARG_EXTRA_ARGS} build | ||
INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory | ||
${CMAKE_PYTHON_OUTPUT_DIRECTORY} | ||
COMMAND ${CMAKE_COMMAND} -E make_directory | ||
${CMAKE_RUNTIME_OUTPUT_DIRECTORY} | ||
COMMAND ${CMAKE_BINARY_DIR}/atlas_build_run.sh | ||
python setup.py ${ARG_EXTRA_ARGS} install | ||
--prefix ${CMAKE_BINARY_DIR}/${ATLAS_PLATFORM} | ||
--exec-prefix ${CMAKE_BINARY_DIR}/${ATLAS_PLATFORM} | ||
--root / | ||
--install-lib ${CMAKE_PYTHON_OUTPUT_DIRECTORY} | ||
--install-scripts ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} | ||
${_extraArg} ) | ||
|
||
# Make the package target depend on this one: | ||
add_dependencies( Package_xAODAnaHelpers ${name} ) | ||
|
||
# Add possible extra dependencies: | ||
if( ARG_DEPENDS ) | ||
add_dependencies( ${name} ${ARG_DEPENDS} ) | ||
endif() | ||
|
||
# Get the package directory: | ||
atlas_get_package_dir( pkgDir ) | ||
|
||
# Add some metadata to the target: | ||
set_property( TARGET ${name} PROPERTY LABEL xAODAnaHelpers ) | ||
set_property( TARGET ${name} PROPERTY FOLDER ${pkgDir} ) | ||
|
||
# Generate the package installer script: | ||
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkgbuildInstall.cmake.in | ||
${CMAKE_CURRENT_BINARY_DIR}/${name}PkgbuildInstall.cmake | ||
@ONLY ) | ||
|
||
# Use this script for installing the package: | ||
install( SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/${name}PkgbuildInstall.cmake ) | ||
|
||
endfunction( setup_python_package ) | ||
|
||
# Clean up: | ||
unset( setup_python_package ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- setup.cfg-orig 2017-09-27 10:58:54.738687009 -0500 | ||
+++ setup.cfg 2017-09-27 10:59:06.210122091 -0500 | ||
@@ -17,3 +17,5 @@ | ||
tag_build = | ||
tag_date = 0 | ||
|
||
+[build] | ||
+executable = /usr/bin/env python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# $Id: pkgbuildInstall.cmake.in 720559 2016-01-29 09:13:32Z krasznaa $ | ||
# | ||
# Script installing a setuptools / distutils based Python package | ||
# during the release installation, under $CMAKE_INSTALL_PREFIX. | ||
# | ||
|
||
# Get the destination directory as an absolute path, as the setup.py script | ||
# can't deal with relative paths correctly. | ||
if( NOT "$ENV{DESTDIR}" STREQUAL "" ) | ||
get_filename_component( _destdir $ENV{DESTDIR} ABSOLUTE ) | ||
endif() | ||
|
||
# Install the package: | ||
execute_process( COMMAND ${CMAKE_BINARY_DIR}/atlas_build_run.sh | ||
python setup.py @ARG_EXTRA_ARGS@ install | ||
--prefix ${_destdir}${CMAKE_INSTALL_PREFIX} | ||
--exec-prefix ${_destdir}${CMAKE_INSTALL_PREFIX} | ||
--root / | ||
--install-lib ${_destdir}${CMAKE_INSTALL_PREFIX}/@CMAKE_INSTALL_PYTHONDIR@ | ||
--install-scripts ${_destdir}${CMAKE_INSTALL_PREFIX}/@CMAKE_INSTALL_BINDIR@ | ||
--record @CMAKE_CURRENT_BINARY_DIR@/@name@_installed.files | ||
@_extraArg@ | ||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src/@name@ ) | ||
|
||
# Read in the list of installed files, and select ones put into the | ||
# binary directory. | ||
file( READ @CMAKE_CURRENT_BINARY_DIR@/@name@_installed.files | ||
_installedFiles LIMIT 10000000 ) | ||
string( SUBSTRING "${_destdir}${CMAKE_INSTALL_PREFIX}/@CMAKE_INSTALL_BINDIR@" | ||
1 -1 _binDir ) | ||
string( REGEX MATCHALL "(^|\n)${_binDir}[^\n]+" _executables | ||
${_installedFiles} ) | ||
|
||
# Loop over the installed executables: | ||
foreach( _exec ${_executables} ) | ||
# And replace the absolute python executable names in them with | ||
# relocatable ones. | ||
string( STRIP ${_exec} _execName ) | ||
# This is unfortunately very unportable. But should be hopefully good | ||
# enough on all POSIX platforms at least. | ||
execute_process( COMMAND | ||
sed "s/^#!\\/.*\\/python/#!\\/usr\\/bin\\/env python/" | ||
"/${_execName}" | ||
COMMAND tee /${_execName}Fixed | ||
COMMAND ${CMAKE_COMMAND} -E rename "/${_execName}Fixed" "/${_execName}" ) | ||
# For some reason this doesn't work correctly (in CMake 3.3.2) when put at | ||
# the end of the previous execute_process(...) call. Only when used in a | ||
# separate call... | ||
execute_process( COMMAND chmod 755 /${_execName} ) | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
# xAODAnaHelpers injected shell commands are below | ||
eval "$(register-python-argcomplete xAH_run.py)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters