deluge/packaging/win/delugewin.spec
tbkizle 540d557cb2
[Common] Add is_interface to validate network interfaces
Libtorrent now supports interface names instead of just IP address so
add new common functions to validate user input.

* Added is_interface that will verify if a libtorrent interface of name
or IP address.
* Added is_interface_name to verify that the name supplied is a valid
network interface name in the operating system.
  On Windows sock.if_nameindex() is only supported on 3.8+ and does not
return a uuid (required by libtorrent) so use ifaddr package. Using git
commit version for ifaddr due to adapter name decode bug in v0.1.7.
On other OSes attempt to use stdlib and fallback to ifaddr if installed
otherwiser return True.
* Added tests for is_interface & is_interface_name
* Updated UIs with change from address to interface
* Updated is_ipv6 and is_ipv4 to used inet_pton; now supported on
Windows.

Ref: https://github.com/pydron/ifaddr/pull/32
Closes: https://github.com/deluge-torrent/deluge/pull/338
2022-01-30 16:13:27 +00:00

201 lines
4.4 KiB
Python

# -*- mode: python ; coding: utf-8 -*-
import os
import sys
import deluge.common
from PyInstaller.utils.hooks import collect_all, collect_submodules, copy_metadata
datas = []
binaries = []
hiddenimports = ['pygame','ifaddr']
# Collect Meta Data
datas += copy_metadata('deluge', recursive=True)
datas += copy_metadata('service-identity', recursive=True)
# Add Deluge Hidden Imports
hiddenimports += collect_submodules('deluge')
# Add stdlib as Hidden Imports.
# This is filtered list that excludes some common examples or stuff not useful in plugins (such as tty, mailbox, turtledemo etc.).
# It is safe to assume that 90% of that list would already be included anyway.
stdlib = [
'string',
're',
'unicodedata',
'struct',
'codecs',
'datetime',
'zoneinfo',
'calendar',
'collections',
'array',
'weakref',
'types',
'copy',
'enum',
'numbers',
'math',
'cmath',
'decimal',
'fractions',
'random',
'statistics',
'itertools',
'functools',
'operator',
'pathlib',
'fileinput',
'stat',
'tempfile',
'glob',
'fnmatch',
'shutil',
'pickle',
'copyreg',
'shelve',
'marshal',
'dom',
'sqlite3',
'zlib',
'gzip',
'bz2',
'lzma',
'csv',
'hashlib',
'hmac',
'secrets',
'os',
'io',
'time',
'logging',
'platform',
'errno',
'queue',
'socket',
'ssl',
'email',
'json',
'mimetypes',
'base64',
'binhex',
'binascii',
'quopri',
'uu',
'html',
'xml',
'urllib',
'http',
'ftplib',
'smtplib',
'uuid',
'xmlrpc.client',
'ipaddress',
'locale',
'sys',
]
for module in stdlib:
hiddenimports += collect_submodules(module, filter=lambda name: 'test' not in name)
# Add Hidden Imports for Plugins
hiddenimports += collect_submodules('twisted', filter=lambda name: 'test' not in name)
datas += copy_metadata('twisted', recursive=True)
# Copy UI/Plugin files to where pyinstaller expects
datas += [('../../deluge/ui', 'deluge/ui'), ('../../deluge/plugins', 'deluge/plugins')]
# List of executables to produce
executables = {
'deluge-script.pyw': {
'name': 'deluge',
'console': False,
'gtk': True,
},
'deluge-gtk-script.pyw': {
'name': 'deluge-gtk',
'console': False,
'gtk': True,
},
'deluge-debug-script.py': {
'name': 'deluge-debug',
'console': True,
'gtk': True,
},
'deluge-console-script.py': {
'name': 'deluge-console',
'console': True,
'gtk': False,
},
'deluged-script.py': {
'name': 'deluged',
'console': False,
'gtk': False,
},
'deluged-debug-script.py': {
'name': 'deluged-debug',
'console': True,
'gtk': False,
},
'deluge-web-debug-script.py': {
'name': 'deluge-web-debug',
'console': False,
'gtk': False,
},
'deluge-web-script.py': {
'name': 'deluge-web',
'console': True,
'gtk': False,
},
}
analysis = {}
exe = {}
coll = []
# Perform analysis
for e, d in executables.items():
runtime_hooks = []
if d['gtk']:
runtime_hooks += [os.path.join(SPECPATH, 'pyi_rth_gtk_csd.py')]
analysis[e] = Analysis(
[os.path.abspath(os.path.join(HOMEPATH, os.pardir, os.pardir, 'Scripts', e))],
pathex=[],
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=runtime_hooks,
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=None,
noarchive=False,
)
# Executable
for e, d in executables.items():
exe[e] = EXE(
PYZ(analysis[e].pure, analysis[e].zipped_data, cipher=None),
analysis[e].scripts,
[],
exclude_binaries=True,
name=d['name'],
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
icon='../../deluge/ui/data/pixmaps/deluge.ico',
console=d['console'],
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
# Collect
for e, d in executables.items():
coll += exe[e], analysis[e].binaries, analysis[e].zipfiles, analysis[e].datas
COLLECT(*coll, strip=False, upx=True, upx_exclude=[], name='Deluge')