Skip to content

Commit f4445b4

Browse files
fix(setup): only run openparse-download when openparse is installed
Guard the post-install weight download with an `import openparse` probe so a stripped-down install (no openparse[ml] in install_requires) does not call a missing console-script and emit a confusing error. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 9242566 commit f4445b4

1 file changed

Lines changed: 21 additions & 12 deletions

File tree

setup.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,28 @@ def run(self):
4646
except Exception as err:
4747
print(f"Error when installing yt-dlp pre-release: '{err}'")
4848

49-
# do "openparse-download"
49+
# Only run "openparse-download" if openparse is actually installed.
50+
# openparse[ml] is in install_requires today, but guard anyway so this
51+
# post-install does not crash on a stripped-down install.
5052
try:
51-
subprocess.check_call(
52-
["openparse-download"],
53-
)
54-
except Exception as err:
55-
print(
56-
"Error when trying to run 'openparse-download' to download"
57-
f" weights for deep learning based table detection : '{err}'"
58-
"\nBy default wdoc still uses pymupdf via openparse so it "
59-
"shouldn't matter too much.\n"
60-
"For more: see https://github.com/Filimoa/open-parse/"
61-
)
53+
import openparse # noqa: F401
54+
55+
has_openparse = True
56+
except ImportError:
57+
has_openparse = False
58+
if has_openparse:
59+
try:
60+
subprocess.check_call(
61+
["openparse-download"],
62+
)
63+
except Exception as err:
64+
print(
65+
"Error when trying to run 'openparse-download' to download"
66+
f" weights for deep learning based table detection : '{err}'"
67+
"\nBy default wdoc still uses pymupdf via openparse so it "
68+
"shouldn't matter too much.\n"
69+
"For more: see https://github.com/Filimoa/open-parse/"
70+
)
6271

6372
# do "import nltk ; nltk.download('punkt_tab')"
6473
try:

0 commit comments

Comments
 (0)