Move loading of env vars to bypy. Allows defining CALIBRE_DEVELOP_FROM in env vars file

This commit is contained in:
Kovid Goyal 2020-11-21 12:20:54 +05:30
parent 4265c87463
commit 3dd7bc160e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 25 deletions

View File

@ -653,7 +653,11 @@ class Freeze(object):
os.rename(join(src, x), join(pydir, x))
os.rmdir(src)
py_compile(pydir)
freeze_python(pydir, dest, self.inc_dir, self.ext_map, develop_mode_env_var='CALIBRE_DEVELOP_FROM')
freeze_python(
pydir, dest, self.inc_dir, self.ext_map,
develop_mode_env_var='CALIBRE_DEVELOP_FROM',
path_to_user_env_vars='~/Library/Preferences/calibre/macos-env.txt'
)
shutil.rmtree(pydir)
def create_app_clone(self, name, specialise_plist, remove_doc_types=False, base_dir=None):

View File

@ -4,21 +4,6 @@ import sys
import _sitebuiltins
def read_user_env_vars():
try:
with open(os.path.expanduser('~/Library/Preferences/calibre/macos-env.txt'), 'rb') as f:
raw = f.read().decode('utf-8', 'replace')
except EnvironmentError:
return
for line in raw.splitlines():
if line.startswith('#'):
continue
parts = line.split('=', 1)
if len(parts) == 2:
key, val = parts
os.environ[key] = os.path.expandvars(os.path.expanduser(val))
def nuke_stdout():
# Redirect stdout, stdin and stderr to /dev/null
from calibre_extensions.speedup import detach
@ -37,15 +22,6 @@ def set_quit():
def main():
sys.argv[0] = sys.calibre_basename
try:
read_user_env_vars()
except Exception as err:
try:
print('Failed to read user env vars with error:', err, file=sys.stderr)
sys.stderr.flush()
except Exception:
pass
set_helper()
set_quit()
mod = __import__(sys.calibre_module, fromlist=[1])