Skip to content

Commit 7fe53a1

Browse files
committed
build: refactor building steps
1 parent cee2152 commit 7fe53a1

File tree

5 files changed

+26
-41
lines changed

5 files changed

+26
-41
lines changed

noxfile.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ def mypy(session):
3434
@nox.session(reuse_venv=True)
3535
def test(session):
3636
"""Run all the test using the environment varialbe of the running machine."""
37-
session.install("--verbose", ".[test]")
38-
# session.run("pytest", "--color=yes", "--cov", "--cov-report=html", *test_files)
39-
session.run("sphinx-build", "--bug-report")
37+
session.install(".[test]")
38+
test_files = session.posargs or ["tests"]
39+
session.run("pytest", "--color=yes", "--cov", "--cov-report=xml", *test_files)

pyproject.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ test = [
4848
"pytest",
4949
"beautifulsoup4",
5050
"pytest-regressions",
51-
"pytest-cov"
51+
"pytest-cov",
52+
"defusedxml",
5253
]
5354
doc = [
5455
"pydata-sphinx-theme",
@@ -88,6 +89,8 @@ convention = "google"
8889

8990
[tool.coverage.run]
9091
source = ["sphinxcontrib.icon"]
92+
branch = true
93+
relative_files = true
9194

9295
[tool.mypy]
9396
scripts_are_modules = true

setup.py

+5-32
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
from pynpm import NPMPackage
55
from setuptools import Command, setup
6-
from setuptools.command.build_py import build_py
76
from setuptools.command.egg_info import egg_info
8-
from setuptools.command.sdist import sdist
97

108
ROOT = Path(__file__).parent
119

@@ -16,8 +14,7 @@
1614

1715
def update_package_data(distribution) -> None:
1816
"""Update package_data to catch changes during setup."""
19-
build_py = distribution.get_command_obj("build_py")
20-
build_py.finalize_options()
17+
distribution.get_command_obj("build_py").finalize_options()
2118

2219

2320
def js_prerelease(command: Command, strict: bool = False) -> Command:
@@ -28,36 +25,12 @@ class DecoratedCommand(command):
2825

2926
def run(self) -> None:
3027
"""Run the command."""
31-
self.distribution.run_command("jsdeps")
32-
command.run(self)
28+
package = ROOT / "sphinxcontrib" / "icon" / "package.json"
29+
NPMPackage(str(package), shell=is_windows).install()
3330
update_package_data(self.distribution)
31+
command.run(self)
3432

3533
return DecoratedCommand
3634

3735

38-
class NPM(Command):
39-
"""install package.json dependencies using npm."""
40-
41-
def initialize_options(self):
42-
"""Ignore initialize_options."""
43-
pass
44-
45-
def finalize_options(self):
46-
"""Ignore finalize_options."""
47-
pass
48-
49-
def run(self):
50-
"""Run the command."""
51-
package = ROOT / "sphinxcontrib" / "icon" / "package.json"
52-
NPMPackage(str(package), shell=is_windows).install()
53-
update_package_data(self.distribution)
54-
55-
56-
setup(
57-
cmdclass={
58-
"build_py": js_prerelease(build_py),
59-
"egg_info": js_prerelease(egg_info),
60-
"sdist": js_prerelease(sdist, strict=True),
61-
"jsdeps": NPM,
62-
}
63-
)
36+
setup(cmdclass={"egg_info": js_prerelease(egg_info)})

sphinxcontrib/icon/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def setup(app: Sphinx) -> Dict[str, Any]:
2222
font_handler = Fontawesome()
2323

2424
# install html related files
25-
raise Exception(str(font_handler.css_file.resolve()))
2625
app.add_css_file(str(font_handler.css_file.resolve()))
2726
app.add_js_file(str(font_handler.js_file.resolve()))
2827

sphinxcontrib/icon/package-lock.json

+14-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)