Merge pull request #114049 from graham33/feature/add_fiblary3

This commit is contained in:
Martin Weinelt 2022-02-23 17:44:33 +01:00 committed by GitHub
commit e93b6abd35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 72 additions and 30 deletions

View File

@ -0,0 +1,51 @@
{ lib
, buildPythonPackage
, isPy3k
, fetchPypi
, fixtures
, jsonpatch
, netaddr
, prettytable
, python-dateutil
, pytestCheckHook
, requests
, requests-mock
, six
, sphinx
, testtools
}:
buildPythonPackage rec {
pname = "fiblary3-fork";
version = "0.1.12";
src = fetchPypi {
inherit pname version;
sha256 = "001wqh7gx2dv3sf7a5xsbppz9r88f5qwrp05jzjsjcm6cbcvmsz0";
};
propagatedBuildInputs = [
jsonpatch
netaddr
prettytable
python-dateutil
requests
six
];
checkInputs = [
fixtures
pytestCheckHook
requests-mock
testtools
];
pythonImportsCheck = [ "fiblary3" ];
meta = with lib; {
homepage = "https://github.com/graham33/fiblary";
description = "Fibaro Home Center API Python Library";
license = licenses.asl20;
maintainers = with maintainers; [ graham33 ];
};
}

View File

@ -216,7 +216,7 @@
"ecobee" = ps: with ps; [ python-ecobee-api ];
"econet" = ps: with ps; [ pyeconet ];
"ecovacs" = ps: with ps; [ ]; # missing inputs: sucks
"eddystone_temperature" = ps: with ps; [ construct ]; # missing inputs: beacontools[scan]
"eddystone_temperature" = ps: with ps; [ construct ]; # missing inputs: beacontools
"edimax" = ps: with ps; [ pyedimax ];
"edl21" = ps: with ps; [ pysml ];
"efergy" = ps: with ps; [ pyefergy ];
@ -264,7 +264,7 @@
"ffmpeg" = ps: with ps; [ ha-ffmpeg ];
"ffmpeg_motion" = ps: with ps; [ ha-ffmpeg ];
"ffmpeg_noise" = ps: with ps; [ ha-ffmpeg ];
"fibaro" = ps: with ps; [ ]; # missing inputs: fiblary3
"fibaro" = ps: with ps; [ fiblary3-fork ];
"fido" = ps: with ps; [ pyfido ];
"file" = ps: with ps; [ ];
"filesize" = ps: with ps; [ ];

View File

@ -34,16 +34,12 @@ from rich.table import Table
COMPONENT_PREFIX = "homeassistant.components"
PKG_SET = "home-assistant.python.pkgs"
# If some requirements are matched by multiple Python packages,
# the following can be used to choose one of them
# If some requirements are matched by multiple or no Python packages, the
# following can be used to choose the correct one
PKG_PREFERENCES = {
# Use python3Packages.youtube-dl-light instead of python3Packages.youtube-dl
"youtube-dl": "youtube-dl-light",
"tensorflow-bin": "tensorflow",
"tensorflow-bin_2": "tensorflow",
"tensorflowWithoutCuda": "tensorflow",
"tensorflow-build_2": "tensorflow",
"whois": "python-whois",
"youtube_dl": "youtube-dl-light",
"tensorflow": "tensorflow",
"fiblary3": "fiblary3-fork", # https://github.com/home-assistant/core/issues/66466
}
@ -120,39 +116,28 @@ def dump_packages() -> Dict[str, Dict[str, str]]:
def name_to_attr_path(req: str, packages: Dict[str, Dict[str, str]]) -> Optional[str]:
attr_paths = set()
if req in PKG_PREFERENCES:
return f"{PKG_SET}.{PKG_PREFERENCES[req]}"
attr_paths = []
names = [req]
# E.g. python-mpd2 is actually called python3.6-mpd2
# instead of python-3.6-python-mpd2 inside Nixpkgs
if req.startswith("python-") or req.startswith("python_"):
names.append(req[len("python-") :])
# Add name variant without extra_require, e.g. samsungctl
# instead of samsungctl[websocket]
if req.endswith("]"):
names.append(req[:req.find("[")])
for name in names:
# treat "-" and "_" equally
name = re.sub("[-_]", "[-_]", name)
# python(minor).(major)-(pname)-(version or unstable-date)
# we need the version qualifier, or we'll have multiple matches
# (e.g. pyserial and pyserial-asyncio when looking for pyserial)
pattern = re.compile("^python\\d\\.\\d-{}-(?:\\d|unstable-.*)".format(name), re.I)
pattern = re.compile(f"^python\\d\\.\\d-{name}-(?:\\d|unstable-.*)", re.I)
for attr_path, package in packages.items():
if pattern.match(package["name"]):
attr_paths.add(attr_path)
if len(attr_paths) > 1:
for to_replace, replacement in PKG_PREFERENCES.items():
try:
attr_paths.remove(PKG_SET + "." + to_replace)
attr_paths.add(PKG_SET + "." + replacement)
except KeyError:
pass
attr_paths.append(attr_path)
# Let's hope there's only one derivation with a matching name
assert len(attr_paths) <= 1, "{} matches more than one derivation: {}".format(
req, attr_paths
)
if len(attr_paths) == 1:
return attr_paths.pop()
assert len(attr_paths) <= 1, f"{req} matches more than one derivation: {attr_paths}"
if attr_paths:
return attr_paths[0]
else:
return None
@ -180,6 +165,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]
if name.endswith("]"):
name = name[:name.find("[")]
attr_path = name_to_attr_path(name, packages)
if our_version := get_pkg_version(name, packages):
if Version.parse(our_version) < Version.parse(required_version):

View File

@ -2845,6 +2845,8 @@ in {
ffmpeg-progress-yield = callPackage ../development/python-modules/ffmpeg-progress-yield { };
fiblary3-fork = callPackage ../development/python-modules/fiblary3-fork { };
fido2 = callPackage ../development/python-modules/fido2 { };
fields = callPackage ../development/python-modules/fields { };