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 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 (
extract_extension_modules, fix_pycryptodome, freeze_python, path_to_freeze_dir
@ -24,8 +24,10 @@ from bypy.utils import (
j = os.path.join
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()))
QT_PREFIX = os.path.join(PREFIX, 'qt')
iv = globals()['init_env']

View File

@ -16,7 +16,7 @@ import sys
import zipfile
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
)
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']
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
create_installer = runpy.run_path(
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):
printf('Copying CRT and D3D...')
plat = ('x64' if is64bit else 'x86')
plat = 'x64'
for key, val in worker_env.items():
if 'COMNTOOLS' in key.upper():
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)
if not os.path.exists(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):
raise SystemExit('Mesa DLLs (opengl32sw.dll) not found at: %r' % mesa_path)
@ -582,9 +582,8 @@ def main():
if args.sign_installers:
sign_executables(env)
create_installer(env)
if not is64bit:
build_portable(env)
build_portable_installer(env)
build_portable(env)
build_portable_installer(env)
if args.sign_installers:
sign_installers(env)

View File

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

View File

@ -182,7 +182,7 @@ is_macos_universal_build = ismacos and 'universal2' in sysconfig.get_platform()
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
if isunix:
cc = os.environ.get('CC', 'gcc')
@ -244,8 +244,7 @@ def init_env(debug=False, sanitize=False):
ldflags.append('/DEBUG')
# cflags = '/c /nologo /Ox /MD /W3 /EHsc /Zi'.split()
# ldflags = '/DLL /nologo /INCREMENTAL:NO /DEBUG'.split()
if is64bit:
cflags.append('/GS-')
cflags.append('/GS-')
for p in win_inc:
cflags.append('-I'+p)

View File

@ -25,6 +25,14 @@ if enc.lower() == 'ascii':
enc = 'utf-8'
dl_url = calibre_version = signature = None
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:
unicode = str
@ -320,9 +328,7 @@ def do_download(dest):
def download_tarball():
fname = 'calibre-%s-i686.%s'%(calibre_version, 'txz')
if is64bit:
fname = fname.replace('i686', 'x86_64')
fname = 'calibre-%s-%s.%s'%(calibre_version, arch, 'txz')
tdir = tempfile.gettempdir()
cache = os.path.join(tdir, 'calibre-installer-cache')
if not os.path.exists(cache):
@ -648,14 +654,14 @@ def get_tarball_info(version):
print('Downloading tarball signature securely...')
if version:
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
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:
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]
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:
raise ValueError('Failed to get install file signature, invalid signature returned')
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):
if not ignore_umask and not isolated:
check_umask()
machine = os.uname()[4]
if machine and machine.lower().startswith('arm') or machine.lower().startswith('aarch'):
if (is_linux_arm and not is_linux_arm64) or not is64bit:
raise SystemExit(
'You are running on an ARM system. The calibre binaries are only'
' available for x86 systems. You will have to compile from'
'You are running on a 32-bit system. The calibre binaries are only'
' available for 64-bit systems. You will have to compile from'
' source.')
check_glibc_version()
run_installer(install_dir, isolated, bin_dir, share_dir, version)

View File

@ -74,6 +74,14 @@ if enc.lower() == 'ascii':
enc = 'utf-8'
dl_url = calibre_version = signature = None
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:
unicode = str
@ -369,9 +377,7 @@ def do_download(dest):
def download_tarball():
fname = 'calibre-%s-i686.%s'%(calibre_version, 'txz')
if is64bit:
fname = fname.replace('i686', 'x86_64')
fname = 'calibre-%s-%s.%s'%(calibre_version, arch, 'txz')
tdir = tempfile.gettempdir()
cache = os.path.join(tdir, 'calibre-installer-cache')
if not os.path.exists(cache):
@ -697,14 +703,14 @@ def get_tarball_info(version):
print('Downloading tarball signature securely...')
if version:
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
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:
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]
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:
raise ValueError('Failed to get install file signature, invalid signature returned')
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):
if not ignore_umask and not isolated:
check_umask()
machine = os.uname()[4]
if machine and machine.lower().startswith('arm') or machine.lower().startswith('aarch'):
if (is_linux_arm and not is_linux_arm64) or not is64bit:
raise SystemExit(
'You are running on an ARM system. The calibre binaries are only'
' available for x86 systems. You will have to compile from'
'You are running on a 32-bit system. The calibre binaries are only'
' available for 64-bit systems. You will have to compile from'
' source.')
check_glibc_version()
run_installer(install_dir, isolated, bin_dir, share_dir, version)

View File

