diff --git a/TODO.md b/TODO.md index df16efa..47b2dcf 100644 --- a/TODO.md +++ b/TODO.md @@ -1,5 +1,7 @@ # TODO -* pyInstaller -* add screenshot in README -* https://github.com/seanbreckenridge/browserexport or https://github.com/browser-history/browser-history +* [x] pyInstaller +* [x] add screenshot in README +* [x] https://github.com/seanbreckenridge/browserexport or https://github.com/browser-history/browser-history +* [ ] add some text in figure to explain what it is for neophytes and how to read it +* [ ] add autodetection of most common sleep patterns / circadian rhythm disorders patterns (DSPD/night shift work, non-24, ASPD, eveving owl, morning lark, social jet lag). Difference between night shift work and DSPD: night shift work don't sleep as well or as long as DSPD during the day, because not their circadian phase. diff --git a/pyInstallerInstructions.txt b/pyInstallerInstructions.txt index 4baf5d3..90338e3 100644 --- a/pyInstallerInstructions.txt +++ b/pyInstallerInstructions.txt @@ -2,8 +2,8 @@ Instructions to build a standalone exe using pyInstaller: 1. Install Anaconda or Miniconda3. 2. Launch the Anaconda/Miniconda3 command prompt, or just a standard terminal if conda is in the PATH. -3. conda create -n webactogramenv python=3.10 -Note: you can change the python version when a newer interpreter will be released. Creating a new venv is necessary to limit the number of packages in the environment, so that pyinstaller does not include a whole lot of unnecessary packages. +3. conda create -n webactogramenv python=3.11 +Note: you can change the python version when a newer interpreter will be released. Creating a new venv is necessary to limit the number of packages in the environment, so that pyinstaller does not include a whole lot of unnecessary packages in the final binaries. 4. conda activate webactogramenv 5. pip install --upgrade webactogram Note: webactogram needs to be up-to-date on pypi, otherwise replace this command by `pip install -e .` to use the local version. @@ -11,12 +11,11 @@ Note2: if trying to compile for another platform such as 32-bits, then it may be 6. pip install --upgrade pyinstaller From this step on, you can reuse the same environment each time you want to rebuild the freezed binary (as long as you install nothing else but the strictly necessary packages to run your project, as to keep it clean and with minimal dependencies): -7. cd to the webactogram subfolder (the module one, where webactogram.py resides) +7. cd to the webactogram folder (the root of the project, where there is pyproject.toml) 8. conda activate webactogramenv -9. if there is any dist or build or __pycache folder, delete them -10. pyinstaller -D -c --hidden-import="pkg_resources.py2_warn" --hidden-import="pkg_resources.py3_warn" --add-data="_version.py;." webactogram.py -Note: we used to bundle as one-file (with -F option), but in newer versions, the python app is unpackaged in a random temporary folder, which makes it difficult to bundle config files that are easily accessible and modifiable by the user. And also such apps are slower to launch than one-folder bundles. So we now bundle as a one-folder, using the -D option. We also force the console to stay open with the -c argument as it gives additional infos to the user, especially in case of errors. -11. Copy config.ini and config_internal.ini in the dist/webactogram folder -12. Zip the dist/webactogram folder and distribute it. +9. if there is any dist or build or __pycache__ folder (in src/webactogram/__pycache__), delete them +10. pyinstaller -F -c --hidden-import="pkg_resources.py2_warn" --hidden-import="pkg_resources.py3_warn" src/webactogram/webactogram.py +Note: we used to bundle as one-file (with -F option), but in newer versions, the python app is unpackaged in a random temporary folder, which makes it difficult to bundle config files that are easily accessible and modifiable by the user. And also such apps are slower to launch than one-folder bundles. So it can be preferred to bundle as a one-folder app, using the -D option. We also force the console to stay open with the -c argument as it gives additional infos to the user, especially in case of errors. +11. Zip the dist/webactogram folder and distribute it. To build a 32-bit binary, simply install Miniconda3 32-bit and repeat the steps above with the 32-bit interpreter. diff --git a/src/webactogram/webactogram.py b/src/webactogram/webactogram.py index 176e086..61991ce 100644 --- a/src/webactogram/webactogram.py +++ b/src/webactogram/webactogram.py @@ -788,7 +788,7 @@ def main(argv: Sequence[str] | None = None) -> int: """ Main entry point for the command line interface """ if argv is None: # if argv is empty, fetch from the commandline argv = sys.argv[1:] - elif isinstance(argv, _str): # else if argv is supplied but it's a simple string, we need to parse it to a list of arguments before handing to argparse or any other argument parser + elif isinstance(argv, str): # else if argv is supplied but it's a simple string, we need to parse it to a list of arguments before handing to argparse or any other argument parser argv = shlex.split(argv) # Parse string just like argv using shlex desc = '''WebActogram