From 78b0b1d6d23de71d9094e9074b3f8e16e4aa17ad Mon Sep 17 00:00:00 2001 From: Vratislav Podzimek Date: Mon, 25 Apr 2022 11:30:00 +0200 Subject: [PATCH 1/2] Remove the dependency on the 'requests' Python package The 'requests' package is not part of the standard Python library and build set. We don't use the package extensively so to avoid requiring dependencies, we can just use 'urllib' which is part of the standard library and build set. Ticket: ENT-8439 Changelog: Removed dependency on the 'requests' package --- README.md | 1 - cfbs/utils.py | 8 +++----- requirements.txt | 1 - setup.py | 1 - 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8703b411..d38f01b0 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,6 @@ $ cfbs install . `cfbs` is implemented in Python and has a few dependencies: * Python 3.5 or newer -* `requests` python library * `git` CLI installed and in PATH * `rsync` * `autoconf` for configuring masterfiles module (typical usage but not required) diff --git a/cfbs/utils.py b/cfbs/utils.py index 2bff8ac2..a73de2f7 100644 --- a/cfbs/utils.py +++ b/cfbs/utils.py @@ -9,8 +9,6 @@ from collections import OrderedDict from shutil import rmtree -import requests - from cfbs.pretty import pretty SHA1_RE = re.compile(r"^[0-9a-f]{40}$") @@ -84,9 +82,9 @@ def user_error(msg: str): def get_json(url: str) -> OrderedDict: - r = requests.get(url) - assert r.status_code >= 200 and r.status_code < 300 - return r.json(object_pairs_hook=OrderedDict) + with urllib.request.urlopen(url) as r: + assert r.status >= 200 and r.status < 300 + return json.loads(r.read().decode(), object_pairs_hook=OrderedDict) def get_or_read_json(path: str) -> OrderedDict: diff --git a/requirements.txt b/requirements.txt index 65d7ffc5..e69de29b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +0,0 @@ -requests>=2.25.1 diff --git a/setup.py b/setup.py index d36f9b18..316efcff 100644 --- a/setup.py +++ b/setup.py @@ -45,6 +45,5 @@ ] }, install_requires=[ - "requests >= 2.25.1", ], ) From 269c181b86c15124c4a4ef4db0319c9e55d40499 Mon Sep 17 00:00:00 2001 From: Vratislav Podzimek Date: Mon, 25 Apr 2022 11:42:14 +0200 Subject: [PATCH 2/2] Make sure urllib.request is imported On some platforms 'import urllib' doesn't make 'urllib.request' available. Ticket: ENT-8439 Changelog: None --- cfbs/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cfbs/utils.py b/cfbs/utils.py index a73de2f7..a703ba3f 100644 --- a/cfbs/utils.py +++ b/cfbs/utils.py @@ -6,6 +6,7 @@ import subprocess import hashlib import urllib +import urllib.request # needed on some platforms from collections import OrderedDict from shutil import rmtree