Vendoring: remove dependency on Setuptools from vendored pytest (#15612)
If the Python used by Spack does not include Setuptools, then 'spack test' will fail because Spack's vendored pytest dependency imports and uses Setuptools in some of its functions. It turns out that Spack doesn't use the functionality those methods enable, so this PR removes those functions and thereby allows 'spack test' to run without Setuptools.
This commit is contained in:
10
lib/spack/external/__init__.py
vendored
10
lib/spack/external/__init__.py
vendored
@@ -88,10 +88,11 @@
|
||||
* Homepage: https://pypi.python.org/pypi/pytest
|
||||
* Usage: Testing framework used by Spack.
|
||||
* Version: 3.2.5 (last version supporting Python 2.6)
|
||||
* Note: This package has been slightly modified to improve
|
||||
Python 2.6 compatibility. See the following commit if the
|
||||
vendored copy ever needs to be updated again:
|
||||
https://github.com/spack/spack/pull/6801/commits/ff513c39f2c67ff615de5cbc581dd69a8ec96526
|
||||
* Note: This package has been slightly modified:
|
||||
* We improve Python 2.6 compatibility. See:
|
||||
https://github.com/spack/spack/pull/6801.
|
||||
* We have patched pytest not to depend on setuptools. See:
|
||||
https://github.com/spack/spack/pull/15612
|
||||
|
||||
ruamel.yaml
|
||||
------
|
||||
@@ -125,4 +126,5 @@
|
||||
* Homepage: https://altgraph.readthedocs.io/en/latest/index.html
|
||||
* Usage: dependency of macholib
|
||||
* Version: 0.16.1
|
||||
|
||||
"""
|
||||
|
38
lib/spack/external/_pytest/config.py
vendored
38
lib/spack/external/_pytest/config.py
vendored
@@ -1028,34 +1028,13 @@ def _consider_importhook(self, args):
|
||||
except SystemError:
|
||||
mode = 'plain'
|
||||
else:
|
||||
self._mark_plugins_for_rewrite(hook)
|
||||
# REMOVED FOR SPACK: This routine imports `pkg_resources` from
|
||||
# `setuptools`, but we do not need it for Spack. We have removed
|
||||
# it from Spack to avoid a dependency on setuptools.
|
||||
# self._mark_plugins_for_rewrite(hook)
|
||||
pass
|
||||
self._warn_about_missing_assertion(mode)
|
||||
|
||||
def _mark_plugins_for_rewrite(self, hook):
|
||||
"""
|
||||
Given an importhook, mark for rewrite any top-level
|
||||
modules or packages in the distribution package for
|
||||
all pytest plugins.
|
||||
"""
|
||||
import pkg_resources
|
||||
self.pluginmanager.rewrite_hook = hook
|
||||
|
||||
# 'RECORD' available for plugins installed normally (pip install)
|
||||
# 'SOURCES.txt' available for plugins installed in dev mode (pip install -e)
|
||||
# for installed plugins 'SOURCES.txt' returns an empty list, and vice-versa
|
||||
# so it shouldn't be an issue
|
||||
metadata_files = 'RECORD', 'SOURCES.txt'
|
||||
|
||||
package_files = (
|
||||
entry.split(',')[0]
|
||||
for entrypoint in pkg_resources.iter_entry_points('pytest11')
|
||||
for metadata in metadata_files
|
||||
for entry in entrypoint.dist._get_metadata(metadata)
|
||||
)
|
||||
|
||||
for name in _iter_rewritable_modules(package_files):
|
||||
hook.mark_rewrite(name)
|
||||
|
||||
def _warn_about_missing_assertion(self, mode):
|
||||
try:
|
||||
assert False
|
||||
@@ -1081,7 +1060,12 @@ def _preparse(self, args, addopts=True):
|
||||
self._checkversion()
|
||||
self._consider_importhook(args)
|
||||
self.pluginmanager.consider_preparse(args)
|
||||
self.pluginmanager.load_setuptools_entrypoints('pytest11')
|
||||
|
||||
# REMOVED FOR SPACK: This routine imports `pkg_resources` from
|
||||
# `setuptools`, but we do not need it for Spack. We have removed
|
||||
# it from Spack to avoid a dependency on setuptools.
|
||||
# self.pluginmanager.load_setuptools_entrypoints('pytest11')
|
||||
|
||||
self.pluginmanager.consider_env()
|
||||
self.known_args_namespace = ns = self._parser.parse_known_args(args, namespace=self.option.copy())
|
||||
if self.known_args_namespace.confcutdir is None and self.inifile:
|
||||
|
@@ -497,26 +497,6 @@ def check_pending(self):
|
||||
"unknown hook %r in plugin %r" %
|
||||
(name, hookimpl.plugin))
|
||||
|
||||
def load_setuptools_entrypoints(self, entrypoint_name):
|
||||
""" Load modules from querying the specified setuptools entrypoint name.
|
||||
Return the number of loaded plugins. """
|
||||
from pkg_resources import (iter_entry_points, DistributionNotFound,
|
||||
VersionConflict)
|
||||
for ep in iter_entry_points(entrypoint_name):
|
||||
# is the plugin registered or blocked?
|
||||
if self.get_plugin(ep.name) or self.is_blocked(ep.name):
|
||||
continue
|
||||
try:
|
||||
plugin = ep.load()
|
||||
except DistributionNotFound:
|
||||
continue
|
||||
except VersionConflict as e:
|
||||
raise PluginValidationError(
|
||||
"Plugin %r could not be loaded: %s!" % (ep.name, e))
|
||||
self.register(plugin, name=ep.name)
|
||||
self._plugin_distinfo.append((plugin, ep.dist))
|
||||
return len(self._plugin_distinfo)
|
||||
|
||||
def list_plugin_distinfo(self):
|
||||
""" return list of distinfo/plugin tuples for all setuptools registered
|
||||
plugins. """
|
||||
|
Reference in New Issue
Block a user