mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-21 10:01:54 +00:00
Fix PyInstaller builds
This commit contains a few small changes to fix PyInstaller frozen builds (which were recently broken in a few ways by changes introduced with `tahoe invite`, `tahoe daemonize`, and the addition of "setuptools >= 28.8.0" to setup_requires) and removes a couple of hacks that are no longer necessary to create working frozen tahoe executables with PyInstaller.
This commit is contained in:
parent
d395a11208
commit
c850638537
@ -15,17 +15,6 @@ if not hasattr(sys, 'real_prefix'):
|
|||||||
sys.exit("Please run inside a virtualenv with Tahoe-LAFS installed.")
|
sys.exit("Please run inside a virtualenv with Tahoe-LAFS installed.")
|
||||||
|
|
||||||
|
|
||||||
# Ugly hack to disable the setuptools requirement asserted in '_auto_deps.py'.
|
|
||||||
# Without patching out this requirement, frozen binaries will fail at runtime.
|
|
||||||
autodeps_path = os.path.join(get_python_lib(), 'allmydata', '_auto_deps.py')
|
|
||||||
print("Patching '{}' to remove setuptools check...".format(autodeps_path))
|
|
||||||
autodeps_path_backup = autodeps_path + '.backup'
|
|
||||||
shutil.copy2(autodeps_path, autodeps_path_backup)
|
|
||||||
with open(autodeps_path_backup) as src, open(autodeps_path, 'w+') as dest:
|
|
||||||
dest.write(src.read().replace('"setuptools >=', '#"setuptools >='))
|
|
||||||
print("Done!")
|
|
||||||
|
|
||||||
|
|
||||||
options = [('u', None, 'OPTION')] # Unbuffered stdio
|
options = [('u', None, 'OPTION')] # Unbuffered stdio
|
||||||
|
|
||||||
added_files = [
|
added_files = [
|
||||||
@ -37,12 +26,25 @@ added_files = [
|
|||||||
('src/allmydata/web/static/css/*', 'allmydata/web/static/css'),
|
('src/allmydata/web/static/css/*', 'allmydata/web/static/css'),
|
||||||
('src/allmydata/web/static/img/*.png', 'allmydata/web/static/img')]
|
('src/allmydata/web/static/img/*.png', 'allmydata/web/static/img')]
|
||||||
|
|
||||||
|
hidden_imports = [
|
||||||
|
'allmydata.client',
|
||||||
|
'allmydata.introducer',
|
||||||
|
'allmydata.stats',
|
||||||
|
'cffi',
|
||||||
|
'characteristic',
|
||||||
|
'Crypto',
|
||||||
|
'packaging.specifiers',
|
||||||
|
'six.moves.html_parser',
|
||||||
|
'yaml',
|
||||||
|
'zfec'
|
||||||
|
]
|
||||||
|
|
||||||
a = Analysis(
|
a = Analysis(
|
||||||
['static/tahoe.py'],
|
['static/tahoe.py'],
|
||||||
pathex=[],
|
pathex=[],
|
||||||
binaries=None,
|
binaries=None,
|
||||||
datas=added_files,
|
datas=added_files,
|
||||||
hiddenimports=['characteristic', 'cffi'],
|
hiddenimports=hidden_imports,
|
||||||
hookspath=[],
|
hookspath=[],
|
||||||
runtime_hooks=[],
|
runtime_hooks=[],
|
||||||
excludes=[],
|
excludes=[],
|
||||||
@ -76,10 +78,6 @@ coll = COLLECT(
|
|||||||
name='Tahoe-LAFS')
|
name='Tahoe-LAFS')
|
||||||
|
|
||||||
|
|
||||||
# Revert the '_auto_deps.py' patch above
|
|
||||||
shutil.move(autodeps_path_backup, autodeps_path)
|
|
||||||
|
|
||||||
|
|
||||||
print("Creating archive...")
|
print("Creating archive...")
|
||||||
platform_tag = platform.system().replace('Darwin', 'MacOS')
|
platform_tag = platform.system().replace('Darwin', 'MacOS')
|
||||||
bitness_tag = str(struct.calcsize('P') * 8) + 'bit'
|
bitness_tag = str(struct.calcsize('P') * 8) + 'bit'
|
||||||
|
@ -123,6 +123,8 @@ package_imports = [
|
|||||||
('enum34', 'enum'),
|
('enum34', 'enum'),
|
||||||
('pycparser', 'pycparser'),
|
('pycparser', 'pycparser'),
|
||||||
('PyYAML', 'yaml'),
|
('PyYAML', 'yaml'),
|
||||||
|
('magic-wormhole', 'wormhole'),
|
||||||
|
('setuptools', 'setuptools')
|
||||||
]
|
]
|
||||||
|
|
||||||
# Dependencies for which we don't know how to get a version number at run-time.
|
# Dependencies for which we don't know how to get a version number at run-time.
|
||||||
@ -141,14 +143,6 @@ ignorable = [
|
|||||||
'twisted-conch',
|
'twisted-conch',
|
||||||
]
|
]
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
# Don't try to get the version number of setuptools in frozen builds, because
|
|
||||||
# that triggers 'site' processing that causes failures. Note that frozen
|
|
||||||
# builds still (unfortunately) import pkg_resources in .tac files, so the
|
|
||||||
# entry for setuptools in install_requires above isn't conditional.
|
|
||||||
if not hasattr(sys, 'frozen'):
|
|
||||||
package_imports.append(('setuptools', 'setuptools'))
|
|
||||||
|
|
||||||
setup_requires = [
|
setup_requires = [
|
||||||
'setuptools >= 28.8.0', # for PEP-440 style versions
|
'setuptools >= 28.8.0', # for PEP-440 style versions
|
||||||
|
@ -104,7 +104,7 @@ def start(config):
|
|||||||
# "pretty fast" and with a zero return-code, or else something
|
# "pretty fast" and with a zero return-code, or else something
|
||||||
# Very Bad has happened.
|
# Very Bad has happened.
|
||||||
try:
|
try:
|
||||||
args = [sys.executable]
|
args = [sys.executable] if not getattr(sys, 'frozen', False) else []
|
||||||
for i, arg in enumerate(sys.argv):
|
for i, arg in enumerate(sys.argv):
|
||||||
if arg in ['start', 'restart']:
|
if arg in ['start', 'restart']:
|
||||||
args.append('daemonize')
|
args.append('daemonize')
|
||||||
|
6
tox.ini
6
tox.ini
@ -102,14 +102,10 @@ commands =
|
|||||||
sphinx-build -b html -d {toxinidir}/docs/_build/doctrees {toxinidir}/docs {toxinidir}/docs/_build/html
|
sphinx-build -b html -d {toxinidir}/docs/_build/doctrees {toxinidir}/docs {toxinidir}/docs/_build/html
|
||||||
|
|
||||||
[testenv:pyinstaller]
|
[testenv:pyinstaller]
|
||||||
# Do not use the '--editable' flag for this testenv as the 'pyinstaller.spec'
|
|
||||||
# script called below will need patch the source tree at build-time in order
|
|
||||||
# to remove the setuptools requirement from '_auto_deps.py' (and we want to
|
|
||||||
# avoid race-conditions when running tests in parallel, e.g., with "detox").
|
|
||||||
usedevelop = False
|
|
||||||
extras =
|
extras =
|
||||||
deps =
|
deps =
|
||||||
.
|
.
|
||||||
|
packaging
|
||||||
pyinstaller
|
pyinstaller
|
||||||
# Setting PYTHONHASHSEED to a known value assists with reproducible builds.
|
# Setting PYTHONHASHSEED to a known value assists with reproducible builds.
|
||||||
# See https://pyinstaller.readthedocs.io/en/stable/advanced-topics.html#creating-a-reproducible-build
|
# See https://pyinstaller.readthedocs.io/en/stable/advanced-topics.html#creating-a-reproducible-build
|
||||||
|
Loading…
x
Reference in New Issue
Block a user