Drop 32-bit code paths

This commit is contained in:
Kovid Goyal 2021-12-23 14:33:17 +05:30
parent 74600b7c07
commit 5db39aa16e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
14 changed files with 81 additions and 106 deletions

View File

@ -13,7 +13,7 @@ import time
from functools import partial from functools import partial
from bypy.constants import ( from bypy.constants import (
OUTPUT_DIR, PREFIX, SRC as CALIBRE_DIR, is64bit, python_major_minor_version OUTPUT_DIR, PREFIX, SRC as CALIBRE_DIR, python_major_minor_version
) )
from bypy.freeze import ( from bypy.freeze import (
extract_extension_modules, fix_pycryptodome, freeze_python, path_to_freeze_dir extract_extension_modules, fix_pycryptodome, freeze_python, path_to_freeze_dir
@ -24,8 +24,10 @@ from bypy.utils import (
j = os.path.join j = os.path.join
self_dir = os.path.dirname(os.path.abspath(__file__)) self_dir = os.path.dirname(os.path.abspath(__file__))
arch = 'x86_64' if is64bit else 'i686' machine = (os.uname()[4] or '').lower()
arch = 'x86_64'
if machine.startswith('arm') or machine.startswith('aarch64'):
arch = 'arm64'
py_ver = '.'.join(map(str, python_major_minor_version())) py_ver = '.'.join(map(str, python_major_minor_version()))
QT_PREFIX = os.path.join(PREFIX, 'qt') QT_PREFIX = os.path.join(PREFIX, 'qt')
iv = globals()['init_env'] iv = globals()['init_env']

View File

@ -16,7 +16,7 @@ import sys
import zipfile import zipfile
from bypy.constants import ( from bypy.constants import (
CL, LINK, MT, PREFIX, RC, SIGNTOOL, SRC as CALIBRE_DIR, SW, build_dir, is64bit, CL, LINK, MT, PREFIX, RC, SIGNTOOL, SRC as CALIBRE_DIR, SW, build_dir,
python_major_minor_version, worker_env python_major_minor_version, worker_env
) )
from bypy.freeze import ( from bypy.freeze import (
@ -32,7 +32,7 @@ QT_DLLS, QT_PLUGINS, PYQT_MODULES = iv['QT_DLLS'], iv['QT_PLUGINS'], iv['PYQT_MO
APPNAME, VERSION = calibre_constants['appname'], calibre_constants['version'] APPNAME, VERSION = calibre_constants['appname'], calibre_constants['version']
WINVER = VERSION + '.0' WINVER = VERSION + '.0'
machine = 'X64' if is64bit else 'X86' machine = 'X64'
j, d, a, b = os.path.join, os.path.dirname, os.path.abspath, os.path.basename j, d, a, b = os.path.join, os.path.dirname, os.path.abspath, os.path.basename
create_installer = runpy.run_path( create_installer = runpy.run_path(
j(d(a(__file__)), 'wix.py'), {'calibre_constants': calibre_constants} j(d(a(__file__)), 'wix.py'), {'calibre_constants': calibre_constants}
@ -514,7 +514,7 @@ def build_launchers(env, incdir, debug=False):
def copy_crt_and_d3d(env): def copy_crt_and_d3d(env):
printf('Copying CRT and D3D...') printf('Copying CRT and D3D...')
plat = ('x64' if is64bit else 'x86') plat = 'x64'
for key, val in worker_env.items(): for key, val in worker_env.items():
if 'COMNTOOLS' in key.upper(): if 'COMNTOOLS' in key.upper():
redist_dir = os.path.dirname(os.path.dirname(val.rstrip(os.sep))) redist_dir = os.path.dirname(os.path.dirname(val.rstrip(os.sep)))
@ -533,7 +533,7 @@ def copy_crt_and_d3d(env):
worker_env['WINDOWSSDKDIR'], 'Redist', 'D3D', plat) worker_env['WINDOWSSDKDIR'], 'Redist', 'D3D', plat)
if not os.path.exists(d3d_path): if not os.path.exists(d3d_path):
raise SystemExit('Windows 10 D3D redistributable not found at: %r' % d3d_path) raise SystemExit('Windows 10 D3D redistributable not found at: %r' % d3d_path)
mesa_path = os.path.join(os.environ['MESA'], ('64' if is64bit else '32'), 'opengl32sw.dll') mesa_path = os.path.join(os.environ['MESA'], '64', 'opengl32sw.dll')
if not os.path.exists(mesa_path): if not os.path.exists(mesa_path):
raise SystemExit('Mesa DLLs (opengl32sw.dll) not found at: %r' % mesa_path) raise SystemExit('Mesa DLLs (opengl32sw.dll) not found at: %r' % mesa_path)
@ -582,9 +582,8 @@ def main():
if args.sign_installers: if args.sign_installers:
sign_executables(env) sign_executables(env)
create_installer(env) create_installer(env)
if not is64bit: build_portable(env)
build_portable(env) build_portable_installer(env)
build_portable_installer(env)
if args.sign_installers: if args.sign_installers:
sign_installers(env) sign_installers(env)

View File

@ -7,7 +7,6 @@ __docformat__ = 'restructuredtext en'
import errno import errno
import os import os
import platform
import re import re
import shutil import shutil
import subprocess import subprocess
@ -18,7 +17,6 @@ import hashlib
from contextlib import contextmanager from contextlib import contextmanager
from functools import lru_cache from functools import lru_cache
is64bit = platform.architecture()[0] == '64bit'
iswindows = re.search('win(32|64)', sys.platform) iswindows = re.search('win(32|64)', sys.platform)
ismacos = 'darwin' in sys.platform ismacos = 'darwin' in sys.platform
isfreebsd = 'freebsd' in sys.platform isfreebsd = 'freebsd' in sys.platform
@ -280,17 +278,12 @@ class Command:
shutil.rmtree(ans) shutil.rmtree(ans)
def installer_name(ext, is64bit=False): def installer_names(include_source=True):
if is64bit and ext == 'msi': base = f'dist/{__appname__}'
return 'dist/%s-64bit-%s.msi'%(__appname__, __version__) yield f'{base}-64bit-{__version__}.msi'
if ext in ('exe', 'msi'): yield f'{base}-{__version__}.dmg'
return 'dist/%s-%s.%s'%(__appname__, __version__, ext) yield f'{base}-portable-installer-{__version__}.exe'
if ext == 'dmg': for arch in ('x86_64', 'arm64'):
if is64bit: yield f'{base}-{__version__}-{arch}.txz'
return 'dist/%s-%s-x86_64.%s'%(__appname__, __version__, ext) if include_source:
return 'dist/%s-%s.%s'%(__appname__, __version__, ext) yield f'{base}-{__version__}.tar.xz'
ans = 'dist/%s-%s-i686.%s'%(__appname__, __version__, ext)
if is64bit:
ans = ans.replace('i686', 'x86_64')
return ans

View File

@ -182,7 +182,7 @@ is_macos_universal_build = ismacos and 'universal2' in sysconfig.get_platform()
def init_env(debug=False, sanitize=False): def init_env(debug=False, sanitize=False):
from setup.build_environment import win_ld, is64bit, win_inc, win_lib, NMAKE, win_cc from setup.build_environment import win_ld, win_inc, win_lib, NMAKE, win_cc
linker = None linker = None
if isunix: if isunix:
cc = os.environ.get('CC', 'gcc') cc = os.environ.get('CC', 'gcc')
@ -244,8 +244,7 @@ def init_env(debug=False, sanitize=False):
ldflags.append('/DEBUG') ldflags.append('/DEBUG')
# cflags = '/c /nologo /Ox /MD /W3 /EHsc /Zi'.split() # cflags = '/c /nologo /Ox /MD /W3 /EHsc /Zi'.split()
# ldflags = '/DLL /nologo /INCREMENTAL:NO /DEBUG'.split() # ldflags = '/DLL /nologo /INCREMENTAL:NO /DEBUG'.split()
if is64bit: cflags.append('/GS-')
cflags.append('/GS-')
for p in win_inc: for p in win_inc:
cflags.append('-I'+p) cflags.append('-I'+p)

View File

@ -25,6 +25,14 @@ if enc.lower() == 'ascii':
enc = 'utf-8' enc = 'utf-8'
dl_url = calibre_version = signature = None dl_url = calibre_version = signature = None
has_ssl_verify = hasattr(ssl, 'create_default_context') has_ssl_verify = hasattr(ssl, 'create_default_context')
is_linux_arm = is_linux_arm64 = False
machine = (os.uname()[4] or '').lower()
arch = 'x86_64'
if machine.startswith('arm') or machine.startswith('aarch64'):
is_linux_arm = True
is_linux_arm64 = machine.startswith('arm64') or machine.startswith('aarch64')
arch = 'arm64'
if py3: if py3:
unicode = str unicode = str
@ -320,9 +328,7 @@ def do_download(dest):
def download_tarball(): def download_tarball():
fname = 'calibre-%s-i686.%s'%(calibre_version, 'txz') fname = 'calibre-%s-%s.%s'%(calibre_version, arch, 'txz')
if is64bit:
fname = fname.replace('i686', 'x86_64')
tdir = tempfile.gettempdir() tdir = tempfile.gettempdir()
cache = os.path.join(tdir, 'calibre-installer-cache') cache = os.path.join(tdir, 'calibre-installer-cache')
if not os.path.exists(cache): if not os.path.exists(cache):
@ -648,14 +654,14 @@ def get_tarball_info(version):
print('Downloading tarball signature securely...') print('Downloading tarball signature securely...')
if version: if version:
signature = get_https_resource_securely( signature = get_https_resource_securely(
'https://code.calibre-ebook.com/signatures/calibre-' + version + '-' + ('x86_64' if is64bit else 'i686') + '.txz.sha512') 'https://code.calibre-ebook.com/signatures/calibre-' + version + '-' + arch + '.txz.sha512')
calibre_version = version calibre_version = version
dl_url = 'https://download.calibre-ebook.com/' + version + '/calibre-' + version + '-' + ('x86_64' if is64bit else 'i686') + '.txz' dl_url = 'https://download.calibre-ebook.com/' + version + '/calibre-' + version + '-' + arch + '.txz'
else: else:
raw = get_https_resource_securely( raw = get_https_resource_securely(
'https://code.calibre-ebook.com/tarball-info/' + ('x86_64' if is64bit else 'i686')) 'https://code.calibre-ebook.com/tarball-info/' + arch)
signature, calibre_version = raw.rpartition(b'@')[::2] signature, calibre_version = raw.rpartition(b'@')[::2]
dl_url = 'https://calibre-ebook.com/dist/linux'+('64' if is64bit else '32') dl_url = 'https://calibre-ebook.com/dist/linux-' + arch
if not signature or not calibre_version: if not signature or not calibre_version:
raise ValueError('Failed to get install file signature, invalid signature returned') raise ValueError('Failed to get install file signature, invalid signature returned')
dl_url = os.environ.get('CALIBRE_INSTALLER_LOCAL_URL', dl_url) dl_url = os.environ.get('CALIBRE_INSTALLER_LOCAL_URL', dl_url)
@ -763,11 +769,10 @@ def check_glibc_version(min_required=(2, 31), release_date='2020-02-01'):
def main(install_dir=None, isolated=False, bin_dir=None, share_dir=None, ignore_umask=False, version=None): def main(install_dir=None, isolated=False, bin_dir=None, share_dir=None, ignore_umask=False, version=None):
if not ignore_umask and not isolated: if not ignore_umask and not isolated:
check_umask() check_umask()
machine = os.uname()[4] if (is_linux_arm and not is_linux_arm64) or not is64bit:
if machine and machine.lower().startswith('arm') or machine.lower().startswith('aarch'):
raise SystemExit( raise SystemExit(
'You are running on an ARM system. The calibre binaries are only' 'You are running on a 32-bit system. The calibre binaries are only'
' available for x86 systems. You will have to compile from' ' available for 64-bit systems. You will have to compile from'
' source.') ' source.')
check_glibc_version() check_glibc_version()
run_installer(install_dir, isolated, bin_dir, share_dir, version) run_installer(install_dir, isolated, bin_dir, share_dir, version)

View File

@ -74,6 +74,14 @@ if enc.lower() == 'ascii':
enc = 'utf-8' enc = 'utf-8'
dl_url = calibre_version = signature = None dl_url = calibre_version = signature = None
has_ssl_verify = hasattr(ssl, 'create_default_context') has_ssl_verify = hasattr(ssl, 'create_default_context')
is_linux_arm = is_linux_arm64 = False
machine = (os.uname()[4] or '').lower()
arch = 'x86_64'
if machine.startswith('arm') or machine.startswith('aarch64'):
is_linux_arm = True
is_linux_arm64 = machine.startswith('arm64') or machine.startswith('aarch64')
arch = 'arm64'
if py3: if py3:
unicode = str unicode = str
@ -369,9 +377,7 @@ def do_download(dest):
def download_tarball(): def download_tarball():
fname = 'calibre-%s-i686.%s'%(calibre_version, 'txz') fname = 'calibre-%s-%s.%s'%(calibre_version, arch, 'txz')
if is64bit:
fname = fname.replace('i686', 'x86_64')
tdir = tempfile.gettempdir() tdir = tempfile.gettempdir()
cache = os.path.join(tdir, 'calibre-installer-cache') cache = os.path.join(tdir, 'calibre-installer-cache')
if not os.path.exists(cache): if not os.path.exists(cache):
@ -697,14 +703,14 @@ def get_tarball_info(version):
print('Downloading tarball signature securely...') print('Downloading tarball signature securely...')
if version: if version:
signature = get_https_resource_securely( signature = get_https_resource_securely(
'https://code.calibre-ebook.com/signatures/calibre-' + version + '-' + ('x86_64' if is64bit else 'i686') + '.txz.sha512') 'https://code.calibre-ebook.com/signatures/calibre-' + version + '-' + arch + '.txz.sha512')
calibre_version = version calibre_version = version
dl_url = 'https://download.calibre-ebook.com/' + version + '/calibre-' + version + '-' + ('x86_64' if is64bit else 'i686') + '.txz' dl_url = 'https://download.calibre-ebook.com/' + version + '/calibre-' + version + '-' + arch + '.txz'
else: else:
raw = get_https_resource_securely( raw = get_https_resource_securely(
'https://code.calibre-ebook.com/tarball-info/' + ('x86_64' if is64bit else 'i686')) 'https://code.calibre-ebook.com/tarball-info/' + arch)
signature, calibre_version = raw.rpartition(b'@')[::2] signature, calibre_version = raw.rpartition(b'@')[::2]
dl_url = 'https://calibre-ebook.com/dist/linux'+('64' if is64bit else '32') dl_url = 'https://calibre-ebook.com/dist/linux-' + arch
if not signature or not calibre_version: if not signature or not calibre_version:
raise ValueError('Failed to get install file signature, invalid signature returned') raise ValueError('Failed to get install file signature, invalid signature returned')
dl_url = os.environ.get('CALIBRE_INSTALLER_LOCAL_URL', dl_url) dl_url = os.environ.get('CALIBRE_INSTALLER_LOCAL_URL', dl_url)
@ -812,11 +818,10 @@ def check_glibc_version(min_required=(2, 31), release_date='2020-02-01'):
def main(install_dir=None, isolated=False, bin_dir=None, share_dir=None, ignore_umask=False, version=None): def main(install_dir=None, isolated=False, bin_dir=None, share_dir=None, ignore_umask=False, version=None):
if not ignore_umask and not isolated: if not ignore_umask and not isolated:
check_umask() check_umask()
machine = os.uname()[4] if (is_linux_arm and not is_linux_arm64) or not is64bit:
if machine and machine.lower().startswith('arm') or machine.lower().startswith('aarch'):
raise SystemExit( raise SystemExit(
'You are running on an ARM system. The calibre binaries are only' 'You are running on a 32-bit system. The calibre binaries are only'
' available for x86 systems. You will have to compile from' ' available for 64-bit systems. You will have to compile from'
' source.') ' source.')
check_glibc_version() check_glibc_version()
run_installer(install_dir, isolated, bin_dir, share_dir, version) run_installer(install_dir, isolated, bin_dir, share_dir, version)

View File

@ -16,7 +16,7 @@ if __name__ == '__main__':
d = os.path.dirname d = os.path.dirname
sys.path.insert(0, d(d(os.path.abspath(__file__)))) sys.path.insert(0, d(d(os.path.abspath(__file__))))
from setup import Command, __version__, installer_name, __appname__ from setup import Command, __version__, __appname__, installer_names
DOWNLOADS = '/srv/main/downloads' DOWNLOADS = '/srv/main/downloads'
HTML2LRF = "calibre/ebooks/lrf/html/demo" HTML2LRF = "calibre/ebooks/lrf/html/demo"
@ -28,26 +28,13 @@ STAGING_DIR = '/root/staging'
BACKUP_DIR = '/binaries' BACKUP_DIR = '/binaries'
def installers(include_source=True):
installers = list(map(installer_name, ('dmg', 'msi', 'txz')))
installers.append(installer_name('txz', is64bit=True))
installers.append(installer_name('msi', is64bit=True))
if include_source:
installers.insert(0, f'dist/{__appname__}-{__version__}.tar.xz')
installers.append(
f'dist/{__appname__}-portable-installer-{__version__}.exe'
)
return installers
def installer_description(fname): def installer_description(fname):
if fname.endswith('.tar.xz'): if fname.endswith('.tar.xz'):
return 'Source code' return 'Source code'
if fname.endswith('.txz'): if fname.endswith('.txz'):
bits = '32' if 'i686' in fname else '64' return ('ARM' if 'arm64' in fname else 'AMD') + ' 64-bit Linux binary'
return bits + 'bit Linux binary'
if fname.endswith('.msi'): if fname.endswith('.msi'):
return 'Windows %sinstaller' % ('64bit ' if '64bit' in fname else '') return 'Windows installer'
if fname.endswith('.dmg'): if fname.endswith('.dmg'):
return 'OS X dmg' return 'OS X dmg'
if fname.endswith('.exe'): if fname.endswith('.exe'):
@ -59,7 +46,7 @@ def upload_signatures():
tdir = mkdtemp() tdir = mkdtemp()
scp = ['scp'] scp = ['scp']
try: try:
for installer in installers(): for installer in installer_names():
if not os.path.exists(installer): if not os.path.exists(installer):
continue continue
sig = os.path.join(tdir, os.path.basename(installer + '.sig')) sig = os.path.join(tdir, os.path.basename(installer + '.sig'))
@ -92,13 +79,13 @@ class ReUpload(Command): # {{{
def pre_sub_commands(self, opts): def pre_sub_commands(self, opts):
opts.replace = True opts.replace = True
exists = {x for x in installers() if os.path.exists(x)} exists = {x for x in installer_names() if os.path.exists(x)}
if not exists: if not exists:
print('There appear to be no installers!') print('There appear to be no installers!')
raise SystemExit(1) raise SystemExit(1)
def run(self, opts): def run(self, opts):
for x in installers(): for x in installer_names():
if os.path.exists(x): if os.path.exists(x):
os.remove(x) os.remove(x)
@ -199,7 +186,7 @@ def upload_to_fosshub():
else: else:
raise SystemExit('No calibre project found') raise SystemExit('No calibre project found')
files = set(installers()) files = set(installer_names())
entries = [] entries = []
for fname in files: for fname in files:
desc = installer_description(fname) desc = installer_description(fname)
@ -236,7 +223,7 @@ class UploadInstallers(Command): # {{{
def run(self, opts): def run(self, opts):
# return upload_to_fosshub() # return upload_to_fosshub()
all_possible = set(installers()) all_possible = set(installer_names())
available = set(glob.glob('dist/*')) available = set(glob.glob('dist/*'))
files = { files = {
x: installer_description(x) x: installer_description(x)

View File

@ -34,7 +34,7 @@ if iswindows:
wver = sys.getwindowsversion() wver = sys.getwindowsversion()
isxp = wver.major < 6 isxp = wver.major < 6
isoldvista = wver.build < 6002 isoldvista = wver.build < 6002
is64bit = sys.maxsize > (1 << 32) is64bit = True
isworker = hasenv('CALIBRE_WORKER') or hasenv('CALIBRE_SIMPLE_WORKER') isworker = hasenv('CALIBRE_WORKER') or hasenv('CALIBRE_SIMPLE_WORKER')
if isworker: if isworker:
os.environ.pop(environ_item('CALIBRE_FORCE_ANSI'), None) os.environ.pop(environ_item('CALIBRE_FORCE_ANSI'), None)
@ -412,8 +412,6 @@ def get_version():
v = v[:-2] v = v[:-2]
if is_running_from_develop: if is_running_from_develop:
v += '*' v += '*'
if iswindows and is64bit:
v += ' [64bit]'
return v return v

View File

@ -185,18 +185,12 @@ def print_basic_debug_info(out=None):
out = sys.stdout out = sys.stdout
out = functools.partial(prints, file=out) out = functools.partial(prints, file=out)
import platform import platform
from contextlib import suppress
from calibre.constants import (__appname__, get_version, isportable, ismacos, from calibre.constants import (__appname__, get_version, isportable, ismacos,
isfrozen, is64bit) isfrozen)
from calibre.utils.localization import set_translators from calibre.utils.localization import set_translators
out(__appname__, get_version(), 'Portable' if isportable else '', out(__appname__, get_version(), 'Portable' if isportable else '',
'embedded-python:', isfrozen, 'is64bit:', is64bit) 'embedded-python:', isfrozen)
out(platform.platform(), platform.system(), platform.architecture()) out(platform.platform(), platform.system(), platform.architecture())
if iswindows and not is64bit:
from calibre_extensions.winutil import is_wow64_process
with suppress(Exception):
if is_wow64_process():
out('32bit process running on 64bit windows')
out(platform.system_alias(platform.system(), platform.release(), out(platform.system_alias(platform.system(), platform.release(),
platform.version())) platform.version()))
out('Python', platform.python_version()) out('Python', platform.python_version())

View File

@ -2,7 +2,7 @@
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net> # License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
import os, string, re, sys, errno import os, string, re, errno
from collections import namedtuple, defaultdict from collections import namedtuple, defaultdict
from operator import itemgetter from operator import itemgetter
from ctypes import ( from ctypes import (
@ -16,8 +16,6 @@ from polyglot.builtins import iteritems, itervalues
from calibre import prints, as_unicode from calibre import prints, as_unicode
is64bit = sys.maxsize > (1 << 32)
try: try:
import winreg import winreg
except ImportError: except ImportError:
@ -622,7 +620,7 @@ def get_device_interface_detail_data(dev_list, p_interface_data, buf=None):
detail = cast(buf, PSP_DEVICE_INTERFACE_DETAIL_DATA) detail = cast(buf, PSP_DEVICE_INTERFACE_DETAIL_DATA)
# See http://stackoverflow.com/questions/10728644/properly-declare-sp-device-interface-detail-data-for-pinvoke # See http://stackoverflow.com/questions/10728644/properly-declare-sp-device-interface-detail-data-for-pinvoke
# for why cbSize needs to be hardcoded below # for why cbSize needs to be hardcoded below
detail.contents.cbSize = 8 if is64bit else 6 detail.contents.cbSize = 8
required_size = DWORD(0) required_size = DWORD(0)
devinfo = SP_DEVINFO_DATA() devinfo = SP_DEVINFO_DATA()
devinfo.cbSize = sizeof(devinfo) devinfo.cbSize = sizeof(devinfo)
@ -632,7 +630,7 @@ def get_device_interface_detail_data(dev_list, p_interface_data, buf=None):
if err == ERROR_INSUFFICIENT_BUFFER: if err == ERROR_INSUFFICIENT_BUFFER:
buf = create_string_buffer(required_size.value + 50) buf = create_string_buffer(required_size.value + 50)
detail = cast(buf, PSP_DEVICE_INTERFACE_DETAIL_DATA) detail = cast(buf, PSP_DEVICE_INTERFACE_DETAIL_DATA)
detail.contents.cbSize = 8 if is64bit else 6 detail.contents.cbSize = 8
continue continue
raise WinError(err) raise WinError(err)
break break

View File

@ -8,7 +8,7 @@ from qt.core import (QObject, pyqtSignal, Qt, QUrl, QDialog, QGridLayout,
QLabel, QCheckBox, QDialogButtonBox, QIcon) QLabel, QCheckBox, QDialogButtonBox, QIcon)
from calibre.constants import (__appname__, __version__, iswindows, ismacos, from calibre.constants import (__appname__, __version__, iswindows, ismacos,
isportable, is64bit, numeric_version) isportable, numeric_version)
from calibre import prints, as_unicode from calibre import prints, as_unicode
from calibre.utils.config import prefs from calibre.utils.config import prefs
from calibre.utils.localization import localize_website_link from calibre.utils.localization import localize_website_link
@ -26,8 +26,6 @@ NO_CALIBRE_UPDATE = (0, 0, 0)
def get_download_url(): def get_download_url():
which = ('portable' if isportable else 'windows' if iswindows which = ('portable' if isportable else 'windows' if iswindows
else 'osx' if ismacos else 'linux') else 'osx' if ismacos else 'linux')
if which == 'windows' and is64bit:
which += '64'
return localize_website_link('https://calibre-ebook.com/download_' + which) return localize_website_link('https://calibre-ebook.com/download_' + which)

View File

@ -13,7 +13,6 @@ from contextlib import suppress
from polyglot.builtins import string_or_bytes from polyglot.builtins import string_or_bytes
is64bit = sys.maxsize > (1 << 32)
base = sys.extensions_location if hasattr(sys, 'new_app_layout') else os.path.dirname(sys.executable) base = sys.extensions_location if hasattr(sys, 'new_app_layout') else os.path.dirname(sys.executable)
HELPER = os.path.join(base, 'calibre-file-dialog.exe') HELPER = os.path.join(base, 'calibre-file-dialog.exe')
current_app_uid = None current_app_uid = None
@ -46,7 +45,7 @@ def get_hwnd(widget=None):
def serialize_hwnd(hwnd): def serialize_hwnd(hwnd):
if hwnd is None: if hwnd is None:
return b'' return b''
return struct.pack('=B4s' + ('Q' if is64bit else 'I'), 4, b'HWND', int(hwnd)) return struct.pack('=B4sQ', 4, b'HWND', int(hwnd))
def serialize_secret(secret): def serialize_secret(secret):

View File

@ -8,8 +8,6 @@ from ctypes import wintypes
from collections import namedtuple from collections import namedtuple
from contextlib import contextmanager from contextlib import contextmanager
from calibre.constants import is64bit
# Wraps (part of) the IPHelper API, useful to enumerate the network routes and # Wraps (part of) the IPHelper API, useful to enumerate the network routes and
# adapters on the local machine # adapters on the local machine
@ -255,7 +253,7 @@ GetProcessHeap.argtypes = []
GetProcessHeap.restype = wintypes.HANDLE GetProcessHeap.restype = wintypes.HANDLE
HeapAlloc = windll.kernel32.HeapAlloc HeapAlloc = windll.kernel32.HeapAlloc
HeapAlloc.argtypes = [wintypes.HANDLE, wintypes.DWORD, ctypes.c_uint64 if is64bit else ctypes.c_uint32] HeapAlloc.argtypes = [wintypes.HANDLE, wintypes.DWORD, ctypes.c_uint64]
HeapAlloc.restype = wintypes.LPVOID HeapAlloc.restype = wintypes.LPVOID
HeapFree = windll.kernel32.HeapFree HeapFree = windll.kernel32.HeapFree

View File

@ -9,7 +9,7 @@ from threading import Thread
from calibre import guess_type, prints from calibre import guess_type, prints
from calibre.constants import is64bit, isportable, isfrozen, __version__, DEBUG from calibre.constants import isportable, isfrozen, __version__, DEBUG
from calibre.utils.winreg.lib import Key, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE from calibre.utils.winreg.lib import Key, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE
from calibre.utils.lock import singleinstance from calibre.utils.lock import singleinstance
from polyglot.builtins import iteritems, itervalues from polyglot.builtins import iteritems, itervalues
@ -23,25 +23,25 @@ def default_programs():
'calibre.exe': { 'calibre.exe': {
'icon_id':'main_icon', 'icon_id':'main_icon',
'description': _('The main calibre program, used to manage your collection of e-books'), 'description': _('The main calibre program, used to manage your collection of e-books'),
'capability_name': 'calibre' + ('64bit' if is64bit else ''), 'capability_name': 'calibre64bit',
'name': 'calibre' + (' 64-bit' if is64bit else ''), 'name': 'calibre 64-bit',
'assoc_name': 'calibre' + ('64bit' if is64bit else ''), 'assoc_name': 'calibre64bit',
}, },
'ebook-edit.exe': { 'ebook-edit.exe': {
'icon_id':'editor_icon', 'icon_id':'editor_icon',
'description': _('The calibre E-book editor. It can be used to edit common e-book formats.'), 'description': _('The calibre E-book editor. It can be used to edit common e-book formats.'),
'capability_name': 'Editor' + ('64bit' if is64bit else ''), 'capability_name': 'Editor64bit',
'name': 'calibre Editor' + (' 64-bit' if is64bit else ''), 'name': 'calibre Editor 64-bit',
'assoc_name': 'calibreEditor' + ('64bit' if is64bit else ''), 'assoc_name': 'calibreEditor64bit',
}, },
'ebook-viewer.exe': { 'ebook-viewer.exe': {
'icon_id':'viewer_icon', 'icon_id':'viewer_icon',
'description': _('The calibre E-book viewer. It can view most known e-book formats.'), 'description': _('The calibre E-book viewer. It can view most known e-book formats.'),
'capability_name': 'Viewer' + ('64bit' if is64bit else ''), 'capability_name': 'Viewer64bit',
'name': 'calibre Viewer' + (' 64-bit' if is64bit else ''), 'name': 'calibre Viewer 64-bit',
'assoc_name': 'calibreViewer' + ('64bit' if is64bit else ''), 'assoc_name': 'calibreViewer64bit',
}, },
} }