Consolidate development env detection

This commit is contained in:
Kovid Goyal 2017-05-27 22:31:15 +05:30
parent 02b66f2be4
commit dee602246b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 13 additions and 12 deletions

View File

@ -258,13 +258,17 @@ else:
# }}}
dv = os.environ.get('CALIBRE_DEVELOP_FROM')
is_running_from_develop = bool(getattr(sys, 'frozen', False) and dv and os.path.abspath(dv) in sys.path)
del dv
def get_version():
'''Return version string for display to user '''
dv = os.environ.get('CALIBRE_DEVELOP_FROM', None)
v = __version__
if numeric_version[-1] == 0:
v = v[:-2]
if getattr(sys, 'frozen', False) and dv and os.path.abspath(dv) in sys.path:
if is_running_from_develop:
v += '*'
if iswindows and is64bit:
v += ' [64bit]'

View File

@ -13,7 +13,7 @@ from PyQt5.Qt import (
QApplication, QDialog, QUrl, QFont, QFontDatabase, QLocale, QFontInfo)
from calibre import prints
from calibre.constants import (islinux, iswindows, isbsd, isfrozen, isosx,
from calibre.constants import (islinux, iswindows, isbsd, isfrozen, isosx, is_running_from_develop,
plugins, config_dir, filesystem_encoding, isxp, DEBUG, __version__, __appname__ as APP_UID)
from calibre.ptempfile import base_dir
from calibre.utils.config import Config, ConfigProxy, dynamic, JSONConfig
@ -1420,9 +1420,8 @@ def build_forms(srcdir, info=None, summary=False, check_for_migration=False):
gprefs.set('migrated_forms_to_qt5', True)
_df = os.environ.get('CALIBRE_DEVELOP_FROM', None)
if _df and os.path.exists(_df):
build_forms(_df, check_for_migration=True)
if is_running_from_develop:
build_forms(os.environ['CALIBRE_DEVELOP_FROM'], check_for_migration=True)
def event_type_name(ev_or_etype):

View File

@ -8,7 +8,7 @@ import os
from threading import Thread
from calibre import as_unicode
from calibre.constants import cache_dir
from calibre.constants import cache_dir, is_running_from_develop
from calibre.srv.bonjour import BonJour
from calibre.srv.handler import Handler
from calibre.srv.http_response import create_http_handler
@ -82,8 +82,7 @@ class Server(object):
self.exception = None
from calibre.srv.content import reset_caches
try:
_df = os.environ.get('CALIBRE_DEVELOP_FROM', None)
if _df and os.path.exists(_df):
if is_running_from_develop:
from calibre.utils.rapydscript import compile_srv
compile_srv()
except BaseException as e:

View File

@ -10,7 +10,7 @@ import sys, os, signal
from functools import partial
from calibre import as_unicode, prints
from calibre.constants import plugins, iswindows, preferred_encoding
from calibre.constants import plugins, iswindows, preferred_encoding, is_running_from_develop
from calibre.srv.loop import ServerLoop
from calibre.srv.library_broker import load_gui_libraries
from calibre.srv.bonjour import BonJour
@ -77,8 +77,7 @@ class Server(object):
self.handler.set_jobs_manager(self.loop.jobs_manager)
self.serve_forever = self.loop.serve_forever
self.stop = self.loop.stop
_df = os.environ.get('CALIBRE_DEVELOP_FROM', None)
if _df and os.path.exists(_df):
if is_running_from_develop:
from calibre.utils.rapydscript import compile_srv
compile_srv()