Skip to content

Commit

Permalink
CWD switching when exe launch
Browse files Browse the repository at this point in the history
  • Loading branch information
paularnaud2 committed Jan 3, 2022
1 parent 1b2e773 commit 040c25a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions partools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from os.path import dirname

print("CWD:", os.getcwd())

Expand All @@ -17,6 +18,15 @@ def load_module(name, path):
def overwrite_cfg():
import partools.conf as cfg

# Switching CWD to root
file_path = os.path.realpath(__file__)
print('file_path', file_path)
if file_path[-4] == '.pyc':
ncwd = dirname(dirname(file_path))
if os.getcwd() != ncwd:
os.chdir(ncwd)
print(f"Switched CWD to {ncwd}")

if os.path.exists('PTconf_perso.py'):
super_path = 'PTconf_perso.py'
PTconf = load_module('PTconf', super_path)
Expand Down

0 comments on commit 040c25a

Please sign in to comment.