@ -16,7 +16,7 @@ if __name__ == '__main__':
d = os.path.dirname
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'
HTML2LRF = "calibre/ebooks/lrf/html/demo"
@ -28,26 +28,13 @@ STAGING_DIR = '/root/staging'
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):
if fname.endswith('.tar.xz'):
return 'Source code'
if fname.endswith('.txz'):
bits = '32' if 'i686' in fname else '64'
return bits + 'bit Linux binary'
return ('ARM' if 'arm64' in fname else 'AMD') + ' 64-bit Linux binary'
if fname.endswith('.msi'):
return 'Windows %sinstaller' % ('64bit ' if '64bit' in fname else '')
return 'Windows installer'
if fname.endswith('.dmg'):
return 'OS X dmg'
if fname.endswith('.exe'):
@ -59,7 +46,7 @@ def upload_signatures():
tdir = mkdtemp()
scp = ['scp']
try:
for installer in installers():
for installer in installer_names():
if not os.path.exists(installer):
continue
sig = os.path.join(tdir, os.path.basename(installer + '.sig'))
@ -92,13 +79,13 @@ class ReUpload(Command): # {{{
def pre_sub_commands(self, opts):
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:
print('There appear to be no installers!')
raise SystemExit(1)
def run(self, opts):
for x in installers():
for x in installer_names():
if os.path.exists(x):
os.remove(x)
@ -199,7 +186,7 @@ def upload_to_fosshub():
else:
raise SystemExit('No calibre project found')
files = set(installers())
files = set(installer_names())
entries = []
for fname in files:
desc = installer_description(fname)
@ -236,7 +223,7 @@ class UploadInstallers(Command): # {{{
def run(self, opts):
# return upload_to_fosshub()
all_possible = set(installers())
all_possible = set(installer_names())
available = set(glob.glob('dist/*'))
files = {
x: installer_description(x)

View File

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

View File

@ -185,18 +185,12 @@ def print_basic_debug_info(out=None):
out = sys.stdout
out = functools.partial(prints, file=out)
import platform
from contextlib import suppress
from calibre.constants import (__appname__, get_version, isportable, ismacos,
isfrozen, is64bit)
isfrozen)
from calibre.utils.localization import set_translators
out(__appname__, get_version(), 'Portable' if isportable else '',
'embedded-python:', isfrozen, 'is64bit:', is64bit)
'embedded-python:', isfrozen)
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(),
platform.version()))
out('Python', platform.python_version())

View File

@ -2,7 +2,7 @@
# 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 operator import itemgetter
from ctypes import (
@ -16,8 +16,6 @@ from polyglot.builtins import iteritems, itervalues
from calibre import prints, as_unicode
is64bit = sys.maxsize > (1 << 32)
try:
import winreg
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)
# See http://stackoverflow.com/questions/10728644/properly-declare-sp-device-interface-detail-data-for-pinvoke
# for why cbSize needs to be hardcoded below
detail.contents.cbSize = 8 if is64bit else 6
detail.contents.cbSize = 8
required_size = DWORD(0)
devinfo = SP_DEVINFO_DATA()
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:
buf = create_string_buffer(required_size.value + 50)
detail = cast(buf, PSP_DEVICE_INTERFACE_DETAIL_DATA)
detail.contents.cbSize = 8 if is64bit else 6
detail.contents.cbSize = 8
continue
raise WinError(err)
break

View File

@ -8,7 +8,7 @@ from qt.core import (QObject, pyqtSignal, Qt, QUrl, QDialog, QGridLayout,
QLabel, QCheckBox, QDialogButtonBox, QIcon)
from calibre.constants import (__appname__, __version__, iswindows, ismacos,
isportable, is64bit, numeric_version)
isportable, numeric_version)
from calibre import prints, as_unicode
from calibre.utils.config import prefs
from calibre.utils.localization import localize_website_link
@ -26,8 +26,6 @@ NO_CALIBRE_UPDATE = (0, 0, 0)
def get_download_url():
which = ('portable' if isportable else 'windows' if iswindows
else 'osx' if ismacos else 'linux')
if which == 'windows' and is64bit:
which += '64'
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
is64bit = sys.maxsize > (1 << 32)
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')
current_app_uid = None
@ -46,7 +45,7 @@ def get_hwnd(widget=None):
def serialize_hwnd(hwnd):
if hwnd is None:
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):

View File

@ -8,8 +8,6 @@ from ctypes import wintypes
from collections import namedtuple
from contextlib import contextmanager
from calibre.constants import is64bit
# Wraps (part of) the IPHelper API, useful to enumerate the network routes and
# adapters on the local machine
@ -255,7 +253,7 @@ GetProcessHeap.argtypes = []
GetProcessHeap.restype = wintypes.HANDLE
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
HeapFree = windll.kernel32.HeapFree

View File

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