Skip to content

Commit

Permalink
Add global requires ban handling logic
Browse files Browse the repository at this point in the history
Some packages should not be able to be added to any subpkg. Add
handling for this case.

Also as pypi-nose is no longer usable so ban it from being added as a
dependency.

Signed-off-by: William Douglas <[email protected]>
  • Loading branch information
bryteise committed Oct 20, 2023
1 parent c644c18 commit 88d85d9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
18 changes: 13 additions & 5 deletions autospec/buildreq.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,13 @@ class Requirements(object):

def __init__(self, url):
"""Initialize Default requirements settings."""
self.banned_requires = {None: set(["futures",
"configparser",
"typing",
"ipaddress"])}
self.banned_anywhere_requires = set(["futures",
"configparser",
"typing",
"ipaddress",
"pypi-nose",
"pypi(nose)"])
self.banned_requires = {None: set()}
self.buildreqs = set()
self.buildreqs_cache = set()
self.requires = {None: set(), "pypi": set()}
Expand All @@ -294,7 +297,10 @@ def __init__(self, url):
"setuptools_scm[toml]",
"typing",
"ipaddress",
"pypi(setuptools_scm_git_archive)"])
"pypi-nose",
"pypi(setuptools_scm_git_archive)",
"pypi(setuptools_changelog_shortener)",
"pypi(nose)"])
self.autoreconf_reqs = ["gettext-bin",
"automake-dev",
"automake",
Expand Down Expand Up @@ -347,6 +353,8 @@ def add_requires(self, req, packages, override=False, subpkg=None):
banned_requires = self.banned_requires[subpkg] = set()
if req in banned_requires:
return False
if req in self.banned_anywhere_requires:
return False

if req not in self.buildreqs and req not in packages and not override:
if req:
Expand Down
2 changes: 0 additions & 2 deletions autospec/failed_commands
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# This file is sorted with LC_COLLATE=C
# Lines beginning with '#' are ignored.
# For patterns that start with '#', escape the '#' as '\#'.
'nose', pypi(nose)
'numpy', pypi(numpy)
'pexpect', pypi(pexpect)
-lEGL, mesa-dev
Expand Down Expand Up @@ -1132,7 +1131,6 @@ nfsidmap.h, libnfsidmap-dev
nghttp, nghttp2-dev
nl_handle_alloc, libnl-dev
node, nodejs
nose, pypi-nose
nosexcover, nosexcover
notmuch.h, notmuch-dev
nroff, groff
Expand Down
7 changes: 7 additions & 0 deletions tests/test_buildreq.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ def test_add_requires_not_in_buildreqs(self):
self.assertFalse(self.reqs.add_requires('testreq', []))
self.assertNotIn('testreq', self.reqs.requires[None])

def test_add_banned_requires(self):
"""
Test add_requires with banned new req (override buildreq).
"""
self.assertFalse(self.reqs.add_requires('pypi(nose)', [], override=True))
self.assertNotIn('testreq', self.reqs.requires[None])

def test_ban_provides(self):
"""
Test ban_provides with prov already present in provides
Expand Down

0 comments on commit 88d85d9

Please sign in to comment.