mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Move loading of env vars to bypy. Allows defining CALIBRE_DEVELOP_FROM in env vars file
This commit is contained in:
parent
4265c87463
commit
3dd7bc160e
@ -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):
|
||||
|
@ -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])
|
||||
|
Loading…
x
Reference in New Issue
Block a user