@@ -1,5 +1,5 @@
11#! /usr/bin/env nix-shell
2−#! nix-shell -i python3 -p "python3.withPackages (ps: with ps; [ setuptools ])"
2+#! nix-shell -i python3 -p "python3.withPackages (ps: with ps; [ ])"
33#
44# This script downloads https://github.com/home-assistant/home-assistant/blob/master/requirements_all.txt.
55# This file contains lines of the form
@@ -20,7 +20,6 @@ import os
2020import sys
2121import json
2222import re
23−from pkg_resources import Requirement, RequirementParseError
2423
2524GENERAL_PREFIX = '# homeassistant.'
2625COMPONENT_PREFIX = GENERAL_PREFIX + 'components.'
@@ -64,9 +63,11 @@ def name_to_attr_path(req):
6463 names = [req]
6564 # E.g. python-mpd2 is actually called python3.6-mpd2
6665 # instead of python-3.6-python-mpd2 inside Nixpkgs
67− if req.startswith('python-'):
66+ if req.startswith('python-') or req.startswith('python_'):
6867 names.append(req[len('python-'):])
6968 for name in names:
69+ # treat "-" and "_" equally
70+ name = re.sub('[-_]', '[-_]', name)
7071 pattern = re.compile('^python\\d\\.\\d-{}-\\d'.format(name), re.I)
7172 for attr_path, package in packages.items():
7273 if pattern.match(package['name']):
@@ -86,7 +87,7 @@ for component, reqs in OrderedDict(sorted(requirements.items())).items():
8687 attr_paths = []
8788 for req in reqs:
8889 try:
89− name = Requirement.parse(req).project_name
90+ name = req.split('==')[0]
9091 attr_path = name_to_attr_path(name)
9192 if attr_path is not None:
9293 # Add attribute path without "python3Packages." prefix