Claude commited on
Commit
6cf78f1
·
unverified ·
1 Parent(s): d7214cb

Fix HF Space build: drop `-e .` + add src/ to sys.path in app.py

Browse files

HF Spaces only mounts requirements.txt during the pip-install build step,
so `-e .[decoder,gui]` failed with "file:///app does not appear to be a
Python project" — pyproject.toml wasn't there yet.

* requirements.txt: list deps directly instead of editable install.
* app.py: prepend `src/` to sys.path at import time so `from qcal import ...`
resolves on the Space without installing the package.

The pip package install path (`pip install qcal-copilot`) is unchanged —
the src-layout wheel handles that. This shim only kicks in when the repo
is run in-place.

Files changed (2) hide show
  1. app.py +9 -0
  2. requirements.txt +30 -13
app.py CHANGED
@@ -20,6 +20,15 @@ Environment (optional):
20
  from __future__ import annotations
21
 
22
  import os
 
 
 
 
 
 
 
 
 
23
 
24
  import gradio as gr
25
 
 
20
  from __future__ import annotations
21
 
22
  import os
23
+ import sys
24
+ from pathlib import Path
25
+
26
+ # On HF Spaces the build step only mounts requirements.txt, so `pip install -e .`
27
+ # can't reach pyproject.toml. Put src/ on sys.path so `from qcal import ...`
28
+ # resolves against the src-layout package without needing it installed.
29
+ _SRC = Path(__file__).resolve().parent / "src"
30
+ if _SRC.is_dir() and str(_SRC) not in sys.path:
31
+ sys.path.insert(0, str(_SRC))
32
 
33
  import gradio as gr
34
 
requirements.txt CHANGED
@@ -1,15 +1,32 @@
1
- # HF Space / quick-start requirements. Installs qcal-copilot from this repo
2
- # in editable mode plus the extras the Gradio app needs.
3
  #
4
- # For a lighter install (CLI + NIM only, no local VLM weights), use:
5
- # pip install .[decoder]
6
- -e .[decoder,gui]
7
-
8
- # Extras pulled in via the editable install above:
9
- # numpy, pandas, matplotlib, pillow, requests, scipy, typer, platformdirs
10
- # gradio (via [gui]), pymatching (via [decoder])
11
- #
12
- # Add [ml] to also install torch + transformers for local Ising VLM weights:
13
- # -e .[ml,decoder,gui]
14
  #
15
- # CUDA-Q is installed separately (see README).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HF Space / quick-start requirements.
 
2
  #
3
+ # We DON'T use `-e .[...]` here because HF Spaces only mounts requirements.txt
4
+ # during the pip-install build step — pyproject.toml isn't available yet — and
5
+ # the editable install fails with "file:///app does not appear to be a Python
6
+ # project". Instead we list the deps directly; `app.py` puts `src/` on sys.path
7
+ # at import time so `from qcal import ...` still resolves.
 
 
 
 
 
8
  #
9
+ # For a proper pip install (CLI + Python API), use:
10
+ # pip install qcal-copilot # core + NIM
11
+ # pip install "qcal-copilot[decoder]" # + PyMatching
12
+ # pip install "qcal-copilot[gui]" # + Gradio
13
+ # pip install "qcal-copilot[ml]" # + torch + transformers
14
+ # pip install "qcal-copilot[all]" # everything
15
+
16
+ # Core (kept in sync with pyproject.toml [dependencies])
17
+ numpy>=1.26
18
+ pandas>=2.2
19
+ matplotlib>=3.8
20
+ pillow>=10.0
21
+ requests>=2.32
22
+ scipy>=1.11
23
+ typer>=0.12
24
+ platformdirs>=4.0
25
+ tabulate>=0.9 # pandas.DataFrame.to_markdown
26
+
27
+ # [decoder]
28
+ pymatching>=2.2
29
+
30
+ # [gui] — HF Space's bootstrap pins gradio==4.44.0, so don't override it here.
31
+
32
+ # CUDA-Q is installed separately on the Space (see README).