summaryrefslogtreecommitdiffstats
path: root/packaging
diff options
context:
space:
mode:
authorCalum Lind <calumlind@gmail.com>2018-10-02 15:39:51 +0100
committerCalum Lind <calumlind@gmail.com>2018-10-03 15:21:53 +0100
commitb1cdc32f7357e9777eb6cc2d90094c7d122af2eb (patch)
tree9106ac399a7df178c8dbed6fe58009d36b18159a /packaging
parentbcca07443ccad7f130444baaac52b7b49478905e (diff)
downloaddeluge-b1cdc32f7357e9777eb6cc2d90094c7d122af2eb.tar.gz
deluge-b1cdc32f7357e9777eb6cc2d90094c7d122af2eb.tar.bz2
deluge-b1cdc32f7357e9777eb6cc2d90094c7d122af2eb.zip
[Lint] Use Black to auto-format code
The move to using auto-formatter makes it easier to read, submit and speeds up development time. https://github.com/ambv/black/ Although I would prefer 79 chars, the default line length of 88 chars used by black suffices. The flake8 line length remains at 120 chars since black does not touch comments or docstrings and this will require another round of fixes. The only black setting that is not standard is the use of double-quotes for strings so disabled any formatting of these. Note however that flake8 will still flag usage of double-quotes. I may change my mind on double vs single quotes but for now leave them. A new pyproject.toml file has been created for black configuration.
Diffstat (limited to 'packaging')
-rwxr-xr-xpackaging/source/make_release.py15
-rw-r--r--packaging/win32/deluge-bbfreeze.py89
2 files changed, 79 insertions, 25 deletions
diff --git a/packaging/source/make_release.py b/packaging/source/make_release.py
index 62806f04e..542897ed0 100755
--- a/packaging/source/make_release.py
+++ b/packaging/source/make_release.py
@@ -31,7 +31,11 @@ version = check_output(['python', 'version.py']).strip()
# Create release archive
release_dir = 'dist/release-%s' % version
print('Creating release archive for ' + version)
-call('python setup.py --quiet egg_info --egg-base /tmp sdist --formats=tar --dist-dir=%s' % release_dir, shell=True)
+call(
+ 'python setup.py --quiet egg_info --egg-base /tmp sdist --formats=tar --dist-dir=%s'
+ % release_dir,
+ shell=True,
+)
# Compress release archive with xz
tar_path = os.path.join(release_dir, 'deluge-%s.tar' % version)
@@ -39,13 +43,18 @@ tarxz_path = tar_path + '.xz'
print('Compressing tar (%s) with xz' % tar_path)
if lzma:
with open(tar_path, 'rb') as tar_file, open(tarxz_path, 'wb') as xz_file:
- xz_file.write(lzma.compress(bytes(tar_file.read()), preset=9 | lzma.PRESET_EXTREME))
+ xz_file.write(
+ lzma.compress(bytes(tar_file.read()), preset=9 | lzma.PRESET_EXTREME)
+ )
else:
call(['xz', '-e9zkf', tar_path])
# Calculate shasum and add to sha256sums.txt
with open(tarxz_path, 'rb') as _file:
- sha256sum = '%s %s' % (sha256(_file.read()).hexdigest(), os.path.basename(tarxz_path))
+ sha256sum = '%s %s' % (
+ sha256(_file.read()).hexdigest(),
+ os.path.basename(tarxz_path),
+ )
with open(os.path.join(release_dir, 'sha256sums.txt'), 'w') as _file:
_file.write(sha256sum + '\n')
diff --git a/packaging/win32/deluge-bbfreeze.py b/packaging/win32/deluge-bbfreeze.py
index 54aefb49f..400bf640f 100644
--- a/packaging/win32/deluge-bbfreeze.py
+++ b/packaging/win32/deluge-bbfreeze.py
@@ -27,10 +27,21 @@ import deluge.common
class VersionInfo(object):
- def __init__(self, version, internalname=None, originalfilename=None,
- comments=None, company=None, description=None,
- _copyright=None, trademarks=None, product=None, dll=False,
- debug=False, verbose=True):
+ def __init__(
+ self,
+ version,
+ internalname=None,
+ originalfilename=None,
+ comments=None,
+ company=None,
+ description=None,
+ _copyright=None,
+ trademarks=None,
+ product=None,
+ dll=False,
+ debug=False,
+ verbose=True,
+ ):
parts = version.split('.')
while len(parts) < 4:
parts.append('0')
@@ -71,8 +82,19 @@ if not DEBUG:
sys.stdout = open(os.devnull, 'w')
# Include python modules not picked up automatically by bbfreeze.
-includes = ('libtorrent', 'cairo', 'pangocairo', 'atk', 'pango', 'twisted.internet.utils',
- 'gio', 'gzip', 'email.mime.multipart', 'email.mime.text', '_cffi_backend')
+includes = (
+ 'libtorrent',
+ 'cairo',
+ 'pangocairo',
+ 'atk',
+ 'pango',
+ 'twisted.internet.utils',
+ 'gio',
+ 'gzip',
+ 'email.mime.multipart',
+ 'email.mime.text',
+ '_cffi_backend',
+)
excludes = ('numpy', 'OpenGL', 'psyco', 'win32ui', 'unittest')
@@ -86,11 +108,17 @@ bbfreeze.recipes.recipe_gtk_and_friends = recipe_gtk_override
# Workaround for "ImportError: The 'packaging' package is required" with setuptools > 18.8.
# (https://github.com/pypa/setuptools/issues/517)
-bbfreeze.recipes.recipe_pkg_resources = bbfreeze.recipes.include_whole_package('pkg_resources')
+bbfreeze.recipes.recipe_pkg_resources = bbfreeze.recipes.include_whole_package(
+ 'pkg_resources'
+)
fzr = bbfreeze.Freezer(build_dir, includes=includes, excludes=excludes)
fzr.include_py = False
-fzr.setIcon(os.path.join(os.path.dirname(deluge.common.__file__), 'ui', 'data', 'pixmaps', 'deluge.ico'))
+fzr.setIcon(
+ os.path.join(
+ os.path.dirname(deluge.common.__file__), 'ui', 'data', 'pixmaps', 'deluge.ico'
+ )
+)
# TODO: Can/should we grab the script list from setup.py entry_points somehow.
@@ -125,10 +153,22 @@ for script in script_list:
os.remove(script)
# Exclude files which are already included in GTK or Windows. Also exclude unneeded pygame dlls.
-excludeDlls = ('MSIMG32.dll', 'MSVCR90.dll', 'MSVCP90.dll', 'MSVCR120.dll',
- 'POWRPROF.dll', 'DNSAPI.dll', 'USP10.dll', 'MPR.dll',
- 'jpeg.dll', 'libfreetype-6.dll', 'libpng12-0.dll', 'libtiff.dll',
- 'SDL_image.dll', 'SDL_ttf.dll')
+excludeDlls = (
+ 'MSIMG32.dll',
+ 'MSVCR90.dll',
+ 'MSVCP90.dll',
+ 'MSVCR120.dll',
+ 'POWRPROF.dll',
+ 'DNSAPI.dll',
+ 'USP10.dll',
+ 'MPR.dll',
+ 'jpeg.dll',
+ 'libfreetype-6.dll',
+ 'libpng12-0.dll',
+ 'libtiff.dll',
+ 'SDL_image.dll',
+ 'SDL_ttf.dll',
+)
for exclude_dll in excludeDlls:
try:
os.remove(os.path.join(build_dir, exclude_dll))
@@ -146,13 +186,16 @@ locale_include_list = ['gtk20.mo', 'locale.alias']
def ignored_files(adir, ignore_filenames):
return [
- ignore_file for ignore_file in ignore_filenames
- if not os.path.isdir(os.path.join(adir, ignore_file)) and
- ignore_file not in locale_include_list
+ ignore_file
+ for ignore_file in ignore_filenames
+ if not os.path.isdir(os.path.join(adir, ignore_file))
+ and ignore_file not in locale_include_list
]
-shutil.copytree(gtk_locale, os.path.join(build_dir, 'share/locale'), ignore=ignored_files)
+shutil.copytree(
+ gtk_locale, os.path.join(build_dir, 'share/locale'), ignore=ignored_files
+)
# Copy gtk theme files.
theme_include_list = [
@@ -180,11 +223,13 @@ for script in script_list:
script_exe = os.path.splitext(os.path.basename(script))[0] + '.exe'
# Don't add to dev build versions.
if not re.search('[a-zA-Z_-]', build_version):
- versionInfo = VersionInfo(build_version,
- description='Deluge Bittorrent Client',
- company='Deluge Team',
- product='Deluge',
- _copyright='Deluge Team')
+ versionInfo = VersionInfo(
+ build_version,
+ description='Deluge Bittorrent Client',
+ company='Deluge Team',
+ product='Deluge',
+ _copyright='Deluge Team',
+ )
stamp(os.path.join(build_dir, script_exe), versionInfo)
# Copy version info to file for nsis script.
@@ -196,7 +241,7 @@ filedir_list = []
for root, dirnames, filenames in os.walk(build_dir):
dirnames.sort()
filenames.sort()
- filedir_list.append((root[len(build_dir):], filenames))
+ filedir_list.append((root[len(build_dir) :], filenames))
with open('install_files.nsh', 'w') as f:
f.write('; Files to install\n')