From 99bd15cd2015f135ae20ffeee2b79d56ec3198be Mon Sep 17 00:00:00 2001 From: Frank Sauerburger <f.sauerburger@cern.ch> Date: Thu, 11 Feb 2021 11:44:02 +0100 Subject: [PATCH] Generate __init__.py in x86_64 directory if ASG env --- QFramework/CMakeLists.txt | 16 +++++++++++++--- QFramework/share/generateBindings.py | 14 ++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/QFramework/CMakeLists.txt b/QFramework/CMakeLists.txt index 1fb77b6e3..abe57753a 100644 --- a/QFramework/CMakeLists.txt +++ b/QFramework/CMakeLists.txt @@ -50,7 +50,17 @@ find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO HistPainter Matrix Gpa # set some variables for easier handling set(QFrameworkLinkDef ${CMAKE_CURRENT_BINARY_DIR}/LinkDef.h) -set(QFrameworkPythonInit ${CMAKE_CURRENT_BINARY_DIR}/__init__.py) +if(NOT WITHOUT_ASG) + # With ASG, use x86_64 location for python modules + set(QFrameworkPythonInit ${CMAKE_PYTHON_OUTPUT_DIRECTORY}/QFramework/__init__.py) + # Remove old files, to force switch to new directory + file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/__init__.py) + file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/__init__.pyc) +ELSE() + # Use legacy path + set(QFrameworkPythonInit ${CMAKE_CURRENT_BINARY_DIR}/__init__.py) +ENDIF() + file(GLOB QFrameworkPython "python/*.py") #note: this does not include __init__.py since it's not generated yet! file(GLOB QFrameworkSources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "Root/[A-Za-z]*.cxx") file(GLOB QFrameworkHeaders RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "QFramework/[A-Za-z]*.h") @@ -90,8 +100,8 @@ if(NOT WITHOUT_ASG) LINK_LIBRARIES xAODCore xAODRootAccess xAODTruth xAODBase xAODCutFlow ${ROOT_LIBRARIES} PRIVATE_LINK_LIBRARIES ${LIBXML2_LIBRARIES} ) - atlas_install_python_modules( python/*.py ) - + atlas_install_python_modules( ${QFrameworkPython} ) + # register the test cases find_package(PythonInterp REQUIRED) foreach(TestScript ${QFrameworkPythonTests}) diff --git a/QFramework/share/generateBindings.py b/QFramework/share/generateBindings.py index e5f08d2e4..df316f1fe 100644 --- a/QFramework/share/generateBindings.py +++ b/QFramework/share/generateBindings.py @@ -1,5 +1,17 @@ #!/bin/env python +import os +import errno + +def ensure_dir(directory): + """Create (parent) directories if non-existent""" + try: + os.makedirs(directory) + except OSError as e: + if e.errno != errno.EEXIST: + raise + + def fhash(fname): # get a hash of a file (using stupid filesize replacement for now) import os @@ -29,6 +41,8 @@ class Dummysink(object): def datasink(filename): if filename: + directory = os.path.dirname(filename) + ensure_dir(directory) return open(filename, "wt") else: return Dummysink() -- GitLab