dev-python/jaraco-context: New dep of dev-python/cheroot

Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
Michał Górny
2020-07-20 18:33:33 +02:00
parent c28b1d40bb
commit 272c9a97d4
4 changed files with 118 additions and 0 deletions

View File

@@ -0,0 +1 @@
DIST jaraco.context-3.0.0.tar.gz 12901 BLAKE2B b0a18d8799de211c9827a708302798372dff06767fbac08f4bff8ed48e1dde4cca8d3896a3c4dccd186efdc4d80ffe2b972a05e8f351ec53dcd0c7dec45cfcea SHA512 fd48a9af65edea3212c194758ba1a8fc2d7efc35f7eaec959a7f327ad46d1bf15f295af29d62726f813d35baaeaff35bc3fcd6e27a0e0f272232772e1cb87c17

View File

@@ -0,0 +1,62 @@
From e3a1f344c296f9d6193f4bf2ac1e0cdafcddce0e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Mon, 20 Jul 2020 18:11:31 +0200
Subject: [PATCH] Make jaraco.apt & yg.lockfile imports optional
Handle missing jaraco.apt & yg.lockfile modules more gracefully,
delaying the error until dependency_context is actually used. These
two modules are only used by the dependency_context, and this context
can only work on apt-based systems, so there is no point in forcing
the extraneous dependencies on systems that do not use apt where
jaraco.context is being installed for other context managers.
---
jaraco/context.py | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/jaraco/context.py b/jaraco/context.py
index 0b5b1bc..13dfdf6 100644
--- a/jaraco/context.py
+++ b/jaraco/context.py
@@ -13,8 +13,15 @@ try:
except Exception:
import contextlib as contextlib2
-import jaraco.apt
-import yg.lockfile
+try:
+ import jaraco.apt as apt
+except ImportError:
+ apt = None
+
+try:
+ import yg.lockfile
+except ImportError:
+ yg = None
__metaclass__ = type
@@ -131,6 +138,12 @@ def dependency_context(package_names, aggressively_remove=False):
"""
installed_packages = []
log = logging.getLogger(__name__)
+ if apt is None:
+ log.error("jaraco.apt not found installed")
+ raise ImportError("jaraco.apt not found installed")
+ if yg is None:
+ log.error("yg.lockfile not found installed")
+ raise ImportError("yg.lockfile not found installed")
try:
if not package_names:
logging.debug('No packages requested')
@@ -144,7 +157,7 @@ def dependency_context(package_names, aggressively_remove=False):
stderr=subprocess.STDOUT,
)
log.debug('Aptitude output:\n%s', output)
- installed_packages = jaraco.apt.parse_new_packages(
+ installed_packages = apt.parse_new_packages(
output, include_automatic=aggressively_remove
)
if not installed_packages:
--
2.27.0

View File

@@ -0,0 +1,47 @@
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
# upstream uses bad template
DISTUTILS_USE_SETUPTOOLS=manual
PYTHON_COMPAT=( python3_{6..9} pypy3 )
inherit distutils-r1
MY_PN="${PN/-/.}"
DESCRIPTION="Context managers by jaraco"
HOMEPAGE="https://github.com/jaraco/jaraco.context"
SRC_URI="mirror://pypi/${PN:0:1}/${MY_PN}/${MY_PN}-${PV}.tar.gz"
S="${WORKDIR}/${MY_PN}-${PV}"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86"
RDEPEND="
>=dev-python/namespace-jaraco-2[${PYTHON_USEDEP}]
"
BDEPEND="
dev-python/setuptools[${PYTHON_USEDEP}]
dev-python/setuptools_scm[${PYTHON_USEDEP}]
"
distutils_enable_tests pytest
PATCHES=(
"${FILESDIR}"/${P}-useless-deps.patch
)
python_prepare_all() {
# used only for apt support that's irrelevant to Gentoo
sed -i -e '/jaraco\.apt/d' -e '/yg\.lockfile/d' setup.cfg || die
# pytest plugins
sed -i -e 's:--flake8 --black --cov::' pytest.ini || die
distutils-r1_python_prepare_all
}
python_install() {
rm "${BUILD_DIR}"/lib/jaraco/__init__.py || die
distutils-r1_python_install
}

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="project">
<email>python@gentoo.org</email>
<name>Python</name>
</maintainer>
</pkgmetadata>