forked from npshub/mantid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
packagesetup.py.in
53 lines (43 loc) · 1.56 KB
/
packagesetup.py.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
===== AUTO-GENERATED MODULE ====
Handles set up of aspects related to extra Python packages e.g. adding
any required paths to sys.path, setting environment variables etc.
"""
from __future__ import (absolute_import, division,
print_function)
import os as _os
import sys as _sys
def update_sys_paths(paths, recursive=False):
"""
Add the required script directories to the path
@param paths A list of path strings or a string using a semi-colon
separator
@param recursive If true then all directories below the given paths
are added as well
"""
if paths == "":
return
if type(paths) == str:
paths = paths.split(";")
def _append_to_path(path):
# sys.path doesn't like trailing slashes
_sys.path.append(path.rstrip("\\").rstrip("/"))
for path in paths:
_append_to_path(path)
if recursive:
for dirpath, dirnames, filenames in _os.walk(path):
for dirname in dirnames:
_append_to_path(_os.path.join(dirpath, dirname))
def set_NEXUSLIB_var():
"""
Sets the NEXUSLIB environment variable to point to the NeXus shared library
"""
import os as _os
_nexuslib = r"@NEXUSLIB@"
if _nexuslib == "":
return
if not _os.path.isabs(_nexuslib):
# Assume relative to this file
thisdir = _os.path.dirname(__file__)
_nexuslib = _os.path.normpath(_os.path.join(thisdir, _nexuslib))
_os.environ['NEXUSLIB'] = _nexuslib