diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4c395ab..393039f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,15 +27,18 @@ jobs: - name: Install dependencies run: | - sudo apt-get update + sudo apt-get update sudo apt-get install ffmpeg -y - pip install numpy matplotlib ruff + + pip install ruff - name: Test WCONViewer run: | - ./test_all.sh + + ./test_all.sh # also does pip install . and ruff check - name: Print info on files run: | + pip list ls -alt diff --git a/.gitignore b/.gitignore index 1410572..2d24004 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ /__pycache__ /.DS_Store /examples/*.mp4 +/old +/build +/*.egg-info diff --git a/README.md b/README.md index 8785ead..0791e53 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,18 @@ # WCONViewer Python based viewer for WCON files in 2D + +## Installation + +``` +pip install . +``` + +Saving animations with `-nogui` requires the `ffmpeg` binary to be installed on your system. + +## Usage + +``` +wconviewer -f examples/simdata.wcon +``` + +Run `wconviewer -h` for all options (e.g. `-nogui` to save an `.mp4` instead of showing a window). diff --git a/app.py b/app.py index f6ed73f..dbdba1d 100644 --- a/app.py +++ b/app.py @@ -3,7 +3,7 @@ import streamlit as st -from WormView import WormView +from wconviewer.WormView import WormView DEFAULT_WCON = "examples/simdata.wcon" FRAME_DELAY = 0.1 # seconds between frames while playing diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b36d89a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,28 @@ +[build-system] +requires = ["setuptools>=61"] +build-backend = "setuptools.build_meta" + +[project] +name = "WCONViewer" +version = "0.1.0" +description = "Viewer for WCON (Worm tracker Commons Object Notation) files in 2D" +readme = "README.md" +license = { file = "LICENSE" } +requires-python = ">=3.10" +dependencies = ["numpy", "matplotlib"] + +[project.optional-dependencies] +dev = ["ruff"] + +[project.scripts] +wconviewer = "wconviewer.WormView:main" + +[tool.setuptools] +packages = ["wconviewer"] + +[tool.ruff] +target-version = "py310" +line-length = 88 + +[tool.ruff.lint] +select = ["E4", "E7", "E9", "F"] diff --git a/test_all.sh b/test_all.sh index 831f82f..751bef4 100755 --- a/test_all.sh +++ b/test_all.sh @@ -1,11 +1,13 @@ #!/bin/bash set -ex -ruff format *.py -ruff check *.py +ruff format wconviewer app.py +ruff check wconviewer app.py -python WormView.py -f examples/simdata.wcon -nogui -z # Test reloading WCON in Player -python WormView.py -f examples/worm_motion_log.wcon -nogui -g -python WormView.py -f examples/output_W2D.wcon -nogui -g -z +pip install . -#python WormView.py -f examples/N2\ on\ food\ L_2009_09_15__11_01_01___8___1.wcon.zip -nogui +wconviewer -f examples/simdata.wcon -nogui -z # Test reloading WCON in Player +wconviewer -f examples/worm_motion_log.wcon -nogui -g +wconviewer -f examples/output_W2D.wcon -nogui -g -z + +#wconviewer -f examples/N2\ on\ food\ L_2009_09_15__11_01_01___8___1.wcon.zip -nogui diff --git a/Player.py b/wconviewer/Player.py similarity index 100% rename from Player.py rename to wconviewer/Player.py diff --git a/SimpleWCON.py b/wconviewer/SimpleWCON.py similarity index 100% rename from SimpleWCON.py rename to wconviewer/SimpleWCON.py diff --git a/WormView.py b/wconviewer/WormView.py similarity index 99% rename from WormView.py rename to wconviewer/WormView.py index 3c67d37..641a0f5 100644 --- a/WormView.py +++ b/wconviewer/WormView.py @@ -5,8 +5,8 @@ import os import argparse import sys -from Player import Player -from SimpleWCON import SimpleWCON +from .Player import Player +from .SimpleWCON import SimpleWCON class HalfIntegerLocator(MultipleLocator): @@ -277,7 +277,7 @@ def parse_args(): "--wcon_file", type=validate_file, help="WCON file path", - default="examples/simdata.wcon", + required=True, ) parser.add_argument( "-nogui", action="store_true", help="Just load file, don't show GUI" diff --git a/wconviewer/__init__.py b/wconviewer/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/wconviewer/__main__.py b/wconviewer/__main__.py new file mode 100644 index 0000000..c1179f5 --- /dev/null +++ b/wconviewer/__main__.py @@ -0,0 +1,5 @@ +import sys + +from .WormView import main + +sys.exit(main())