Edgewall Software

Opened 2 years ago

Last modified 2 years ago

#13051 reopened defect

The initenv process of trac-admin requires more than just 'psycopg2' and 'trac'

Reported by: wind8702@… Owned by:
Priority: normal Milestone:
Component: general Version: 1.2.2
Severity: major Keywords: setuptools pip wheel
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Ryan J Ollos)

I figured out the initenv process of trac-admin requires more than just 'psycopg2' and 'trac' to use the postgresql driver, the previous week of last week.

Either it is a bug or the wiki page for database backends is missing an important line (DatabaseBackend).

I somehow figured out how to make it work after some digging: I had to also install TracTags from Python Package Index. otherwise I'd get messages like: TracError: Unsupported database type "postgres"

What I did:

useradd -mrd /var/lib/g9-trac g9-trac
mkdir -p /var/log/g9

apt install -y virtualenv
# virtualenv -p /usr/bin/python3 /var/lib/g9-trac/ve-trac
su - g9-trac
virtualenv -p /usr/bin/python2 /var/lib/g9-trac/ve-trac
source /var/lib/g9-trac/ve-trac/bin/activate

pip install trac
#it's weird the psycopg2 driver worked only after I installed TracTags
pip install psycopg2

trac-admin /var/lib/g9-trac/trac-g9 initenv Gxxxxx9 'postgres://g9-trac:passphrase32!@localhost:5432/trac-g9'

Thank you, Gunwoo Gim

Attachments (0)

Change History (6)

comment:1 by Jun Omae, 2 years ago

Description: modified (diff)
Priority: highnormal
Resolution: cantfix
Status: newclosed

InstallationIssue. Please ask on the mailing list.

comment:2 by wind8702@…, 2 years ago

I do know how to SOMEHOW install it with the postgresql driver now. I thought I'd love to help the developers fix this issue.

Asking, that's how I figured out how to successfully install/initenv, a guy showed his dockerfile and I tried some of the packages in the recipe to figure out TracTags somehow helps with the utilization of the postgresql driver. I got the help on the irc channel.

Jun, I'd like to ask you if you thought I did something wrong in the failed installation, and trac had no bug.

comment:3 by Jun Omae, 2 years ago

Component: database backendgeneral
Keywords: setuptools pip wheel added; postgresql removed
Resolution: cantfix
Status: closedreopened

Well, I get the same error with fresh virtualenv.

$ /usr/bin/virtualenv -p /usr/bin/python2.7 /dev/shm/trac-1.2.2
Running virtualenv with interpreter /usr/bin/python2.7
New python executable in /dev/shm/trac-1.2.2/bin/python2.7
Also creating executable in /dev/shm/trac-1.2.2/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
$ source /dev/shm/trac-1.2.2/bin/activate
(trac-1.2.2) $ type pip
pip is /dev/shm/trac-1.2.2/bin/pip
(trac-1.2.2) $ pip install trac
Collecting trac
  Using cached https://files.pythonhosted.org/packages/85/67/f1549b34fc405d10d09eb9eb52f71cd6b790328177e33e3993a9a08b22b7/Trac-1.2.2-py2-none-any.whl
Requirement already satisfied: setuptools>=0.6 in /dev/shm/trac-1.2.2/lib/python2.7/site-packages (from trac) (39.2.0)
Collecting Genshi>=0.6 (from trac)
  Using cached https://files.pythonhosted.org/packages/c5/2f/34493b2286561d0ea003c568a6c80343eee3c9975a69964d22ce8501dd3f/Genshi-0.7.tar.gz
Installing collected packages: Genshi, trac
  Running setup.py install for Genshi ... done
Successfully installed Genshi-0.7 trac-1.2.2
(trac-1.2.2) $ pip install psycopg2
Collecting psycopg2
  Downloading https://files.pythonhosted.org/packages/7c/e6/d5161798a5e8900f24216cb730f2c2be5e4758a80d35c8588306831c0c99/psycopg2-2.7.5-cp27-cp27mu-manylinux1_x86_64.whl (2.7MB)
    100% |████████████████████████████████| 2.7MB 155kB/s
Installing collected packages: psycopg2
Successfully installed psycopg2-2.7.5
(trac-1.2.2) $ pip list                                                                                       DEPRECATION: The legacy format has been deprecated and will be removed in the future.
Genshi (0.7)
pip (10.0.1)
pkg-resources (0.0.0)
psycopg2 (2.7.5)
setuptools (39.2.0)
Trac (1.2.2)
wheel (0.31.1)
(trac-1.2.2) $ type trac-admin
trac-admin is /dev/shm/trac-1.2.2/bin/trac-admin
(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
  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__
  File "/dev/shm/trac-1.2.2/local/lib/python2.7/site-packages/trac/env.py", line 592, in create
  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
TracError: Unsupported database type "postgres"

I noticed UndefinedEnvironmentName raised when loading trac.db.postgres_backend. The issue is due to pip, setuptools, wheel or Trac-1.2.2-py2-none-any.whl file.

(trac-1.2.2) $ cat > /dev/shm/trac-1.2.2/inherit.ini
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
  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.

Work around is to reinstall Trac using tarball.

$ pip uninstall -y Trac
$ pip install https://download.edgewall.org/trac/Trac-1.2.2.tar.gz
$ 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'

The latest documentation can also always be found on the project



comment:4 by Jun Omae, 2 years ago

Another work around is to downgrade to setuptools 39.1.0.

$ pip install setuptools==39.1.0

comment:5 by Jun Omae, 2 years ago

Filed in https://github.com/pypa/setuptools/issues/1411.

setuptools 40.0.0 is released but the issue is not fixed.

comment:6 by Ryan J Ollos, 2 years ago

Description: modified (diff)

Modify Ticket

Change Properties
Set your email in Preferences
as reopened The ticket will remain with no owner.
The ticket will be disowned. Next status will be 'new'.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.