Skip to content

Commit

Permalink
Python: tidy code (#2205)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrnz committed Nov 1, 2019
1 parent 8808a8e commit 1a9301f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
19 changes: 8 additions & 11 deletions src/plugins/thirdParty/Python/scripts/set_python_path.py
Expand Up @@ -46,7 +46,6 @@
import sys
import logging
import marshal
import argparse
from types import CodeType
from collections import OrderedDict

Expand Down Expand Up @@ -217,15 +216,16 @@ def update_paths(base, scripts_dir, clear_args, extra_args):
return True


def main():
if __name__ == '__main__':
import argparse

parser = argparse.ArgumentParser(description='Update the path of scripts '
'to a new Python prefix')

parser.add_argument('-c', '--clear-args', dest='clear_args',
default=False, action='store_true',
help='Clear all existing arguments to Python')

parser.add_argument('-u', '--update-path', dest='update_path',
parser.add_argument('-u', '--scripts-dir', dest='scripts_dir',
help='Path to scripts. Set to "auto" for autodetection')

parser.add_argument('-v', '--verbose', dest='verbose',
Expand All @@ -238,14 +238,11 @@ def main():
help='Additional arguments to append to Python')

args = parser.parse_args()
if not args.update_path:
args.update_path = 'auto'
if not args.scripts_dir:
args.scripts_dir = 'auto'

if not args.verbose:
logging.disable(logging.INFO)

sys.exit(0 if update_paths(args.path, args.update_path, args.clear_args, args.extra_args) else 1)


if __name__ == '__main__':
main()
if not update_paths(args.path, args.scripts_dir, args.clear_args, args.extra_args):
sys.exit(1)
2 changes: 1 addition & 1 deletion src/plugins/thirdParty/PythonPackages/CMakeLists.txt
Expand Up @@ -479,7 +479,7 @@ endif()

add_custom_command(TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_SCRIPT_DIR}/set_python_path.py --update-path ${FULL_LOCAL_EXTERNAL_PACKAGE_DIR}/${PYTHON_RELATIVE_SCRIPT_DIR}
COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_SCRIPT_DIR}/set_python_path.py --scripts-dir ${FULL_LOCAL_EXTERNAL_PACKAGE_DIR}/${PYTHON_RELATIVE_SCRIPT_DIR}
${PYTHON_ROOT_DIR}
-s)

Expand Down

0 comments on commit 1a9301f

Please sign in to comment.