Skip to content

Commit

Permalink
Merge pull request #15 from nickpgill/master
Browse files Browse the repository at this point in the history
Updated to Python 3.11
  • Loading branch information
nickpgill authored Oct 9, 2024
2 parents 93dc168 + 495e4dd commit b62969f
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 562 deletions.
130 changes: 130 additions & 0 deletions .github/workflows/release-executables.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: Release Executables
on:
push:
tags:
- '*'

jobs:
#
# 1. Build Windows Executable
#
build-windows-exe:
name: 'script.exe creation using python 3.11 on Windows'
runs-on: 'windows-latest'
steps:
- uses: actions/checkout@v2
# https://github.com/actions/setup-python
- uses: actions/setup-python@v2
with:
python-version: '3.11'
# https://hynek.me/articles/python-github-actions/
- name: "Install dependencies"
run: |
python -VV
python -m site
python -m pip install --upgrade pip
pip install pyyaml
pip install argparse
pip install pyinstaller==6.10.0
pip install eel==0.17.0
pip install cvxpy==1.5.3
pip install gspread==6.1.2
pip install mip
pip install oauth2client==4.1.3
pip install toml==0.10.2
python -m eel script.py web -n strat-select-win.exe --additional-hooks-dir=. --onefile --noconsole
mkdir -p target/release
mv dist/strat-select-win.exe target/release
# copy nicks-script.exe to the release
#
# https://github.com/marketplace/actions/upload-files-to-a-github-release
- name: upload executable to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/release/strat-select-win.exe
tag: ${{ github.ref }}
overwrite: true
body: "script release text"
#
# 2. Build MacOS Executable
#
build-macos-executable:
name: 'script.app creation using python 3.11 on MacOS'
runs-on: 'macos-latest'
steps:
- uses: actions/checkout@v2
# https://github.com/actions/setup-python
- uses: actions/setup-python@v2
with:
python-version: '3.11'
# https://hynek.me/articles/python-github-actions/
- name: "Install dependencies"
run: |
python -VV
python -m site
python -m pip install --upgrade pip
pip install pyyaml
pip install argparse
pip install pyinstaller==6.10.0
pip install eel==0.17.0
pip install cvxpy==1.5.3
pip install gspread==6.1.2
pip install mip
pip install oauth2client==4.1.3
pip install toml==0.10.2
python -m eel script.py web -n strat-select-macos --additional-hooks-dir=. --onefile --noconsole
mkdir -p target/release
mv dist/strat-select-macos target/release
# copy script.app to the release
#
# https://github.com/marketplace/actions/upload-files-to-a-github-release
- name: upload exectuable to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/release/strat-select-macos
tag: ${{ github.ref }}
overwrite: true
body: "script release text"
#
# 3. Build Linux Executable
#
build-linux-executable:
name: 'executable creation using python 3.11 on Linux'
runs-on: 'ubuntu-24.04'
steps:
- uses: actions/checkout@v2
# https://github.com/actions/setup-python
- uses: actions/setup-python@v2
with:
python-version: '3.11'
# https://hynek.me/articles/python-github-actions/
- name: "Install dependencies"
run: |
python -VV
python -m site
python -m pip install --upgrade pip
pip install pyyaml
pip install argparse
pip install pyinstaller==6.10.0
pip install eel==0.17.0
pip install cvxpy==1.5.3
pip install gspread==6.1.2
pip install mip
pip install oauth2client==4.1.3
pip install toml==0.10.2
python -m eel script.py web -n strat-select-linux --additional-hooks-dir=. --onefile --noconsole
mkdir -p target/release
mv dist/strat-select-linux target/release
# copy script.app to the release
#
# https://github.com/marketplace/actions/upload-files-to-a-github-release
- name: upload exectuable to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/release/strat-select-linux
tag: ${{ github.ref }}
overwrite: true
body: "script release text"
48 changes: 0 additions & 48 deletions .github/workflows/release-windows-executable.yml

This file was deleted.

44 changes: 0 additions & 44 deletions .travis.yml

This file was deleted.

51 changes: 35 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,60 @@ The app is built using [eel](https://github.com/ChrisKnott/Eel) - a framework th
First you need to have the following installed:

- git
- python 3.6
- [pipenv](https://docs.pipenv.org/en/latest/)
- python 3.11 or 3.12
- a recent version of Chrome or Chromium
- poetry

### Running in development

After cloning this repo, open a terminal in the root of the repo and run:
When you first set up a development version, you need to clone this repo, open a terminal in the root of the repo and run:

```
pipenv install --dev
pipenv shell
pip install eel
pip install cvxpy
pip install gspread
pip install mip
pip install toml
pip install oauth2client
poetry shell
python script.py
```

At which point you should have a window pop up and be able to interact with it.
At this point you should have a window pop up and be able to interact with it, either via uploading .csv files or else by reading directly from a google sheet.

Releasing
You will only need to do those *pip install* commands when you first set up your development version. After that, simply run:

```
poetry shell
python script.py
```

### Key files

The python command *python script.py* requires only:
- script.py
- stratification.py
- all of the files in the folder *web*

To use poetry (as we suggest above) to control dependencies, you need *pyproject.toml*

To create exectuables using pyinstaller (as we describe below), you need *hook-mip.py* to deal with [this error](https://github.com/coin-or/python-mip/issues/198).

Executables
---------

To make a single file executable, we use [PyInstaller](https://pyinstaller.readthedocs.io/en/stable/). The following command, run in the root of the repo, creates a single file executable at `dist/script` - you can rename it to whatever you want. You can then give it to someone running on the same **platform** as you, and they can run it immediately
You can download executables from the latest releases page.

The command is:
If you want to make an executable yourself, use [PyInstaller](https://pyinstaller.readthedocs.io/en/stable/). The following set of commands, run in the root of the repo, create a single file executable in the folder `dist`.

```
git pull
pipenv shell
poetry shell
python -m eel script.py web --additional-hooks-dir=. --onefile --noconsole
```

**Platform** means Windows, Mac OS X or Linux. So if you run the above command on Linux, you can give the file to someone else running Linux. So if the person who wants the app is running Windows, you need to run the above command on Windows.
The resulting executable will work on any computer running the same operating system as yours, i.e. Windows, Mac OS or Linux. So if you run the above command on Linux, you can give the file to someone else running Linux. If the person who wants the app is running Windows, you need to run the above command on Windows.


Note that on Windows you need to install an extra package:

```
pip install pypiwin32
```

This should be done by `pipenv install` but I may have got the syntax wrong.
72 changes: 0 additions & 72 deletions cli.py

This file was deleted.

Loading

0 comments on commit b62969f

Please sign in to comment.