Skip to content

Turn any technical book PDF into a Claude Code skill — ready to study, reference, and use while you work.

PyPI Packaging & CLI Entrypoint (#48)

Marcello Mendo2d5067216ee8
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index df23b1b..9cf34ba 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -17,8 +17,8 @@ jobs:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- - uses: actions/checkout@v6
- - uses: actions/setup-python@v6
+ - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
+ - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
with:
python-version: ${{ matrix.python-version }}
- name: Install pytest
@@ -30,8 +30,8 @@ jobs:
name: lint (ruff)
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v6
- - uses: actions/setup-python@v6
+ - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
+ - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
with:
python-version: "3.12"
- name: Install ruff
@@ -40,14 +40,14 @@ jobs:
# High-value gate: syntax errors (E9, e.g. IndentationError) + pyflakes
# (F: undefined names, unused imports). Style rules are intentionally
# not gated yet to avoid blocking on cosmetic churn.
- run: ruff check --select E9,F --target-version py310 scripts/ tests/
+ run: ruff check --select E9,F --target-version py310 book_to_skill/ scripts/ tests/ tools/
smoke:
name: smoke (dependency-free extraction)
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v6
- - uses: actions/setup-python@v6
+ - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
+ - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
with:
python-version: "3.12"
- name: Extract a sample with no optional deps installed
@@ -65,8 +65,8 @@ jobs:
name: security (bandit + zizmor)
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v6
- - uses: actions/setup-python@v6
+ - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
+ - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
with:
python-version: "3.12"
- name: Install scanners
@@ -75,9 +75,9 @@ jobs:
# Hard gate: only HIGH-severity / MEDIUM-confidence findings fail CI, to
# avoid blocking on the known-acceptable subprocess (pip install) calls.
# Ratchet down to medium once the open B314 docx-XML finding is hardened.
- run: bandit -q -r scripts tools --severity-level high --confidence-level medium
+ run: bandit -q -r book_to_skill scripts tools --severity-level high --confidence-level medium
- name: Bandit — report MEDIUM+ (informational)
- run: bandit -q -r scripts tools -ll || true
+ run: bandit -q -r book_to_skill scripts tools -ll || true
- name: Zizmor — workflow audit (informational)
# Surfaces GitHub Actions risks (injection, pull_request_target misuse).
# Currently only flags unpinned-uses (tags vs SHA) — non-blocking until
@@ -88,8 +88,8 @@ jobs:
name: validate SKILL.md (Claude Code rules)
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v6
- - uses: actions/setup-python@v6
+ - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
+ - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
with:
python-version: "3.12"
- name: Audit SKILL.md against Claude Code skill rules
diff --git a/.gitignore b/.gitignore
index e1cf15b..350bc30 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,11 @@ __pycache__/
# Agent session traces (Stone CLI) — never commit
.stone/
**/.stone/
+
+# PyPI packaging build directories
+dist/
+build/
+*.egg-info/
+
+# Local design specifications
+docs/superpowers/specs/
diff --git a/book_to_skill/__init__.py b/book_to_skill/__init__.py
new file mode 100644
index 0000000..d770d75
--- /dev/null
+++ b/book_to_skill/__init__.py
@@ -0,0 +1,4 @@
+from book_to_skill.utils import resolve_input_files, extract_single_file, main
+from book_to_skill.exceptions import ExtractionError
+
+__all__ = ["resolve_input_files", "extract_single_file", "main", "ExtractionError"]
diff --git a/book_to_skill/__main__.py b/book_to_skill/__main__.py
new file mode 100644
index 0000000..42140f4
--- /dev/null
+++ b/book_to_skill/__main__.py
@@ -0,0 +1,4 @@
+from book_to_skill.cli import main
+
+if __name__ == "__main__":
+ main()
diff --git a/book_to_skill/cli.py b/book_to_skill/cli.py
new file mode 100644
index 0000000..439bb8d
--- /dev/null
+++ b/book_to_skill/cli.py
@@ -0,0 +1,16 @@
+import sys
+from book_to_skill.utils import main as utils_main
+
+def main():
+ # Force UTF-8 stdout/stderr to avoid UnicodeEncodeError on Windows console
+ for _stream in (sys.stdout, sys.stderr):
+ try:
+ _stream.reconfigure(encoding="utf-8")
+ except (AttributeError, ValueError):
+ # Ignore if the stream does not support reconfigure (e.g. mock streams during testing)
+ pass
+ utils_main()
+
+# Expose main for packaging console scripts entry points
+if __name__ == "__main__":
+ main()
diff --git a/scripts/extractor/config.py b/book_to_skill/config.py
similarity index 100%
rename from scripts/extractor/config.py
rename to book_to_skill/config.py
diff --git a/scripts/extractor/dependencies.py b/book_to_skill/dependencies.py
similarity index 99%
rename from scripts/extractor/dependencies.py
rename to book_to_skill/dependencies.py
index f48c88b..cab0b8a 100644
--- a/scripts/extractor/dependencies.py
+++ b/book_to_skill/dependencies.py
@@ -5,7 +5,7 @@ import os
import shutil
import subprocess
import sys
-from extractor.config import PYTHON_DEPENDENCIES, HTML_EXTENSIONS
+from book_to_skill.config import PYTHON_DEPENDENCIES, HTML_EXTENSIONS
# Ordered groups for the --check preflight report. Each entry describes one
diff --git a/scripts/extractor/exceptions.py b/book_to_skill/exceptions.py
similarity index 100%
rename from scripts/extractor/exceptions.py
rename to book_to_skill/exceptions.py
diff --git a/scripts/extractor/parsers/__init__.py b/book_to_skill/parsers/__init__.py
similarity index 100%
rename from scripts/extractor/parsers/__init__.py
rename to book_to_skill/parsers/__init__.py
diff --git a/scripts/extractor/parsers/calibre.py b/book_to_skill/parsers/calibre.py
similarity index 94%
rename from scripts/extractor/parsers/calibre.py
rename to book_to_skill/parsers/calibre.py
index d43766a..f182ae0 100644
--- a/scripts/extractor/parsers/calibre.py
+++ b/book_to_skill/parsers/calibre.py
@@ -3,7 +3,7 @@ from __future__ import annotations
import shutil
import subprocess
import sys
-from extractor.config import OUTPUT_DIR
+from book_to_skill.config import OUTPUT_DIR
def extract_with_ebook_convert(input_path: str) -> str | None:
diff --git a/scripts/extractor/parsers/docx.py b/book_to_skill/parsers/docx.py
similarity index 97%
rename from scripts/extractor/parsers/docx.py
rename to book_to_skill/parsers/docx.py
index c570b27..08d7685 100644
--- a/scripts/extractor/parsers/docx.py
+++ b/book_to_skill/parsers/docx.py
@@ -2,7 +2,7 @@ from __future__ import annotations
import zipfile
import sys
-from extractor.exceptions import ExtractionError
+from book_to_skill.exceptions import ExtractionError
def extract_docx_with_python_docx(docx_path: str) -> str | None:
diff --git a/scripts/extractor/parsers/epub.py b/book_to_skill/parsers/epub.py
similarity index 98%
rename from scripts/extractor/parsers/epub.py
rename to book_to_skill/parsers/epub.py
index f60c5d2..71c7403 100644
--- a/scripts/extractor/parsers/epub.py
+++ b/book_to_skill/parsers/epub.py
@@ -4,7 +4,7 @@ import posixpath
import re
import zipfile
import sys
-from extractor.parsers.html import _HTMLTextExtractor
+from book_to_skill.parsers.html import _HTMLTextExtractor
def extract_with_ebooklib(epub_path: str) -> str | None:
diff --git a/scripts/extractor/parsers/html.py b/book_to_skill/parsers/html.py
similarity index 96%
rename from scripts/extractor/parsers/html.py
rename to book_to_skill/parsers/html.py
index 5133f7b..72af1a1 100644
--- a/scripts/extractor/parsers/html.py
+++ b/book_to_skill/parsers/html.py
@@ -2,7 +2,7 @@ from __future__ import annotations
import html
import html.parser
-from extractor.parsers.text import read_text_file
+from book_to_skill.parsers.text import read_text_file
class _HTMLTextExtractor(html.parser.HTMLParser):
diff --git a/scripts/extractor/parsers/pdf.py b/book_to_skill/parsers/pdf.py
similarity index 100%
rename from scripts/extractor/parsers/pdf.py
rename to book_to_skill/parsers/pdf.py
diff --git a/scripts/extractor/parsers/rtf.py b/book_to_skill/parsers/rtf.py
similarity index 89%
rename from scripts/extractor/parsers/rtf.py
rename to book_to_skill/parsers/rtf.py
index 06cab49..e765559 100644
--- a/scripts/extractor/parsers/rtf.py
+++ b/book_to_skill/parsers/rtf.py
@@ -1,8 +1,8 @@
import html
import re
import sys
-from extractor.parsers.text import read_text_file
-from extractor.exceptions import ExtractionError
+from book_to_skill.parsers.text import read_text_file
+from book_to_skill.exceptions import ExtractionError
def strip_rtf_fallback(raw: str) -> str:
diff --git a/scripts/extractor/parsers/text.py b/book_to_skill/parsers/text.py
similarity index 100%
rename from scripts/extractor/parsers/text.py
rename to book_to_skill/parsers/text.py
diff --git a/scripts/extractor/utils.py b/book_to_skill/utils.py
similarity index 97%
rename from scripts/extractor/utils.py
rename to book_to_skill/utils.py
index 12dbff0..78f671d 100644
--- a/scripts/extractor/utils.py
+++ b/book_to_skill/utils.py
@@ -9,9 +9,9 @@ import shutil
import zipfile
from pathlib import Path
-from extractor.exceptions import ExtractionError
+from book_to_skill.exceptions import ExtractionError
-from extractor.config import (
+from book_to_skill.config import (
OUTPUT_DIR,
OUTPUT_TEXT,
OUTPUT_META,
@@ -22,24 +22,24 @@ from extractor.config import (
CALIBRE_EBOOK_EXTENSIONS,
supported_formats_message,
)
-from extractor.dependencies import (
+from book_to_skill.dependencies import (
normalize_install_mode,
prepare_dependencies,
run_dependency_check,
)
-from extractor.parsers.text import read_text_file
-from extractor.parsers.html import extract_html_file
-from extractor.parsers.docx import extract_docx
-from extractor.parsers.rtf import extract_rtf
-from extractor.parsers.calibre import extract_with_ebook_convert
-from extractor.parsers.pdf import (
+from book_to_skill.parsers.text import read_text_file
+from book_to_skill.parsers.html import extract_html_file
+from book_to_skill.parsers.docx import extract_docx
+from book_to_skill.parsers.rtf import extract_rtf
+from book_to_skill.parsers.calibre import extract_with_ebook_convert
+from book_to_skill.parsers.pdf import (
extract_with_docling,
extract_with_pdftotext,
extract_with_pypdf2,
extract_with_pdfminer,
count_pages,
)
-from extractor.parsers.epub import (
+from book_to_skill.parsers.epub import (
extract_with_ebooklib,
extract_with_zipfile,
count_epub_chapters,
@@ -547,7 +547,7 @@ def extract_single_file(input_path: Path, extraction_mode: str, install_mode: st
def print_banner() -> None:
"""Print the attribution banner. Done here (not only in SKILL.md) so it
shows on every run regardless of how the agent invokes extraction."""
- banner = Path(__file__).resolve().parent.parent / "banner.txt"
+ banner = Path(__file__).resolve().parent.parent / "scripts" / "banner.txt"
try:
sys.stderr.write(banner.read_text(encoding="utf-8") + "\n")
except Exception:
diff --git a/pyproject.toml b/pyproject.toml
index e791df3..79b6d33 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,11 +1,34 @@
+[build-system]
+requires = ["hatchling"]
+build-backend = "hatchling.build"
+
[project]
name = "book-to-skill"
-version = "1.1.0"
+version = "1.2.0"
description = "Convert books and documents into structured, on-demand agent skills."
readme = "README.md"
requires-python = ">=3.9"
license = { text = "MIT" }
+[project.scripts]
+book-to-skill = "book_to_skill.cli:main"
+
+[project.optional-dependencies]
+epub = ["ebooklib", "beautifulsoup4"]
+pdf = ["PyPDF2", "pdfminer.six"]
+docx = ["python-docx"]
+rtf = ["striprtf"]
+technical = ["docling"]
+all = [
+ "ebooklib",
+ "beautifulsoup4",
+ "PyPDF2",
+ "pdfminer.six",
+ "python-docx",
+ "striprtf",
+ "docling"
+]
+
# Tooling config so `ruff check .` and `pytest` locally match CI without flags.
[tool.ruff]
target-version = "py39"
diff --git a/scripts/extract.py b/scripts/extract.py
index a76aa48..ca6d75e 100644
--- a/scripts/extract.py
+++ b/scripts/extract.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""
Extract text from a document file for book-to-skill processing.
-Modular entrypoint wrapper.
+Backward-compatible entrypoint wrapper.
"""
import os
@@ -16,11 +16,11 @@ for _stream in (sys.stdout, sys.stderr):
except (AttributeError, ValueError):
pass
-# Ensure the scripts/ directory (where the 'extractor' package lives) is in sys.path
+# Ensure the project root directory (where the 'book_to_skill' package lives) is in sys.path
# so the modular package can be imported reliably regardless of the working directory.
-sys.path.insert(0, str(os.path.dirname(os.path.abspath(__file__))))
+sys.path.insert(0, str(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
-from extractor.utils import main
+from book_to_skill.cli import main
if __name__ == "__main__":
main()
diff --git a/scripts/extractor/__init__.py b/scripts/extractor/__init__.py
deleted file mode 100644
index 9bcf04d..0000000
--- a/scripts/extractor/__init__.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from extractor.utils import resolve_input_files, extract_single_file, main
-from extractor.exceptions import ExtractionError
-
-__all__ = ["resolve_input_files", "extract_single_file", "main", "ExtractionError"]
diff --git a/tests/test_extractor.py b/tests/test_book_to_skill.py
similarity index 94%
rename from tests/test_extractor.py
rename to tests/test_book_to_skill.py
index 3fda846..beccabd 100644
--- a/tests/test_extractor.py
+++ b/tests/test_book_to_skill.py
@@ -1,5 +1,5 @@
"""
-Test suite for the three PR blocker fixes + nits in the extractor package.
+Test suite for the three PR blocker fixes + nits in the book_to_skill package.
Covers:
Fix #1 — EPUB extraction tuple-unpack regression
@@ -18,13 +18,13 @@ from unittest import mock
import pytest
# ---------------------------------------------------------------------------
-# Bootstrap: make sure the extractor package is importable
+# Bootstrap: make sure the book_to_skill package is importable
# ---------------------------------------------------------------------------
-SCRIPTS_DIR = Path(__file__).resolve().parent.parent / "scripts"
-sys.path.insert(0, str(SCRIPTS_DIR))
+ROOT_DIR = Path(__file__).resolve().parent.parent
+sys.path.insert(0, str(ROOT_DIR))
-from extractor.exceptions import ExtractionError
-from extractor.utils import (
+from book_to_skill.exceptions import ExtractionError
+from book_to_skill.utils import (
resolve_input_files,
extract_single_file,
parse_arguments,
@@ -33,7 +33,7 @@ from extractor.utils import (
_cn_numeral_to_int,
main,
)
-from extractor.config import SUPPORTED_EXTENSIONS
+from book_to_skill.config import SUPPORTED_EXTENSIONS
# ═══════════════════════════════════════════════════════════════════════════
@@ -175,7 +175,7 @@ class TestEpubExtractionFix:
def test_epub_extract_with_ebooklib_returns_str_or_none(self):
"""extract_with_ebooklib returns str|None, NOT a tuple."""
- from extractor.parsers.epub import extract_with_ebooklib
+ from book_to_skill.parsers.epub import extract_with_ebooklib
# With ebooklib likely not installed in test env → returns None
result = extract_with_ebooklib("nonexistent.epub")
@@ -188,7 +188,7 @@ class TestEpubExtractionFix:
epub_path = _make_minimal_epub(tmp_path / "test.epub")
# Mock prepare_dependencies to be a no-op
- with mock.patch("extractor.utils.prepare_dependencies"):
+ with mock.patch("book_to_skill.utils.prepare_dependencies"):
result = extract_single_file(epub_path, "text", "no")
assert result["format"] == "epub"
@@ -202,7 +202,7 @@ class TestEpubExtractionFix:
epub_path = _make_minimal_epub(tmp_path / "test.epub")
# Even if ebooklib is absent, this should NOT raise TypeError/ValueError
- with mock.patch("extractor.utils.prepare_dependencies"):
+ with mock.patch("book_to_skill.utils.prepare_dependencies"):
try:
result = extract_single_file(epub_path, "text", "no")
except (TypeError, ValueError) as exc:
@@ -220,7 +220,7 @@ class TestEpubOpfRelativePaths:
def test_zipfile_fallback_resolves_oebps_paths(self, tmp_path):
"""The core bug: hrefs in OPF are relative to OPF dir, not archive root."""
- from extractor.parsers.epub import extract_with_zipfile
+ from book_to_skill.parsers.epub import extract_with_zipfile
epub_path = _make_oebps_epub(tmp_path / "oebps.epub")
text = extract_with_zipfile(str(epub_path))
@@ -233,7 +233,7 @@ class TestEpubOpfRelativePaths:
"""End-to-end: extract_single_file should succeed with OEBPS layout."""
epub_path = _make_oebps_epub(tmp_path / "test_oebps.epub")
- with mock.patch("extractor.utils.prepare_dependencies"):
+ with mock.patch("book_to_skill.utils.prepare_dependencies"):
result = extract_single_file(epub_path, "text", "no")
assert result["format"] == "epub"
@@ -243,7 +243,7 @@ class TestEpubOpfRelativePaths:
def test_container_xml_locates_opf(self, tmp_path):
"""_find_opf_path should prefer META-INF/container.xml over globbing."""
- from extractor.parsers.epub import _find_opf_path
+ from book_to_skill.parsers.epub import _find_opf_path
epub_path = _make_oebps_epub(tmp_path / "container.epub")
with zipfile.ZipFile(epub_path) as zf:
@@ -253,7 +253,7 @@ class TestEpubOpfRelativePaths:
def test_count_chapters_with_oebps(self, tmp_path):
"""count_epub_chapters should work with OPF in subdirectory."""
- from extractor.parsers.epub import count_epub_chapters
+ from book_to_skill.parsers.epub import count_epub_chapters
epub_path = _make_oebps_epub(tmp_path / "chapters.epub")
count = count_epub_chapters(str(epub_path))
@@ -261,7 +261,7 @@ class TestEpubOpfRelativePaths:
def test_root_level_opf_still_works(self, tmp_path):
"""Regression check: root-level OPF (no subdirectory) should still work."""
- from extractor.parsers.epub import extract_with_zipfile
+ from book_to_skill.parsers.epub import extract_with_zipfile
epub_path = _make_minimal_epub(tmp_path / "root_opf.epub")
text = extract_with_zipfile(str(epub_path))
@@ -303,7 +303,7 @@ class TestBatchResilience:
for fp in input_files:
try:
- with mock.patch("extractor.utils.prepare_dependencies"):
+ with mock.patch("book_to_skill.utils.prepare_dependencies"):
res = extract_single_file(fp, "text", "no")
extracted.append(res)
except ExtractionError as exc:
@@ -322,7 +322,7 @@ class TestBatchResilience:
"sys.argv",
["extract.py", str(bad1), str(bad2), "--install-missing", "no"],
)
- monkeypatch.setattr("extractor.utils.prepare_dependencies", lambda *a: None)
+ monkeypatch.setattr("book_to_skill.utils.prepare_dependencies", lambda *a: None)
with pytest.raises(SystemExit) as exc_info:
main()
@@ -346,10 +346,10 @@ class TestBatchResilience:
# So we patch the OUTPUT_* in utils directly
out_text = out_dir / "full_text.txt"
out_meta = out_dir / "metadata.json"
- monkeypatch.setattr("extractor.utils.OUTPUT_DIR", out_dir)
- monkeypatch.setattr("extractor.utils.OUTPUT_TEXT", out_text)
- monkeypatch.setattr("extractor.utils.OUTPUT_META", out_meta)
- monkeypatch.setattr("extractor.utils.prepare_dependencies", lambda *a: None)
+ monkeypatch.setattr("book_to_skill.utils.OUTPUT_DIR", out_dir)
+ monkeypatch.setattr("book_to_skill.utils.OUTPUT_TEXT", out_text)
+ monkeypatch.setattr("book_to_skill.utils.OUTPUT_META", out_meta)
+ monkeypatch.setattr("book_to_skill.utils.prepare_dependencies", lambda *a: None)
main()
@@ -815,7 +815,7 @@ class TestTextExtraction:
def test_extract_txt_file(self, tmp_path):
txt = _make_text_file(tmp_path / "simple.txt", "Simple text content for testing.")
- with mock.patch("extractor.utils.prepare_dependencies"):
+ with mock.patch("book_to_skill.utils.prepare_dependencies"):
result = extract_single_file(txt, "text", "no")
assert result["format"] == "txt"
@@ -825,7 +825,7 @@ class TestTextExtraction:
def test_extract_md_file(self, tmp_path):
md = _make_md_file(tmp_path / "notes.md", "# My Notes\n\nSome notes here.")
- with mock.patch("extractor.utils.prepare_dependencies"):
+ with mock.patch("book_to_skill.utils.prepare_dependencies"):
result = extract_single_file(md, "text", "no")
assert result["format"] == "md"
@@ -838,7 +838,7 @@ class TestHtmlExtraction:
def test_extract_html_file(self, tmp_path):
html_file = _make_html_file(tmp_path / "page.html")
- with mock.patch("extractor.utils.prepare_dependencies"):
+ with mock.patch("book_to_skill.utils.prepare_dependencies"):
result = extract_single_file(html_file, "text", "no")
assert result["format"] == "html"
@@ -852,7 +852,7 @@ class TestDocxExtraction:
def test_extract_docx_zipfile_fallback(self, tmp_path):
docx = _make_minimal_docx(tmp_path / "test.docx")
- with mock.patch("extractor.utils.prepare_dependencies"):
+ with mock.patch("book_to_skill.utils.prepare_dependencies"):
result = extract_single_file(docx, "text", "no")
assert result["format"] == "docx"
@@ -891,10 +891,10 @@ class TestDependencyCheck:
"""Tests for the --check preflight (run_dependency_check)."""
def test_all_present_reports_ready(self, capsys):
- from extractor.dependencies import run_dependency_check
+ from book_to_skill.dependencies import run_dependency_check
- with mock.patch("extractor.dependencies.python_module_available", return_value=True), \
- mock.patch("extractor.dependencies.shutil.which", return_value="/usr/bin/tool"):
+ with mock.patch("book_to_skill.dependencies.python_module_available", return_value=True), \
+ mock.patch("book_to_skill.dependencies.shutil.which", return_value="/usr/bin/tool"):
code = run_dependency_check()
out = capsys.readouterr().out
@@ -903,10 +903,10 @@ class TestDependencyCheck:
assert "✗" not in out
def test_all_missing_lists_install_commands(self, capsys):
- from extractor.dependencies import run_dependency_check
+ from book_to_skill.dependencies import run_dependency_check
- with mock.patch("extractor.dependencies.python_module_available", return_value=False), \
- mock.patch("extractor.dependencies.shutil.which", return_value=None):
+ with mock.patch("book_to_skill.dependencies.python_module_available", return_value=False), \
+ mock.patch("book_to_skill.dependencies.shutil.which", return_value=None):
code = run_dependency_check()
out = capsys.readouterr().out
@@ -921,13 +921,13 @@ class TestDependencyCheck:
def test_pdftotext_alone_satisfies_pdf_text(self, capsys):
"""pdftotext present (system) should mark PDF text-heavy ready even with no python PDF libs."""
- from extractor.dependencies import run_dependency_check
+ from book_to_skill.dependencies import run_dependency_check
def which(cmd):
return "/usr/bin/pdftotext" if cmd == "pdftotext" else None
- with mock.patch("extractor.dependencies.python_module_available", return_value=False), \
- mock.patch("extractor.dependencies.shutil.which", side_effect=which):
+ with mock.patch("book_to_skill.dependencies.python_module_available", return_value=False), \
+ mock.patch("book_to_skill.dependencies.shutil.which", side_effect=which):
run_dependency_check()
out = capsys.readouterr().out
@@ -945,7 +945,7 @@ class TestParserExceptionLogging:
def test_pypdf2_warns_on_unexpected_error_and_returns_none(self, tmp_path, capsys):
"""Monkeypatch pypdf2 import to raise; confirm None + stderr warning."""
- from extractor.parsers.pdf import extract_with_pypdf2
+ from book_to_skill.parsers.pdf import extract_with_pypdf2
broken = tmp_path / "broken.pdf"
broken.write_bytes(b"%PDF-1.4 fake")
diff --git a/tools/discovery_tax.py b/tools/discovery_tax.py
index 7c2ff7c..3e2fff5 100644
--- a/tools/discovery_tax.py
+++ b/tools/discovery_tax.py
@@ -38,8 +38,8 @@ from pathlib import Path
# Reuse the extractor's hardened chapter detection instead of duplicating it, so
# discovery_tax and the pipeline always agree on what a chapter is (Arabic +
# Roman headings, prose/cross-reference rejection, list-item rejection).
-sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts"))
-from extractor.utils import _chapter_number as chapter_number # noqa: E402
+sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
+from book_to_skill.utils import _chapter_number as chapter_number # noqa: E402
TOC_RE = re.compile(r"^\s*(?:sum[áa]rio|table of contents|contents|[íi]ndice)\s*$",
re.IGNORECASE | re.MULTILINE)