Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: refactor building steps #33

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/unit.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: Build

on:
- push
- pull_request
push:
branches:
- main
pull_request:

jobs:
lint:
Expand Down
8 changes: 4 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def docs(session):
session.install(".[doc]")
b = session.posargs[0] if session.posargs else "html"
dst = Path(__file__).parent / "docs" / "_build" / b
session.run("sphinx-build", f"-b={b}", "-a", "-E", "docs", str(dst))
session.run("sphinx-build", f"-b={b}", "-a", "-E", "docs", dst.resolve())


@nox.session(reuse_venv=True)
Expand All @@ -34,6 +34,6 @@ def mypy(session):
@nox.session(reuse_venv=True)
def test(session):
"""Run all the test using the environment varialbe of the running machine."""
session.install("--verbose", ".[test]")
# session.run("pytest", "--color=yes", "--cov", "--cov-report=html", *test_files)
session.run("sphinx-build", "--bug-report")
session.install(".[test]")
test_files = session.posargs or ["tests"]
session.run("pytest", "--color=yes", "--cov", "--cov-report=xml", *test_files)
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ test = [
"pytest",
"beautifulsoup4",
"pytest-regressions",
"pytest-cov"
"pytest-cov",
"defusedxml",
]
doc = [
"pydata-sphinx-theme",
Expand Down Expand Up @@ -88,6 +89,8 @@ convention = "google"

[tool.coverage.run]
source = ["sphinxcontrib.icon"]
branch = true
relative_files = true

[tool.mypy]
scripts_are_modules = true
Expand Down
37 changes: 5 additions & 32 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

from pynpm import NPMPackage
from setuptools import Command, setup
from setuptools.command.build_py import build_py
from setuptools.command.egg_info import egg_info
from setuptools.command.sdist import sdist

ROOT = Path(__file__).parent

Expand All @@ -16,8 +14,7 @@

def update_package_data(distribution) -> None:
"""Update package_data to catch changes during setup."""
build_py = distribution.get_command_obj("build_py")
build_py.finalize_options()
distribution.get_command_obj("build_py").finalize_options()


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

def run(self) -> None:
"""Run the command."""
self.distribution.run_command("jsdeps")
command.run(self)
package = ROOT / "sphinxcontrib" / "icon" / "package.json"
NPMPackage(package.resolve(), shell=is_windows).install()
update_package_data(self.distribution)
command.run(self)

return DecoratedCommand


class NPM(Command):
"""install package.json dependencies using npm."""

def initialize_options(self):
"""Ignore initialize_options."""
pass

def finalize_options(self):
"""Ignore finalize_options."""
pass

def run(self):
"""Run the command."""
package = ROOT / "sphinxcontrib" / "icon" / "package.json"
NPMPackage(str(package), shell=is_windows).install()
update_package_data(self.distribution)


setup(
cmdclass={
"build_py": js_prerelease(build_py),
"egg_info": js_prerelease(egg_info),
"sdist": js_prerelease(sdist, strict=True),
"jsdeps": NPM,
}
)
setup(cmdclass={"egg_info": js_prerelease(egg_info)})
1 change: 0 additions & 1 deletion sphinxcontrib/icon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def setup(app: Sphinx) -> Dict[str, Any]:
font_handler = Fontawesome()

# install html related files
raise Exception(str(font_handler.css_file.resolve()))
app.add_css_file(str(font_handler.css_file.resolve()))
app.add_js_file(str(font_handler.js_file.resolve()))

Expand Down
2 changes: 1 addition & 1 deletion sphinxcontrib/icon/font_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def add_latex_font_files(self, app: Sphinx) -> None:
dst = Path(app.builder.outdir) / f.name
logger.info(f"Writing: {f.name}")
ensuredir(app.builder.outdir)
copyfile(str(f), str(dst))
copyfile(f.resolve(), dst.resolve())

def add_latex_font(self, app: Sphinx, config: Config) -> None:
"""Add the fontawesome fontfamily in the preamble of the .tex file."""
Expand Down
18 changes: 14 additions & 4 deletions sphinxcontrib/icon/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading