diff --git a/README.md b/README.md index a4a7852..b228c9a 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,7 @@ pip install --editable git://github.com/elonen/lanscatter.git#egg=lanscatter ``` git clone git+ssh://git@github.com/elonen/lanscatter.git cd lanscatter -python3.7 -m venv venv -source venv/bin/activate -python setup.py develop +./init-env.sh # on Windows requires Mingw (Git Bash) or Cygwin ``` Either way, you can now type `lanscatter_master`, `lanscatter_peer` or `lanscatter_gui` on the command line. @@ -105,7 +103,7 @@ Notable modules: ## Testing -The `tests` folder contains integration and unit tests using the _pytest_ framework. +The `tests` folder contains integration and unit tests using the _pytest_ framework; simply the environment and run `pytest`. Integration test – in short – runs a master node and several peer node simultaneously, with random sync dir contents, and makes sure they get in sync without errors. @@ -161,6 +159,11 @@ Numbers on the right show current downloads, current uploads and average time it See `planner.plan_transfers()` for details on how planning algorithm works. +## Building + +Being a Python package, Lanscatter doesn't require building, but if you want to package .exe binaries for +Windows , run `pyinstaller-build.sh` in _Git Bash_ (Mingw) or Cygwin. + ## License Copyright 2019 Jarno Elonen diff --git a/init-env.sh b/init-env.sh index 838bf0b..04a1cbb 100755 --- a/init-env.sh +++ b/init-env.sh @@ -1,12 +1,30 @@ #!/bin/bash +set -e + +PYTHON=python3.7 +REQ=requirements.txt +ACTIVATE=venv/bin/activate + +if (uname | grep -q -E '(CYGWIN|MINGW)'); then + echo "NOTE: Windows OS detected. Using 'python' instead of '$PYTHON'." + PYTHON=python + ACTIVATE=venv/Scripts/activate +fi + +if (uname | grep -q -E 'Linux'); then + echo "NOTE: Linux OS detected. Skipping installing GUI packages (failing ATM)." + REQ=requirements.cli.txt +fi + if [ ! -e venv ]; then - python3.7 -m venv venv + $PYTHON -m venv venv fi -source venv/bin/activate || { echo "Venv activation failed."; exit 1; } -pip install -r requirements.txt + +source $ACTIVATE || { echo "Venv activation failed."; exit 1; } +pip install -r $REQ python ./setup.py develop echo " " echo "---" -echo "Done. First run 'source venv/bin/activate'" +echo "Done. First run 'source $ACTIVATE'" echo "Then try 'lanscatter_master --help', 'lanscatter_peer' or 'lanscatter_gui'." diff --git a/lanscatter/common.py b/lanscatter/common.py index d532282..70df886 100644 --- a/lanscatter/common.py +++ b/lanscatter/common.py @@ -21,7 +21,7 @@ class Defaults: CONCURRENT_TRANSFERS_PEER = 2 DIR_SCAN_INTERVAL_PEER = 60 - APP_VERSION = '0.1.0' + APP_VERSION = '0.1.1' PROTOCOL_VERSION = '1.0.0' diff --git a/pyinstaller-build.bat b/pyinstaller-build.bat deleted file mode 100644 index acb6b9b..0000000 --- a/pyinstaller-build.bat +++ /dev/null @@ -1,10 +0,0 @@ -IF NOT EXIST venv (python -m venv venv) -CALL venv\Scripts\activate -venv\Scripts\pip install -r requirements.txt -venv\Scripts\python ./setup.py develop -venv\Scripts\python setup.py pyinstaller -- --noconsole --onefile --add-data "gfx/*;gfx" --icon gfx/icon.ico -copy dist\lanscatter_gui.exe .\ -del /S dist /Q -venv\Scripts\python setup.py pyinstaller -- --onefile -copy dist\lanscatter_master.exe .\ -copy dist\lanscatter_peer.exe .\ diff --git a/pyinstaller-build.sh b/pyinstaller-build.sh index 32dc228..51545d9 100755 --- a/pyinstaller-build.sh +++ b/pyinstaller-build.sh @@ -1,9 +1,46 @@ #!/bin/bash -if [ ! -e venv ]; then - python3.7 -m venv venv +PYTHON=python3.7 +REQ=requirements.txt +ACTIVATE=venv/bin/activate +set -e + +VER=$(git describe --exact-match 2> /dev/null || echo "`git symbolic-ref HEAD 2> /dev/null | cut -b 12-`-`git log --pretty=format:\"%h\" -1`") +echo "Current version string is: '$VER'" + +if (uname | grep -q -E '(CYGWIN|MINGW)'); then + echo "NOTE: Windows OS detected. Using 'python' instead of '$PYTHON'." + PYTHON=python + ACTIVATE=venv/Scripts/activate fi -source venv/bin/activate || { echo "Venv activation failed."; exit 1; } -pip install -r requirements.txt + +if (uname | grep -q -E 'Linux'); then + echo "NOTE: Linux OS detected. Skipping installing GUI packages (failing ATM)." + REQ=requirements.cli.txt +fi + +source $ACTIVATE || { echo "Venv activation failed."; exit 1; } +pip install -r $REQ + +echo " " pytest || { echo "Tests failed, will not continue with pyinstaller."; exit 1; } python ./setup.py develop -python ./setup.py pyinstaller -- --noconsole --onefile --add-data 'gfx/*:gfx' --icon gfx/icon.ico + +if (uname | grep -q -E '(CYGWIN|MINGW)'); then + ZIPFILE="lanscatter-win32_$VER.zip" + python setup.py pyinstaller -- --noconsole --onefile --add-data "gfx/*;gfx" --icon gfx/icon.ico + cp dist/lanscatter_gui.exe ./ + rm -rf dist + python setup.py pyinstaller -- --onefile + cp dist/lanscatter_master.exe dist/lanscatter_peer.exe ./ + rm -f lanscatter-win32.zip + python -c "import zipfile, glob; z=zipfile.ZipFile('$ZIPFILE', 'w'); [z.write(f) for f in glob.glob('*.exe')]" + rm -- *.exe + echo "--- DONE. Windows binaries built and packaged into $ZIPFILE" + +else + echo "--- NOTE: We are not on Windows, so binaries will stay in dist/." + python ./setup.py pyinstaller -- --noconsole --onefile --add-data 'gfx/*:gfx' --icon gfx/icon.ico +fi + +rm -rf dist +rm -f lanscatter_*.spec