Add pip-installable package with CLI and auto-detection · pathsim/pathview@ceba711 · GitHub
Skip to content

Commit ceba711

Browse files
milanoftheKDW1
andcommitted
Add pip-installable package with CLI and auto-detection
Co-Authored-By: KDW1 <KDW1@users.noreply.github.com>
1 parent 281510e commit ceba711

15 files changed

Lines changed: 727 additions & 403 deletions

File tree

‎.github/workflows/publish-pypi.yml‎

Lines changed: 77 additions & 0 deletions

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ tmpclaude-*
3838

3939

4040
__pycache__/
41+
*.egg-info/
42+
dist/
43+
pathview_server/static/
4144

4245
# Generated screenshots
4346
static/examples/screenshots/

‎README.md‎

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,39 @@ A web-based visual node editor for building and simulating dynamic systems with
1717
- [Plotly.js](https://plotly.com/javascript/) for interactive plots
1818
- [CodeMirror 6](https://codemirror.net/) for code editing
1919

20-
## Getting Started
20+
## Installation
21+
22+
### pip install (recommended for users)
23+
24+
```bash
25+
pip install pathview
26+
pathview serve
27+
```
28+
29+
This starts the PathView server with a local Python backend and opens your browser. No Node.js required.
30+
31+
**Options:**
32+
- `--port PORT` — server port (default: 5000)
33+
- `--host HOST` — bind address (default: 127.0.0.1)
34+
- `--no-browser` — don't auto-open the browser
35+
- `--debug` — debug mode with auto-reload
36+
37+
### Development setup
2138

2239
```bash
2340
npm install
2441
npm run dev
2542
```
2643

27-
To use the Flask backend (server-side Python):
44+
To use the Flask backend during development:
2845

2946
```bash
30-
pip install -r server/requirements.txt
47+
pip install flask flask-cors
3148
npm run server # Start Flask backend on port 5000
3249
npm run dev # Start Vite dev server (separate terminal)
3350
# Open http://localhost:5173/?backend=flask
3451
```
3552

36-
For production:
37-
38-
```bash
39-
npm run build
40-
npm run preview
41-
```
42-
4353
## Project Structure
4454

4555
```
@@ -82,10 +92,11 @@ src/
8292
├── routes/ # SvelteKit pages
8393
└── app.css # Global styles with CSS variables
8494
85-
server/
95+
pathview_server/ # Python package (pip install pathview)
8696
├── app.py # Flask server (subprocess management, HTTP routes)
8797
├── worker.py # REPL worker subprocess (Python execution)
88-
└── requirements.txt # Server Python dependencies
98+
├── cli.py # CLI entry point (pathview serve)
99+
└── static/ # Bundled frontend (generated at build time)
89100
90101
scripts/
91102
├── config/ # Configuration files for extraction
@@ -467,15 +478,21 @@ Browser Tab Flask Server Worker Subprocess
467478
└──────────────┘ └──────────────────┘ └──────────────────┘
468479
```
469480

470-
**Setup:**
481+
**Standalone (pip package):**
471482

472483
```bash
473-
pip install -r server/requirements.txt
474-
npm run server # Starts Flask on port 5000
475-
npm run dev # Starts Vite dev server (separate terminal)
484+
pip install pathview
485+
pathview serve
476486
```
477487

478-
Then open `http://localhost:5173/?backend=flask`.
488+
**Development (separate servers):**
489+
490+
```bash
491+
pip install flask flask-cors
492+
npm run server # Starts Flask API on port 5000
493+
npm run dev # Starts Vite dev server (separate terminal)
494+
# Open http://localhost:5173/?backend=flask
495+
```
479496

480497
**Key properties:**
481498
- **Process isolation** — each session gets its own Python subprocess
@@ -666,7 +683,8 @@ https://view.pathsim.org/?modelgh=pathsim/pathview/static/examples/feedback-syst
666683
|--------|---------|
667684
| `npm run dev` | Start Vite development server |
668685
| `npm run server` | Start Flask backend server (port 5000) |
669-
| `npm run build` | Production build |
686+
| `npm run build` | Production build (GitHub Pages) |
687+
| `npm run build:package` | Build pip package (frontend + wheel) |
670688
| `npm run preview` | Preview production build |
671689
| `npm run check` | TypeScript/Svelte type checking |
672690
| `npm run lint` | Run ESLint |
@@ -783,14 +801,23 @@ Port labels show the name of each input/output port alongside the node. Toggle g
783801

784802
## Deployment
785803

786-
PathView uses a dual deployment strategy with automatic versioning:
804+
PathView has two deployment targets:
805+
806+
### GitHub Pages (web)
787807

788808
| Trigger | What happens | Deployed to |
789809
|---------|--------------|-------------|
790810
| Push to `main` | Build with base path `/dev` | [view.pathsim.org/dev/](https://view.pathsim.org/dev/) |
791811
| Release published | Bump `package.json`, build, deploy | [view.pathsim.org/](https://view.pathsim.org/) |
792812
| Manual dispatch | Choose `dev` or `release` | Respective path |
793813

814+
### PyPI (pip package)
815+
816+
| Trigger | What happens | Published to |
817+
|---------|--------------|--------------|
818+
| Release published | Build frontend + wheel, publish | [pypi.org/project/pathview](https://pypi.org/project/pathview/) |
819+
| Manual dispatch | Choose `testpypi` or `pypi` | Respective index |
820+
794821
### How it works
795822

796823
1. Both versions deploy to the `deployment` branch using GitHub Actions

‎package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
2020
"lint": "eslint .",
2121
"format": "prettier --write .",
22-
"server": "python server/app.py"
22+
"server": "python -m pathview_server.app",
23+
"build:package": "python scripts/build_package.py"
2324
},
2425
"devDependencies": {
2526
"@sveltejs/adapter-static": "^3.0.0",

‎pathview_server/__init__.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""PathView Server — local Flask backend for PathView."""
2+
3+
__version__ = "0.5.0"

‎pathview_server/__main__.py‎

Lines changed: 6 additions & 0 deletions

0 commit comments

Comments
 (0)