mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
better setup.py
This commit is contained in:
parent
374ff9cf9e
commit
f1c86cca4f
36
setup.py
36
setup.py
@ -24,16 +24,27 @@
|
|||||||
import os
|
import os
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
import setuptools.command.easy_install
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
from setuptools.command.easy_install import ScriptWriter
|
|
||||||
|
|
||||||
|
|
||||||
# =====
|
# =====
|
||||||
def main() -> None:
|
class _ScriptWriter(setuptools.command.easy_install.ScriptWriter):
|
||||||
|
template = textwrap.dedent("""
|
||||||
|
# EASY-INSTALL-ENTRY-SCRIPT: {spec},{group},{name}
|
||||||
|
|
||||||
|
__requires__ = "{spec}"
|
||||||
|
|
||||||
|
from {module} import main
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
""").strip()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
def get_args(cls, dist, header=None): # type: ignore
|
def get_args(cls, dist, header=None): # type: ignore
|
||||||
if header is None:
|
if header is None:
|
||||||
header = cls.get_header()
|
header = cls.get_header()
|
||||||
|
|
||||||
spec = str(dist.as_requirement())
|
spec = str(dist.as_requirement())
|
||||||
for group_type in ["console", "gui"]:
|
for group_type in ["console", "gui"]:
|
||||||
group = group_type + "_scripts"
|
group = group_type + "_scripts"
|
||||||
@ -45,21 +56,14 @@ def main() -> None:
|
|||||||
name=name,
|
name=name,
|
||||||
module=ep.module_name,
|
module=ep.module_name,
|
||||||
)
|
)
|
||||||
args = cls._get_script_args(group_type, name, header, script_text)
|
yield from cls._get_script_args(group_type, name, header, script_text)
|
||||||
for res in args:
|
|
||||||
yield res
|
|
||||||
|
|
||||||
ScriptWriter.get_args = classmethod(get_args)
|
|
||||||
ScriptWriter.template = textwrap.dedent("""
|
|
||||||
# EASY-INSTALL-ENTRY-SCRIPT: {spec},{group},{name}
|
|
||||||
|
|
||||||
__requires__ = "{spec}"
|
# =====
|
||||||
|
def main() -> None:
|
||||||
from {module} import main
|
setuptools.command.easy_install.ScriptWriter = _ScriptWriter
|
||||||
|
setuptools.command.easy_install.get_script_args = _ScriptWriter.get_script_args
|
||||||
if __name__ == "__main__":
|
setuptools.command.easy_install.get_script_header = _ScriptWriter.get_script_header
|
||||||
main()
|
|
||||||
""").strip()
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="kvmd",
|
name="kvmd",
|
||||||
|
|||||||
@ -3,8 +3,13 @@ _MassStorageDeviceInfo.product
|
|||||||
_MassStorageDeviceInfo.real
|
_MassStorageDeviceInfo.real
|
||||||
_MassStorageDeviceInfo.hw
|
_MassStorageDeviceInfo.hw
|
||||||
_MassStorageDeviceInfo.image
|
_MassStorageDeviceInfo.image
|
||||||
|
|
||||||
|
IpmiServer.handle_raw_request
|
||||||
|
|
||||||
fake_rpi.RPi.GPIO
|
fake_rpi.RPi.GPIO
|
||||||
|
|
||||||
_KeyMapping.kvmd_code
|
_KeyMapping.kvmd_code
|
||||||
_KeyMapping.arduino_hid_key
|
_KeyMapping.arduino_hid_key
|
||||||
_KeyMapping.web_key
|
_KeyMapping.web_key
|
||||||
IpmiServer.handle_raw_request
|
|
||||||
|
_ScriptWriter.get_args
|
||||||
|
|||||||
@ -8,14 +8,16 @@ sitepackages = true
|
|||||||
changedir = /src
|
changedir = /src
|
||||||
|
|
||||||
[testenv:flake8]
|
[testenv:flake8]
|
||||||
commands = flake8 --config=testenv/linters/flake8.ini kvmd genmap.py testenv/tests
|
whitelist_externals = bash
|
||||||
|
commands = bash -c 'flake8 --config=testenv/linters/flake8.ini kvmd testenv/tests *.py'
|
||||||
deps =
|
deps =
|
||||||
flake8
|
flake8
|
||||||
flake8-double-quotes
|
flake8-double-quotes
|
||||||
-rrequirements.txt
|
-rrequirements.txt
|
||||||
|
|
||||||
[testenv:pylint]
|
[testenv:pylint]
|
||||||
commands = pylint --rcfile=testenv/linters/pylint.ini --output-format=colorized --reports=no kvmd genmap.py testenv/tests
|
whitelist_externals = bash
|
||||||
|
commands = bash -c 'pylint --rcfile=testenv/linters/pylint.ini --output-format=colorized --reports=no kvmd testenv/tests *.py'
|
||||||
deps =
|
deps =
|
||||||
pylint
|
pylint
|
||||||
pytest
|
pytest
|
||||||
@ -24,13 +26,15 @@ deps =
|
|||||||
-rrequirements.txt
|
-rrequirements.txt
|
||||||
|
|
||||||
[testenv:mypy]
|
[testenv:mypy]
|
||||||
commands = mypy --config-file=testenv/linters/mypy.ini --cache-dir=testenv/.mypy_cache kvmd genmap.py testenv/tests
|
whitelist_externals = bash
|
||||||
|
commands = bash -c 'mypy --config-file=testenv/linters/mypy.ini --cache-dir=testenv/.mypy_cache kvmd testenv/tests *.py'
|
||||||
deps =
|
deps =
|
||||||
mypy
|
mypy
|
||||||
-rrequirements.txt
|
-rrequirements.txt
|
||||||
|
|
||||||
[testenv:vulture]
|
[testenv:vulture]
|
||||||
commands = vulture --ignore-names=_format_P,Plugin --ignore-decorators=@_exposed,@_system_task,@pytest.fixture kvmd genmap.py testenv/tests testenv/linters/vulture-wl.py
|
whitelist_externals = bash
|
||||||
|
commands = bash -c 'vulture --ignore-names=_format_P,Plugin --ignore-decorators=@_exposed,@_system_task,@pytest.fixture kvmd testenv/tests *.py testenv/linters/vulture-wl.py'
|
||||||
deps =
|
deps =
|
||||||
vulture
|
vulture
|
||||||
-rrequirements.txt
|
-rrequirements.txt
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user