Huiran Yu commited on
Commit
ea8b7ec
·
1 Parent(s): eed6484

patch numpy

Browse files
Files changed (2) hide show
  1. Dockerfile +29 -18
  2. requirements.txt +0 -1
Dockerfile CHANGED
@@ -23,28 +23,39 @@ RUN pip install --no-cache-dir --no-build-isolation madmom
23
 
24
  # madmom patch
25
  RUN python - <<'PY'
26
- import site, pathlib
27
 
28
- # find the installed madmom processors.py
29
- paths = site.getsitepackages()
30
- target = None
31
- for p in paths:
32
- cand = pathlib.Path(p) / "madmom" / "processors.py"
33
  if cand.exists():
34
- target = cand
35
  break
 
 
36
 
37
- if target is None:
38
- raise SystemExit("madmom/processors.py not found")
39
-
40
- txt = target.read_text(encoding="utf-8")
41
- txt2 = txt.replace("from collections import MutableSequence",
42
- "from collections.abc import MutableSequence")
43
- if txt == txt2:
44
- print("No change needed (pattern not found).")
45
- else:
46
- target.write_text(txt2, encoding="utf-8")
47
- print("Patched:", target)
 
 
 
 
 
 
 
 
 
 
 
48
  PY
49
 
50
 
 
23
 
24
  # madmom patch
25
  RUN python - <<'PY'
26
+ import site, pathlib, re
27
 
28
+ pkg_root = None
29
+ for p in site.getsitepackages():
30
+ cand = pathlib.Path(p) / "madmom"
 
 
31
  if cand.exists():
32
+ pkg_root = cand
33
  break
34
+ if pkg_root is None:
35
+ raise SystemExit("madmom package not found")
36
 
37
+ repls = [
38
+ ("from collections import MutableSequence", "from collections.abc import MutableSequence"),
39
+ ("np.float", "float"), # or "np.float64"
40
+ ("np.int", "int"),
41
+ ("np.bool", "bool"),
42
+ ("np.object", "object"),
43
+ ]
44
+
45
+ patched = 0
46
+ for f in pkg_root.rglob("*.py"):
47
+ try:
48
+ s = f.read_text(encoding="utf-8")
49
+ except Exception:
50
+ continue
51
+ s2 = s
52
+ for a, b in repls:
53
+ s2 = s2.replace(a, b)
54
+ if s2 != s:
55
+ f.write_text(s2, encoding="utf-8")
56
+ patched += 1
57
+
58
+ print(f"Patched {patched} madmom files under {pkg_root}")
59
  PY
60
 
61
 
requirements.txt CHANGED
@@ -2,7 +2,6 @@ pip>=23.1
2
  setuptools<82
3
  wheel
4
  gradio==5.28.0
5
- numpy==1.26.4
6
  Cython
7
  git+https://github.com/TEAMuP-dev/pyharp.git@v0.3.0
8
  librosa
 
2
  setuptools<82
3
  wheel
4
  gradio==5.28.0
 
5
  Cython
6
  git+https://github.com/TEAMuP-dev/pyharp.git@v0.3.0
7
  librosa