mirror of https://github.com/streamlink/streamlink
build: build and include plugins JSON in wheels
This commit is contained in:
parent
7462ad5cf1
commit
115c2ed486
|
@ -0,0 +1,34 @@
|
|||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Dict, Type
|
||||
|
||||
from setuptools import Command
|
||||
from setuptools.command.build_py import build_py
|
||||
|
||||
from build_backend.plugins_json import build, to_json
|
||||
|
||||
|
||||
STREAMLINK_PLUGINS_JSON = Path("streamlink", "plugins", "_plugins.json")
|
||||
|
||||
|
||||
__all__ = ["cmdclass"]
|
||||
|
||||
|
||||
class StreamlinkBuildPyCommand(build_py, Command):
|
||||
def _build_plugins_json(self) -> None:
|
||||
self.announce("building plugins JSON data", logging.INFO)
|
||||
output = Path(self.build_lib) / STREAMLINK_PLUGINS_JSON
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
data = build()
|
||||
with output.open("w", encoding="utf-8") as fd:
|
||||
to_json(data, fd)
|
||||
|
||||
def build_package_data(self) -> None:
|
||||
super().build_package_data()
|
||||
|
||||
self._build_plugins_json()
|
||||
|
||||
|
||||
cmdclass: Dict[str, Type[Command]] = {
|
||||
"build_py": StreamlinkBuildPyCommand,
|
||||
}
|
|
@ -91,6 +91,9 @@ namespaces = false
|
|||
streamlink = [
|
||||
"py.typed",
|
||||
]
|
||||
"streamlink.plugins" = [
|
||||
"_plugins.json",
|
||||
]
|
||||
|
||||
|
||||
# https://versioningit.readthedocs.io/en/stable/index.html
|
||||
|
@ -141,6 +144,7 @@ source = [
|
|||
|
||||
[tool.coverage.report]
|
||||
omit = [
|
||||
"build_backend/commands.py",
|
||||
"src/streamlink/packages/*",
|
||||
"src/streamlink/webbrowser/cdp/devtools/*",
|
||||
"src/streamlink_cli/packages/*",
|
||||
|
|
12
setup.py
12
setup.py
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
import sys
|
||||
from os import path
|
||||
from sys import argv, exit, version_info
|
||||
from textwrap import dedent
|
||||
|
@ -73,17 +74,20 @@ data_files = [
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from setuptools import setup # type: ignore[import]
|
||||
sys.path.insert(0, path.dirname(__file__))
|
||||
|
||||
from build_backend.commands import cmdclass
|
||||
from setuptools import setup
|
||||
|
||||
try:
|
||||
# versioningit is only required when building from git (see pyproject.toml)
|
||||
from versioningit import get_cmdclasses
|
||||
except ImportError: # pragma: no cover
|
||||
def get_cmdclasses(): # type: ignore
|
||||
return {}
|
||||
def get_cmdclasses(_): # type: ignore[misc]
|
||||
return _
|
||||
|
||||
setup(
|
||||
cmdclass=get_cmdclasses(),
|
||||
cmdclass=get_cmdclasses(cmdclass),
|
||||
entry_points=entry_points,
|
||||
data_files=data_files,
|
||||
# version="", # static version string template, uncommented and substituted by versioningit's onbuild hook
|
||||
|
|
Loading…
Reference in New Issue