Skip to content

Commit

Permalink
Adding pyinstaller and scripts to generate release
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusd committed Aug 1, 2017
1 parent 2999dde commit 0036e46
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ _data/
__pycache__
*.egg-info
bin
dist
dist
build
releases
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ The restore operation works in reverse: reads the QR codes from a single or a se
- Backing up seed files from crypto wallets


## Installation

Download and extract one of the releases or download the python source code and execute.


## Basic Usage

Using `--sha256` prints the hash of the input (on backup) or output (on restore) file.
Expand Down
3 changes: 3 additions & 0 deletions pyinstaller-hooks/hook-zbarlight.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from PyInstaller.utils.hooks import copy_metadata, collect_data_files

datas = copy_metadata('zbarlight')
33 changes: 33 additions & 0 deletions pypaperbak.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- mode: python -*-

block_cipher = None


a = Analysis(['pypaperbak/__main__.py'],
pathex=['/home/user/projetos/pypaperbak'],
binaries=[],
datas=[('README.md', '.'), ('LICENSE.md', '.'), ('samples', 'samples')],
hiddenimports=['png'],
hookspath=['pyinstaller-hooks'],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='pypaperbak',
debug=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='pypaperbak')
6 changes: 3 additions & 3 deletions pypaperbak/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def run_backup(self, args):
infile_size = os.path.getsize(infile.name)

outfile = args.outfile
inputhash = hashlib.sha256() if args.sha256 else None
inputhash = hashlib.sha256()
framedata = self.frame_data_func(args)

qr_count = infile_size / chunksize + 1
Expand All @@ -124,7 +124,7 @@ def run_backup(self, args):
bindata = infile.read(chunksize)
if not bindata: break
frame = framedata(bindata, qr_count, sizesofar)
if inputhash is not None: inputhash.update(bindata)
inputhash.update(bindata)
sizesofar += len(bindata)

qr_number += 1
Expand All @@ -136,7 +136,7 @@ def run_backup(self, args):

exporter.finish(inputhash)
self.logger.info('Finished exporting')
if inputhash is not None:
if args.sha256:
print('SHA-256 of input: %s' % inputhash.hexdigest())

def run_restore(self, args):
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
'pyqrcode',
'zbarlight',
'fpdf',
'python-magic'
'python-magic',
'pypng'
],
classifiers = [
"Development Status :: 5 - Production/Stable",
Expand Down
14 changes: 14 additions & 0 deletions util/gen-release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/env python

import os
import shutil

exec(open('pypaperbak/_version.py').read())

shutil.rmtree('build', True)
shutil.rmtree('dist', True)
os.makedirs('releases', exist_ok=True)


os.system('pyinstaller pypaperbak.spec')
os.system('tar -C dist -cjf releases/pypaperbak-%s-linux-x64.tar.bz2 pypaperbak' % __version__)

0 comments on commit 0036e46

Please sign in to comment.