From c4e363fbe347809e7c405c228863832d4fd973fd Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Wed, 15 Mar 2017 19:58:36 -0400 Subject: [PATCH] attempt to build cli alongside daemon --- .gitignore | 4 +- appveyor.yml | 8 +- build/build.sh | 5 +- {lbrynet-daemon => daemon}/build.ps1 | 3 +- daemon/cli.onefile.spec | 77 ++++++++++++++++++ daemon/cli.py | 5 ++ .../daemon.onefile.spec | 4 +- lbrynet-daemon/lbry.py => daemon/daemon.py | 0 .../gmpy-1.17-cp27-none-win32.whl | Bin {lbrynet-daemon => daemon}/linux_macos.txt | 0 {lbrynet-daemon => daemon}/requirements.txt | 0 {lbrynet-daemon => daemon}/windows.txt | 0 12 files changed, 96 insertions(+), 10 deletions(-) rename {lbrynet-daemon => daemon}/build.ps1 (90%) create mode 100644 daemon/cli.onefile.spec create mode 100644 daemon/cli.py rename lbrynet-daemon/lbry.onefile.spec => daemon/daemon.onefile.spec (95%) rename lbrynet-daemon/lbry.py => daemon/daemon.py (100%) rename {lbrynet-daemon => daemon}/gmpy-1.17-cp27-none-win32.whl (100%) rename {lbrynet-daemon => daemon}/linux_macos.txt (100%) rename {lbrynet-daemon => daemon}/requirements.txt (100%) rename {lbrynet-daemon => daemon}/windows.txt (100%) diff --git a/.gitignore b/.gitignore index 020530838..1301f029d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,8 @@ dist /app/node_modules /build/venv /lbry-app-venv -/lbrynet-daemon/build -/lbrynet-daemon/venv +/daemon/build +/daemon/venv /.idea *.pyc diff --git a/appveyor.yml b/appveyor.yml index 9f71ca7bd..299ed1563 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -21,8 +21,8 @@ install: - cd app - npm install - cd .. - # create lbrynet-daemon executable - - cd lbrynet-daemon + # create daemon and cli executable + - cd daemon - ps: .\build.ps1 - cd .. # build ui @@ -32,7 +32,9 @@ install: - node_modules\.bin\webpack - ps: Copy-Item dist ..\app\ -recurse - cd .. - - ps: Copy-Item lbrynet-daemon\dist\lbrynet-daemon.exe app\dist + # copy executables into ui + - ps: Copy-Item daemon\dist\lbrynet-daemon.exe app\dist + - ps: Copy-Item daemon\dist\lbrynet-cli.exe app\dist build_script: # build electron app diff --git a/build/build.sh b/build/build.sh index a6355f653..b28f272de 100755 --- a/build/build.sh +++ b/build/build.sh @@ -63,9 +63,10 @@ npm install #################### ( - cd "$ROOT/lbrynet-daemon" + cd "$ROOT/daemon" pip install -r linux_macos.txt - pyinstaller -y lbry.onefile.spec + pyinstaller -y daemon.onefile.spec + pyinstaller -y cli.onefile.spec mv dist/lbrynet-daemon "$ROOT/app/dist/" ) python "$BUILD_DIR/zip_daemon.py" diff --git a/lbrynet-daemon/build.ps1 b/daemon/build.ps1 similarity index 90% rename from lbrynet-daemon/build.ps1 rename to daemon/build.ps1 index 7732c823b..9e4148f86 100644 --- a/lbrynet-daemon/build.ps1 +++ b/daemon/build.ps1 @@ -19,4 +19,5 @@ Remove-Item -Recurse -Force temp pip.exe install pyinstaller pip.exe install -r windows.txt -pyinstaller -y lbry.onefile.spec \ No newline at end of file +pyinstaller -y daemon.onefile.spec +pyinstaller -y cli.onefile.spec \ No newline at end of file diff --git a/daemon/cli.onefile.spec b/daemon/cli.onefile.spec new file mode 100644 index 000000000..20b1ab19f --- /dev/null +++ b/daemon/cli.onefile.spec @@ -0,0 +1,77 @@ +# -*- mode: python -*- +import platform +import os + +import lbryum + + +cwd = os.getcwd() +if os.path.basename(cwd) != 'daemon': + 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: + 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( + ['cli.py'], + pathex=[cwd], + binaries=None, + datas=datas, + hiddenimports=[], + hookspath=[], + 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, + a.binaries, + a.zipfiles, + a.datas, + name='lbrynet-cli', + debug=False, + strip=False, + upx=True, + console=True, + icon=icns +) diff --git a/daemon/cli.py b/daemon/cli.py new file mode 100644 index 000000000..4b48e7f46 --- /dev/null +++ b/daemon/cli.py @@ -0,0 +1,5 @@ +from lbrynet.lbrynet_daemon import DaemonCLI + + +if __name__ == '__main__': + DaemonCLI.main() \ No newline at end of file diff --git a/lbrynet-daemon/lbry.onefile.spec b/daemon/daemon.onefile.spec similarity index 95% rename from lbrynet-daemon/lbry.onefile.spec rename to daemon/daemon.onefile.spec index 58a3a4174..ea42f5289 100644 --- a/lbrynet-daemon/lbry.onefile.spec +++ b/daemon/daemon.onefile.spec @@ -6,7 +6,7 @@ import lbryum cwd = os.getcwd() -if os.path.basename(cwd) != 'lbrynet-daemon': +if os.path.basename(cwd) != 'daemon': 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, '..')) @@ -42,7 +42,7 @@ datas = [ a = Analysis( - ['lbry.py'], + ['daemon.py'], pathex=[cwd], binaries=None, datas=datas, diff --git a/lbrynet-daemon/lbry.py b/daemon/daemon.py similarity index 100% rename from lbrynet-daemon/lbry.py rename to daemon/daemon.py diff --git a/lbrynet-daemon/gmpy-1.17-cp27-none-win32.whl b/daemon/gmpy-1.17-cp27-none-win32.whl similarity index 100% rename from lbrynet-daemon/gmpy-1.17-cp27-none-win32.whl rename to daemon/gmpy-1.17-cp27-none-win32.whl diff --git a/lbrynet-daemon/linux_macos.txt b/daemon/linux_macos.txt similarity index 100% rename from lbrynet-daemon/linux_macos.txt rename to daemon/linux_macos.txt diff --git a/lbrynet-daemon/requirements.txt b/daemon/requirements.txt similarity index 100% rename from lbrynet-daemon/requirements.txt rename to daemon/requirements.txt diff --git a/lbrynet-daemon/windows.txt b/daemon/windows.txt similarity index 100% rename from lbrynet-daemon/windows.txt rename to daemon/windows.txt