__init__ & wrapper scripts for wheel
This commit is contained in:
parent
f9f6d9c50e
commit
f43394b4af
4 changed files with 50 additions and 0 deletions
1
__init__.py
Normal file
1
__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
|
10
__main__.py
Normal file
10
__main__.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env python3
|
||||
# Tries to run_as_subprocess.py as an absolute and relative import. (for script or module)
|
||||
import sys
|
||||
|
||||
try:
|
||||
from .run_as_subprocess import main
|
||||
except (ImportError, ModuleNotFoundError):
|
||||
from run_as_subprocess import main
|
||||
|
||||
main(sys.argv)
|
13
pesterchum
Executable file
13
pesterchum
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
# Run pesterchum either locally or when installed as library/module.
|
||||
# If installed as library/module can be excecuted from anywhere.
|
||||
#echo $@
|
||||
|
||||
if [ -f "pesterchum.py" ];
|
||||
then
|
||||
python3 pesterchum.py $@
|
||||
|
||||
else
|
||||
python3 -m pesterchum_alt $@
|
||||
|
||||
fi
|
26
run_as_subprocess.py
Normal file
26
run_as_subprocess.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env python3
|
||||
# Wrapper script to run Pesterchum from an import independently of the current working directory. (useful for wheel)
|
||||
# Running MainProgram() from an import would be better, but I think it requires making **all** imports relative depending on __main__,
|
||||
# and probably other stuff too-
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import call
|
||||
|
||||
#print(sys.argv)
|
||||
def main(argv):
|
||||
arguments = ''
|
||||
for x in argv[1:]:
|
||||
arguments += x + ' '
|
||||
#print(arguments)
|
||||
|
||||
directory_path = os.getcwd()
|
||||
print("Working directory: " + directory_path)
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
print("Working directory set to: " + directory_path)
|
||||
print("Running Pesterchum as subprocess, this is not ideal.")
|
||||
retcode = call("python3 pesterchum.py " + " " + str(arguments), shell=True)
|
||||
print(retcode)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv)
|
Loading…
Reference in a new issue