setuptools: 20.5.0+ breaks existing setup.py files - UndefinedEnvironmentName

The latest 20.6.4 PyPI is breaking our setup.py files with the following exception:

Traceback (most recent call last):
  File "setup.py", line 163, in <module>
    cmdclass={'test': PyTest},
  File "/opt/python/2.7.9/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/opt/python/2.7.9/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/opt/python/2.7.9/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/setuptools/command/test.py", line 152, in run
    self.distribution.fetch_build_eggs(self.distribution.tests_require)
  File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/setuptools/dist.py", line 313, in fetch_build_eggs
    replace_conflicting=True,
  File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/pkg_resources/__init__.py", line 814, in resolve
    if req.marker and not req.marker.evaluate():
  File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/markers.py", line 273, in evaluate
    return _evaluate_markers(self._markers, current_environment)
  File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/markers.py", line 198, in _evaluate_markers
    lhs_value = _get_env(environment, lhs.value)
  File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/markers.py", line 180, in _get_env
    "{0!r} does not exist in evaluation environment.".format(name)
pkg_resources._vendor.packaging.markers.UndefinedEnvironmentName: 'extra' does not exist in evaluation environment.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 5
  • Comments: 50 (18 by maintainers)

Commits related to this issue

Most upvoted comments

This seems to be broken again in setuptools 28.0.0: I was generating message files with pybabel from jinja templates when I got this exception.

Downgrading setuptools to 27.3.1 fixed the issue.

Wonder if the troubleshooting tip mentioned of hacking the code to print the requirement can be made into debug logging so that it can be turned on easily whenever there is a problem.

Perhaps even modify things so that the current requirement can automatically be printed whenever an exception occurs?

Ordinarily, I’d probably take a look at the code and maybe submit a PR for what I just suggested, but I’m AFK for a few days, so I’ll just leave it as a suggestion for anyone who has motivation and a keyboard.

Simply reinstalling the same version of setuptools solves it too. e.g.

pip install --ignore-installed setuptools==34.4.1

Was also trying to install CKAN, and indeed @rwillmer’s fix worked.

Same here:

venv/local/lib/python2.7/site-packages/pylons/configuration.py:26: RuntimeWarning: Unable to load template engine entry point: 'pylonsmyghty = pylons.templating:MyghtyTemplatePlugin [myghty]': Traceback (most recent call last):
  File "venv/local/lib/python2.7/site-packages/pylons/templating.py", line 610, in <module>
    Engine = entry_point.load()
  File "venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2228, in load
    self.require(*args, **kwargs)
  File "venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2245, in require
    items = working_set.resolve(reqs, env, installer)
  File "venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 808, in resolve
    if not req_extras.markers_pass(req):
  File "venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 993, in markers_pass
    return not req.marker or any(extra_evals) or req.marker.evaluate()
  File "venv/local/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/markers.py", line 278, in evaluate
    return _evaluate_markers(self._markers, current_environment)
  File "venv/local/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/markers.py", line 203, in _evaluate_markers
    lhs_value = _get_env(environment, lhs.value)
  File "venv/local/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/markers.py", line 185, in _get_env
    "{0!r} does not exist in evaluation environment.".format(name)
UndefinedEnvironmentName: 'extra' does not exist in evaluation environment.

  import pylons.templating

setuptools version:

>>> setuptools.__version__
'32.0.0'

After downgrading and upgrading setuptools as suggested by @rwillmer the error is gone.

In order to set up CKAN I was using this Ansible script:

https://github.com/sirex/ckan-ivpk-import/blob/master/ckan.yml