Skip to content

Commit

Permalink
Make .sh scripts Windows compatible (Mingw). Release 0.1.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
elonen committed Dec 28, 2019
1 parent a452dd4 commit 8979eee
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 24 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ pip install --editable git://github.com/elonen/lanscatter.git#egg=lanscatter
```
git clone git+ssh://[email protected]/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.
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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 <[email protected]>
Expand Down
26 changes: 22 additions & 4 deletions init-env.sh
Original file line number Diff line number Diff line change
@@ -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'."
2 changes: 1 addition & 1 deletion lanscatter/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'


Expand Down
10 changes: 0 additions & 10 deletions pyinstaller-build.bat

This file was deleted.

47 changes: 42 additions & 5 deletions pyinstaller-build.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8979eee

Please sign in to comment.