diff --git a/.gitignore b/.gitignore index c571fcd35..9a9fe1a4d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,8 @@ app/dist app/node_modules node_modules LBRY-darwin-x64 -dist \ No newline at end of file +dist +lbrynet/build +lbrynet/venv +.#* +build_venv \ No newline at end of file diff --git a/app/main.js b/app/main.js index d4e9422d0..4948bb5de 100644 --- a/app/main.js +++ b/app/main.js @@ -1,6 +1,12 @@ -const {app, BrowserWindow} = require('electron') +const {app, BrowserWindow} = require('electron'); +var path = require('path'); + var jayson = require('jayson'); -var client = jayson.client.http('http://localhost:5279/lbryapi'); +// tree-kill has better cross-platform handling of +// killing a process. child-process.kill was unreliable +var kill = require('tree-kill'); + +let client = jayson.client.http('http://localhost:5279/lbryapi'); // Keep a global reference of the window object, if you don't, the window will @@ -35,8 +41,14 @@ function lauchDaemon() { if (subpy) { return; } - console.log(`${__dirname}/dist/lbry`); - subpy = require('child_process').spawn(`${__dirname}/dist/lbry`, ['--verbose'], {stdio: ['ignore', process.stdout, process.stderr]}) + console.log(`${__dirname}`); + executable = path.join(__dirname, 'dist', 'lbrynet-daemon'); + subpy = require('child_process').spawn(executable, ['--verbose'])//, {stdio: ['ignore', process.stdout, process.stderr]}); + // Need to handle the data event instead of attaching to + // process.stdout because the latter doesn't work. I believe on + // windows it buffers stdout and we don't get any meaningful output + subpy.stdout.on('data', (buf) => {console.log(String(buf).trim());}); + subpy.stderr.on('data', (buf) => {console.log(String(buf).trim());}); subpy.on('exit', () => { console.log('The daemon has exited. Quitting the app'); subpy = null; @@ -88,8 +100,11 @@ app.on('before-quit', (event) => { if (win) { win.loadURL(`file://${__dirname}/dist/quit.html`); } - quitting = true; - subpy.kill('SIGINT'); + quitting = true; + console.log('Killing lbrynet-daemon process'); + kill(subpy.pid, undefined, (err) => { + console.log('Killed lbrynet-daemon process'); + }); } }) diff --git a/app/package.json b/app/package.json index da5229ba2..d2e7e0dcf 100644 --- a/app/package.json +++ b/app/package.json @@ -8,6 +8,9 @@ "name": "Job Evers-Meltzer" }, "dependencies": { - "jayson": "^2.0.2" + "install": "^0.8.7", + "jayson": "^2.0.2", + "npm": "^4.2.0", + "tree-kill": "^1.1.0" } } diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..61f4bfdd6 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,42 @@ +# Test against the latest version of this Node.js version +environment: + nodejs_version: "6" + +clone_folder: C:\projects\lbry-electron + +# Install scripts. (runs after repo cloning) +install: + # needed to deal with submodules + - git submodule update --init --recursive + - python set-version.py + # Get the latest stable version of Node.js or io.js + - ps: Install-Product node $env:nodejs_version + # install modules + - npm install + - cd app + - npm install + - cd .. + # create lbrynet-daemon executable + - cd lbrynet + - ps: .\build.ps1 + - cd .. + # build ui + - cd lbry-web-ui + - npm install + - node_modules\.bin\node-sass --output dist\css --sourcemap=none scss\ + - node_modules\.bin\webpack + - ps: Copy-Item dist ..\app\ -recurse + - cd .. + - ps: Copy-Item lbrynet\dist\lbrynet-daemon.exe app\dist + +build_script: + # build electron app + - node_modules\.bin\build -p never + # for debugging, see what was built + - dir dist + +test: off + +artifacts: + - path: dist\*.zip + name: LBRY diff --git a/build.sh b/build.sh index 06c90dfcf..6a0ac2f35 100755 --- a/build.sh +++ b/build.sh @@ -10,8 +10,14 @@ else ICON="$ROOT/build/icons/lbry48.png" fi - +FULL_BUILD="${FULL_BUILD:-false}" if [ -n "${TEAMCITY_VERSION:-}" ]; then + FULL_BUILD="true" +elif [ -n "${APPVEYOR:-}" ]; then + FULL_BUILD="true" +fi + +if [ "$FULL_BUILD" == "true" ]; then # install dependencies $ROOT/prebuild.sh @@ -56,10 +62,10 @@ popd cp -r dist "$ROOT/app/dist" ) -mv "$ROOT/lbrynet/dist/lbry" "$ROOT/app/dist" +mv "$ROOT/lbrynet/dist/lbrynet-daemon" "$ROOT/app/dist" -if [ -n "${TEAMCITY_VERSION:-}" ]; then +if [ "$FULL_BUILD" == "true" ]; then if [ "$(uname)" == "Darwin" ]; then security unlock-keychain -p ${KEYCHAIN_PASSWORD} osx-build.keychain fi @@ -71,7 +77,7 @@ else echo 'Build complete. Run `./node_modules/.bin/electron app` to launch the app' fi -if [ -n "${TEAMCITY_VERSION:-}" ]; then +if [ "$FULL_BUILD" == "true" ]; then # electron-build has a publish feature, but I had a hard time getting # it to reliably work and it also seemed difficult to configure. Not proud of # this, but it seemed better to write my own. diff --git a/build/icon.ico b/build/icon.ico new file mode 100644 index 000000000..f8a33ff7c Binary files /dev/null and b/build/icon.ico differ diff --git a/build/icons/lbry128.ico b/build/icons/lbry128.ico new file mode 100644 index 000000000..3cb6f992d Binary files /dev/null and b/build/icons/lbry128.ico differ diff --git a/build/icons/lbry16.ico b/build/icons/lbry16.ico new file mode 100644 index 000000000..40d849628 Binary files /dev/null and b/build/icons/lbry16.ico differ diff --git a/build/icons/lbry256.ico b/build/icons/lbry256.ico new file mode 100644 index 000000000..f8a33ff7c Binary files /dev/null and b/build/icons/lbry256.ico differ diff --git a/build/icons/lbry32.ico b/build/icons/lbry32.ico new file mode 100644 index 000000000..6a6219b50 Binary files /dev/null and b/build/icons/lbry32.ico differ diff --git a/build/icons/lbry48.ico b/build/icons/lbry48.ico new file mode 100644 index 000000000..95c0947fa Binary files /dev/null and b/build/icons/lbry48.ico differ diff --git a/build/icons/lbry96.ico b/build/icons/lbry96.ico new file mode 100644 index 000000000..25572bc9c Binary files /dev/null and b/build/icons/lbry96.ico differ diff --git a/lbry b/lbry index 07233a885..9f358e05f 160000 --- a/lbry +++ b/lbry @@ -1 +1 @@ -Subproject commit 07233a885225c76f826f2b6f44e852fc3cbfa9db +Subproject commit 9f358e05ff58518bbf11437218f688a0d4b0f168 diff --git a/lbry-web-ui b/lbry-web-ui index 06f226d57..9c89652d4 160000 --- a/lbry-web-ui +++ b/lbry-web-ui @@ -1 +1 @@ -Subproject commit 06f226d57b839c2cbca8dacac4a418dd7bcfe192 +Subproject commit 9c89652d462fae1765791b9bee1cb23ddc35fcb4 diff --git a/lbrynet/build.ps1 b/lbrynet/build.ps1 new file mode 100644 index 000000000..b097f7211 --- /dev/null +++ b/lbrynet/build.ps1 @@ -0,0 +1,24 @@ +$env:Path += ";C:\MinGW\bin\" + +$env:Path += ";C:\Program Files (x86)\Windows Kits\10\bin\x86\" +gcc --version +mingw32-make --version + +mkdir temp +Invoke-WebRequest "https://pypi.python.org/packages/55/90/e987e28ed29b571f315afea7d317b6bf4a551e37386b344190cffec60e72/miniupnpc-1.9.tar.gz" -OutFile "temp\miniupnpc-1.9.tar.gz" +cd temp +tar zxf miniupnpc-1.9.tar.gz +cd miniupnpc-1.9 +mingw32-make.exe -f Makefile.mingw +python.exe setupmingw32.py build --compiler=mingw32 +python.exe setupmingw32.py install + +cd ..\..\ +Remove-Item -Recurse -Force temp + +pip.exe install -r windows-requirements.txt +pip.exe install ..\lbryum +pip.exe install ..\lbry +pip.exe install pyinstaller + +pyinstaller -y lbry.onefile.spec \ No newline at end of file diff --git a/lbrynet/lbry.onefile.spec b/lbrynet/lbry.onefile.spec index eef6e371f..40eabec53 100644 --- a/lbrynet/lbry.onefile.spec +++ b/lbrynet/lbry.onefile.spec @@ -4,34 +4,48 @@ import os import lbryum + cwd = os.getcwd() if os.path.basename(cwd) != 'lbrynet': raise Exception('The build needs to be run from the same directory as the spec file') repo_base = os.path.abspath(os.path.join(cwd, '..')) + system = platform.system() if system == 'Darwin': icns = os.path.join(repo_base, 'build', 'icon.icns') +elif system == 'Linux': + icns = os.path.join(repo_base, 'build', 'icons', '256x256.png') +elif system == 'Windows': + icns = os.path.join(repo_base, 'build', 'icons', 'lbry256.ico') else: - icns = os.path.join(repo_base, 'package', 'icons', '256x256.png') + print 'Warning: System {} has no icons'.format(system) + icns = None + block_cipher = None + + languages = ( 'chinese_simplified.txt', 'japanese.txt', 'spanish.txt', 'english.txt', 'portuguese.txt' ) + +datas = [ + ( + os.path.join(os.path.dirname(lbryum.__file__), 'wordlist', language), + 'lbryum/wordlist' + ) + for language in languages +] + + a = Analysis( ['lbry.py'], pathex=[cwd], binaries=None, - datas=[ - ( - os.path.join(os.path.dirname(lbryum.__file__), 'wordlist', language), - 'lbryum/wordlist' - ) - for language in languages - ], + datas=datas, hiddenimports=[], hookspath=[], runtime_hooks=[], @@ -41,28 +55,23 @@ a = Analysis( cipher=block_cipher ) + pyz = PYZ( a.pure, a.zipped_data, cipher=block_cipher ) + exe = EXE( pyz, a.scripts, a.binaries, a.zipfiles, a.datas, - name='lbry', + name='lbrynet-daemon', debug=False, strip=False, upx=True, - console=False, + console=True, icon=icns ) - -app = BUNDLE( - exe, - name='lbry.app', - icon=icns, - bundle_identifier=None -) diff --git a/lbrynet/lbry.py b/lbrynet/lbry.py index 2ed0360ab..8325e3398 100644 --- a/lbrynet/lbry.py +++ b/lbrynet/lbry.py @@ -1,4 +1,5 @@ from lbrynet.lbrynet_daemon import DaemonControl + if __name__ == '__main__': DaemonControl.start() diff --git a/lbrynet/lbry.spec b/lbrynet/lbry.spec deleted file mode 100644 index 190b5f1a4..000000000 --- a/lbrynet/lbry.spec +++ /dev/null @@ -1,61 +0,0 @@ -# -*- mode: python -*- -import lbryum - -block_cipher = None -languages = ( - 'chinese_simplified.txt', 'japanese.txt', 'spanish.txt', - 'english.txt', 'portuguese.txt' -) - - -a = Analysis( - ['lbry.py'], - pathex=['/Users/jobevers/projects/lbryio/lbry-electron/lbrynet'], - binaries=None, - # Not sure why these files are not already include as they are - # listed in package_data and the MANIFEST.in, but they don't seem - # to make it in unless we explicitly add them here - datas=[ - ( - os.path.join(os.path.dirname(lbryum.__file__), 'wordlist', language), - 'lbryum/wordlist' - ) - for language in languages - ], - hiddenimports=[], - hookspath=[], - runtime_hooks=[], - excludes=['win32com'], - 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='lbry', - debug=False, - strip=False, - upx=True, - console=True, -) -coll = COLLECT( - exe, - a.binaries, - a.zipfiles, - a.datas, - strip=False, - upx=True, - name='lbry' -) -app = BUNDLE( - coll, - name='lbry.app', - icon=None, - bundle_identifier=None -) diff --git a/lbrynet/windows-requirements.txt b/lbrynet/windows-requirements.txt new file mode 100644 index 000000000..3d7024332 --- /dev/null +++ b/lbrynet/windows-requirements.txt @@ -0,0 +1,30 @@ +pypiwin32==219 +six==1.10.0 +requests[security]==2.13.0 +zope.interface==4.3.3 +Twisted==16.6.0 +appdirs==1.4.0 +argparse==1.2.1 +colorama==0.3.7 +dnspython==1.12.0 +ecdsa==0.13 +envparse==0.2.0 +jsonrpc==1.2 +jsonrpclib==0.1.7 +loggly-python-handler==1.0.0 +pbkdf2==1.3 +protobuf==3.0.0 +pycrypto==2.6.1 +python-bitcoinrpc==0.1 +pyyaml==3.12 +qrcode==5.2.2 +requests_futures==0.9.7 +seccure==0.3.1.3 +simplejson==3.8.2 +slowaes==0.1a1 +txJSON-RPC==0.5 +wsgiref==0.1.2 +base58==0.2.2 +googlefinance==0.7 +jsonschema==2.5.1 +https://github.com/lbryio/lbry/raw/master/packaging/windows/libs/gmpy-1.17-cp27-none-win32.whl diff --git a/lbryum b/lbryum index bd370d353..b3c6815d4 160000 --- a/lbryum +++ b/lbryum @@ -1 +1 @@ -Subproject commit bd370d353069ef02566c9082fe876e4924861e68 +Subproject commit b3c6815d43222ae739aa1d2c1c670aa09d83bb2d diff --git a/package.json b/package.json index e866eb18a..2766bb005 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,9 @@ }, "linux": { "target": "deb" + }, + "win": { + "target": "zip" } }, "devDependencies": {