From f4e5714391a2a3e3f1cd785bf2ec86e375362398 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 14 Jun 2011 13:08:13 -0600 Subject: [PATCH] Portable build: set a env var --- setup/installer/windows/portable.c | 5 +++++ src/calibre/constants.py | 1 + 2 files changed, 6 insertions(+) diff --git a/setup/installer/windows/portable.c b/setup/installer/windows/portable.c index 2a557e9174..05763bc303 100644 --- a/setup/installer/windows/portable.c +++ b/setup/installer/windows/portable.c @@ -95,6 +95,11 @@ void launch_calibre(LPCTSTR exe, LPCTSTR config_dir, LPCTSTR library_dir) { ExitProcess(1); } + if (! SetEnvironmentVariable(TEXT("CALIBRE_PORTABLE_BUILD"), exe)) { + show_last_error(TEXT("Failed to set environment variables")); + ExitProcess(1); + } + dwFlags = CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_PROCESS_GROUP; _sntprintf_s(cmdline, BUFSIZE, _TRUNCATE, TEXT(" \"--with-library=%s\""), library_dir); diff --git a/src/calibre/constants.py b/src/calibre/constants.py index f6b0a8d802..627f1b751a 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -32,6 +32,7 @@ isbsd = isfreebsd or isnetbsd islinux = not(iswindows or isosx or isbsd) isfrozen = hasattr(sys, 'frozen') isunix = isosx or islinux +isportable = os.environ.get('CALIBRE_PORTABLE_BUILD', None) is not None try: preferred_encoding = locale.getpreferredencoding()