Skip to content

Commit 4370c61

Browse files
authored
Merge pull request #3166 from ferdnyc/pythonpath-arg
launch.py: Add a --path arg to set PYTHONPATH
2 parents 043633c + 7ba96bf commit 4370c61

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/launch.py

+17
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"""
4242

4343
import sys
44+
import os.path
4445
import argparse
4546

4647
try:
@@ -63,6 +64,10 @@ def main():
6364
parser.add_argument('--list-languages', dest='list_languages',
6465
action='store_true', help='List all language '
6566
'codes supported by OpenShot')
67+
parser.add_argument('--path', dest='py_path',
68+
action='append',
69+
help='Additional locations to search for modules '
70+
'(PYTHONPATH). Can be used multiple times.')
6671
parser.add_argument('-V', '--version', action='store_true')
6772
parser.add_argument('remain', nargs=argparse.REMAINDER,
6873
help=argparse.SUPPRESS)
@@ -81,6 +86,18 @@ def main():
8186
print(" {:>12} {}".format(lang[0],lang[1]))
8287
sys.exit()
8388

89+
if args.py_path:
90+
for p in args.py_path:
91+
try:
92+
if os.path.exists(os.path.realpath(p)):
93+
sys.path.insert(0, os.path.realpath(p))
94+
print("Added {} to PYTHONPATH".format(os.path.realpath(p)))
95+
else:
96+
print("{} does not exist".format(os.path.realpath(p)))
97+
except TypeError as ex:
98+
print("Bad path {}: {}".format(p, ex))
99+
continue
100+
84101
if args.lang:
85102
if args.lang in info.SUPPORTED_LANGUAGES:
86103
info.CMDLINE_LANGUAGE = args.lang

0 commit comments

Comments
 (0)