Skip to content

EntryPoint.load(require=True) raises UndefinedEnvironmentName exception if the entry point with extra #1411

@jun66j5

Description

@jun66j5

Originally reported in https://trac.edgewall.org/ticket/13051. PostgreSQL cannot be used due to the issue.

The issue is raised with setuptools 39.2.0 and 40.0.0 but is not raised with setuptools 39.1.0. Another work around is to install tarball (*.egg-info used) rather than Trac wheel package (*.dist-info used).

15:19:45 Trac[loader] DEBUG: Loading plugin "trac.db.postgres" from "/dev/shm/trac-1.2.2/lib/python2.7/site-packages"
15:19:45 Trac[loader] ERROR: Skipping "trac.db.postgres = trac.db.postgres_backend [postgresql]":
Traceback (most recent call last):
  File "/dev/shm/trac-1.2.2/local/lib/python2.7/site-packages/trac/loader.py", line 68, in _load_eggs
    entry.load(require=True)
  File "/dev/shm/trac-1.2.2/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2228, in load
    self.require(*args, **kwargs)
  File "/dev/shm/trac-1.2.2/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2245, in require
    items = working_set.resolve(reqs, env, installer)
  File "/dev/shm/trac-1.2.2/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 808, in resolve
    if not req_extras.markers_pass(req):
  File "/dev/shm/trac-1.2.2/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 "/dev/shm/trac-1.2.2/local/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/markers.py", line 278, in evaluate
    return _evaluate_markers(self._markers, current_environment)
  File "/dev/shm/trac-1.2.2/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 "/dev/shm/trac-1.2.2/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.

setup.py in Trac 1.2.2: https://trac.edgewall.org/browser/tags/trac-1.2.2/setup.py?marks=98,115#L95

How to reproduce:

$ /usr/bin/virtualenv -p /usr/bin/python2.7 /dev/shm/trac-1.2.2
$ source /dev/shm/trac-1.2.2/bin/activate
(trac-1.2.2) $ pip install trac
(trac-1.2.2) $ pip install psycopg2
(trac-1.2.2) $ trac-admin /dev/shm/trac-1.2.2-tracenv initenv 'My Project' 'postgres://tracuser:password@localhost:5432/trac?schema=trac_1_2_2'
Creating and Initializing Project
Initenv for '/dev/shm/trac-1.2.2-tracenv' failed.
Failed to create environment.
Unsupported database type "postgres"
Traceback (most recent call last):
  File "/dev/shm/trac-1.2.2/local/lib/python2.7/site-packages/trac/admin/console.py", line 500, in do_initenv
    options=options)
  File "/dev/shm/trac-1.2.2/local/lib/python2.7/site-packages/trac/core.py", line 136, in __call__
    self.__init__(*args, **kwargs)
  File "/dev/shm/trac-1.2.2/local/lib/python2.7/site-packages/trac/env.py", line 300, in __init__
    self.create(options)
  File "/dev/shm/trac-1.2.2/local/lib/python2.7/site-packages/trac/env.py", line 592, in create
    DatabaseManager(self).init_db()
  File "/dev/shm/trac-1.2.2/local/lib/python2.7/site-packages/trac/db/api.py", line 337, in init_db
    connector, args = self.get_connector()
  File "/dev/shm/trac-1.2.2/local/lib/python2.7/site-packages/trac/db/api.py", line 615, in get_connector
    scheme=scheme))
TracError: Unsupported database type "postgres"
(trac-1.2.2) $ cat > /dev/shm/trac-1.2.2/inherit.ini
[logging]
log_type = stderr
(trac-1.2.2) $ trac-admin /dev/shm/trac-1.2.2-tracenv initenv --inherit=/dev/shm/trac-1.2.2/inherit.ini 'My Project' 'postgres://tracuser:password@localhost:5432/trac?schema=trac_1_2_2'
Creating and Initializing Project
15:19:45 Trac[env] INFO: -------------------------------- environment startup [Trac 1.2.2] --------------------------------
...
15:19:45 Trac[loader] DEBUG: Loading plugin "trac.db.postgres" from "/dev/shm/trac-1.2.2/lib/python2.7/site-packages"
15:19:45 Trac[loader] ERROR: Skipping "trac.db.postgres = trac.db.postgres_backend [postgresql]":
Traceback (most recent call last):
  File "/dev/shm/trac-1.2.2/local/lib/python2.7/site-packages/trac/loader.py", line 68, in _load_eggs
    entry.load(require=True)
  File "/dev/shm/trac-1.2.2/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2228, in load
    self.require(*args, **kwargs)
  File "/dev/shm/trac-1.2.2/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2245, in require
    items = working_set.resolve(reqs, env, installer)
  File "/dev/shm/trac-1.2.2/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 808, in resolve
    if not req_extras.markers_pass(req):
  File "/dev/shm/trac-1.2.2/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 "/dev/shm/trac-1.2.2/local/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/markers.py", line 278, in evaluate
    return _evaluate_markers(self._markers, current_environment)
  File "/dev/shm/trac-1.2.2/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 "/dev/shm/trac-1.2.2/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.
...

See also https://trac.edgewall.org/ticket/13051#comment:3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs ReproIssues that need a reproducible example.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions