Merge pull request #167630 from mweinelt/home-assistant

This commit is contained in:
Martin Weinelt 2022-04-12 04:05:59 +02:00 committed by GitHub
commit b794313d64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 3300 additions and 1052 deletions

View File

@ -28,18 +28,27 @@ buildPythonPackage rec {
};
propagatedBuildInputs = [
aiofiles
cryptography
libusb1
pyasn1
rsa
];
passthru.extras-require = {
async = [
aiofiles
];
usb = [
libusb1
];
};
checkInputs = [
mock
pycryptodome
pytestCheckHook
];
]
++ passthru.extras-require.async
++ passthru.extras-require.usb;
disabledTests = lib.optionals (pythonAtLeast "3.10") [
# Tests are failing with Python 3.10

View File

@ -25,14 +25,22 @@ buildPythonPackage rec {
propagatedBuildInputs = [
adb-shell
aiofiles
pure-python-adb
];
passthru.extras-require = {
async = [
aiofiles
];
inherit (adb-shell.extras-require) usb;
};
checkInputs = [
mock
pytestCheckHook
];
]
++ passthru.extras-require.async
++ passthru.extras-require.usb;
disabledTests = [
# Requires git but fails anyway

View File

@ -1,4 +1,10 @@
{ aiofiles, buildPythonPackage, fetchPypi, lib, pythonOlder }:
{ aiofiles
, buildPythonPackage
, fetchPypi
, lib
, pythonOlder
, pytestCheckHook
}:
buildPythonPackage rec {
pname = "pure-python-adb";
@ -11,11 +17,24 @@ buildPythonPackage rec {
sha256 = "0kdr7w2fhgjpcf1k3l6an9im583iqkr6v8hb4q1zw30nh3bqkk0f";
};
propagatedBuildInputs = [ aiofiles ];
# Disable tests as they require docker, docker-compose and a dedicated
# android emulator
doCheck = false;
pythonImportsCheck = [ "ppadb.client" "ppadb.client_async" ];
passthru.extras-require = {
async = [
aiofiles
];
};
doCheck = pythonOlder "3.10"; # all tests result in RuntimeError on 3.10
checkInputs = [
pytestCheckHook
]
++ passthru.extras-require.async;
pythonImportsCheck = [
"ppadb.client"
] ++ lib.optionals doCheck [
"ppadb.client_async"
];
meta = with lib; {
description = "Pure python implementation of the adb client";

View File

@ -0,0 +1,30 @@
{ lib
, buildPythonPackage
, fetchPypi
, pytestCheckHook
}:
let
pname = "py3rijndael";
version = "0.3.3";
in
buildPythonPackage {
inherit pname version;
format = "setuptools";
src = fetchPypi {
inherit pname version;
hash = "sha256-tmVaPr/zoQVA6u0EnoeI7qOsk9a3GzpqwrACJLvs6ag=";
};
checkInputs = [
pytestCheckHook
];
meta = with lib; {
description = "Rijndael algorithm library";
homepage = "https://github.com/meyt/py3rijndael";
license = licenses.mit;
maintainers = with maintainers; [ hexa ];
};
}

View File

@ -22,15 +22,19 @@ buildPythonPackage rec {
};
propagatedBuildInputs = [
pexpect
pyserial
];
passthru.extras-require.GATTTOOL = [
pexpect
];
checkInputs = [
mock
nose
pytestCheckHook
];
]
++ passthru.extras-require.GATTTOOL;
postPatch = ''
# Not support for Python < 3.4

View File

@ -21,14 +21,17 @@ buildPythonPackage rec {
hash = "sha256-12ol+2CnoPfkxmDGJJAkoafHGpQuWC4lh0N7lSvx2DE=";
};
propagatedBuildInputs = [
passthru.extras-require = {
async = [
aiocoap
dtlssocket
];
};
checkInputs = [
pytestCheckHook
];
]
++ passthru.extras-require.async;
pythonImportsCheck = [
"pytradfri"

View File

@ -1,4 +1,8 @@
{ lib, buildPythonPackage, fetchPypi
{ lib
, buildPythonPackage
, fetchPypi
# extra: websocket
, websocket-client
}:
@ -11,9 +15,12 @@ buildPythonPackage rec {
sha256 = "0ipz3fd65rqkxlb02sql0awc3vnslrwb2pfrsnpfnf8bfgxpbh9g";
};
propagatedBuildInputs = [
passthru.extras-require = {
websocket = [
websocket-client
];
# interactive_ui requires curses package
};
# no tests
doCheck = false;

View File

@ -1,29 +1,62 @@
{ lib, buildPythonPackage, fetchPypi, isPy27
, aiohttp
{ lib
, buildPythonPackage
, fetchFromGitHub
, isPy27
# propagates:
, requests
, websocket-client
# extras: async
, aiohttp
, websockets
# extras: encrypted
, cryptography
, py3rijndael
# tests
, aioresponses
, pytest-asyncio
, pytestCheckHook
}:
buildPythonPackage rec {
pname = "samsungtvws";
version = "2.5.0";
format = "setuptools";
disabled = isPy27;
src = fetchPypi {
inherit pname version;
sha256 = "sha256-AFCN1b80GZ24g3oWe1qqc72yWQy4+/sorL8zwOYM7vo=";
src = fetchFromGitHub {
owner = "xchwarze";
repo = "samsung-tv-ws-api";
rev = "v${version}";
hash = "sha256-AimG5tyTRBETpivC2BwCuoR4o7y98YT6u5sogJlcmoo=";
};
propagatedBuildInputs = [
aiohttp
requests
websocket-client
websockets
];
# no tests
doCheck = false;
passthru.extras-require = {
async = [
aiohttp
websockets
];
encrypted = [
cryptography
py3rijndael
];
};
checkInputs = [
aioresponses
pytest-asyncio
pytestCheckHook
]
++ passthru.extras-require.async
++ passthru.extras-require.encrypted;
pythonImportsCheck = [ "samsungtvws" ];

File diff suppressed because it is too large Load Diff

View File

@ -98,13 +98,37 @@ def get_reqs(components: Dict[str, Dict[str, Any]], component: str, processed: S
return requirements
def repository_root() -> str:
return os.path.abspath(sys.argv[0] + "/../../../..")
# For a package attribute and and an extra, check if the package exposes it via passthru.extras-require
def has_extra(package: str, extra: str):
cmd = [
"nix-instantiate",
repository_root(),
"-A",
f"{package}.extras-require.{extra}",
]
try:
subprocess.run(
cmd,
check=True,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
except subprocess.CalledProcessError:
return False
return True
def dump_packages() -> Dict[str, Dict[str, str]]:
# Store a JSON dump of Nixpkgs' python3Packages
output = subprocess.check_output(
[
"nix-env",
"-f",
os.path.dirname(sys.argv[0]) + "/../../..",
repository_root(),
"-qa",
"-A",
PKG_SET,
@ -158,6 +182,7 @@ def main() -> None:
outdated = {}
for component in sorted(components.keys()):
attr_paths = []
extra_attrs = []
missing_reqs = []
reqs = sorted(get_reqs(components, component, set()))
for req in reqs:
@ -165,9 +190,10 @@ def main() -> None:
# Therefore, if there's a "#" in the line, only take the part after it
req = req[req.find("#") + 1 :]
name, required_version = req.split("==", maxsplit=1)
# Remove extra_require from name, e.g. samsungctl instead of
# samsungctl[websocket]
# Split package name and extra requires
extras = []
if name.endswith("]"):
extras = name[name.find("[")+1:name.find("]")].split(",")
name = name[:name.find("[")]
attr_path = name_to_attr_path(name, packages)
if our_version := get_pkg_version(name, packages):
@ -178,11 +204,20 @@ def main() -> None:
}
if attr_path is not None:
# Add attribute path without "python3Packages." prefix
attr_paths.append(attr_path[len(PKG_SET + ".") :])
pname = attr_path[len(PKG_SET + "."):]
attr_paths.append(pname)
for extra in extras:
# Check if package advertises extra requirements
extra_attr = f"{pname}.extras-require.{extra}"
if has_extra(attr_path, extra):
extra_attrs.append(extra_attr)
else:
missing_reqs.append(extra_attr)
else:
missing_reqs.append(name)
else:
build_inputs[component] = (attr_paths, missing_reqs)
build_inputs[component] = (attr_paths, extra_attrs, missing_reqs)
with open(os.path.dirname(sys.argv[0]) + "/component-packages.nix", "w") as f:
f.write("# Generated by parse-requirements.py\n")
@ -191,11 +226,14 @@ def main() -> None:
f.write(f' version = "{version}";\n')
f.write(" components = {\n")
for component, deps in build_inputs.items():
available, missing = deps
available, extras, missing = deps
f.write(f' "{component}" = ps: with ps; [')
if available:
f.write(" " + " ".join(available))
f.write(" ];")
f.write("\n " + "\n ".join(available))
f.write("\n ]")
if extras:
f.write("\n ++ " + "\n ++ ".join(extras))
f.write(";")
if len(missing) > 0:
f.write(f" # missing inputs: {' '.join(missing)}")
f.write("\n")
@ -203,7 +241,7 @@ def main() -> None:
f.write(" # components listed in tests/components for which all dependencies are packaged\n")
f.write(" supportedComponentsWithTests = [\n")
for component, deps in build_inputs.items():
available, missing = deps
available, extras, missing = deps
if len(missing) == 0 and component in components_with_tests:
f.write(f' "{component}"' + "\n")
f.write(" ];\n")

View File

@ -6679,6 +6679,8 @@ in {
py3exiv2 = callPackage ../development/python-modules/py3exiv2 { };
py3rijndael = callPackage ../development/python-modules/py3rijndael { };
py3status = callPackage ../development/python-modules/py3status { };
py3to2 = callPackage ../development/python-modules/3to2 { };