Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2419 (closed defect: worksforme)

Opened 9 years ago

Last modified 8 years ago

tg-admin sql create fails with sqlobject on installed apps

Reported by: toshio Owned by: Chris Arndt
Priority: normal Milestone: 1.1.x bugfix
Component: tg-admin (non-toolbox) Version: 1.0.8
Severity: normal Keywords:
Cc: lmacken

Description

One of our developers is using SQLObject and TG-1.0.8. He's writing up documentation for end users on how to setup the application on their machines. The application is installed in /usr/share/israwhidebroken. There's two directories in there:

  • /usr/share/israwhidebroken/israwhidebroken <= Contains the module that drives the app
  • /usr/share/israwhidebroken/israwhidebroken-0.1-py26.egg-info <= Contains the egg info for the module

He's tried to run "tg-admin sql create" to setup the database in a variety of ways and it has failed. Our best guess as to what should work was::

  $ cd /usr/share/israwhidebroken
  $ PYTHONPATH=/usr/share/israwhidebroken tg-admin sql create -c /etc/israwhidebroken.cfg
  [...]
  # note: line numbers slightly off as I have some print statements in for debugging
Traceback (most recent call last):
  File "/usr/bin/tg-admin", line 8, in <module>
    load_entry_point('TurboGears==1.0.8', 'console_scripts', 'tg-admin')()
  File "/usr/lib/python2.6/site-packages/turbogears/command/base.py", line 400, in main
    command.run()
  File "/usr/lib/python2.6/site-packages/turbogears/command/base.py", line 138, in run
    command.the_runner.run(sys.argv)
  File "/usr/lib/python2.6/site-packages/sqlobject/manager/command.py", line 101, in run
    runner.run()
  File "/usr/lib/python2.6/site-packages/sqlobject/manager/command.py", line 306, in run
    self.load_options_from_egg(egg_spec)
  File "/usr/lib/python2.6/site-packages/sqlobject/manager/command.py", line 491, in load_options_from_egg
    dist, conf = self.config_from_egg(egg_spec)
  File "/usr/lib/python2.6/site-packages/sqlobject/manager/command.py", line 501, in config_from_egg
    dist = pkg_resources.get_distribution(egg_spec)
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 270, in get_distribution
    if isinstance(dist,Requirement): dist = get_provider(dist)
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 156, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 626, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 524, in resolve
    raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: israwhidebroken-0.1-py2.6

I took a look and found that turbogears/command/base.py:SQL.run() was getting the name of the egg directory, stripping the '.egg-info' extension and then passing that on to sqlobject and hence to setuptools. Unfortunately, setuptools doesn't know how to deal with "israwhidebroken-0.1-py2.6". it treats the whole thing as a complete package name string. For setuptools to understand this it would need to be closer to "israwhidebroken == 0.1" (not sure how to deal with the py2.6).

I did some work and have a patch which transforms the directory name into the form setuptools expects. I also looked at TurboGears-1.1 and found that the logic is the same there and the patch applies.

Attachments

turbogears-sqlcreate.patch Download (1.3 KB) - added by toshio 9 years ago.
Updated patch -- Now fixed for running sql create while developing the app

Change History

comment:1 Changed 9 years ago by lmacken

  • Cc lmacken added

Changed 9 years ago by toshio

Updated patch -- Now fixed for running sql create while developing the app

comment:2 Changed 9 years ago by Chris Arndt

  • Status changed from new to assigned
  • Owner set to Chris Arndt
  • Component changed from TurboGears to tg-admin (non-toolbox)
  • Milestone changed from __unclassified__ to 1.1.x bugfix

comment:3 Changed 8 years ago by chrisz

  • Status changed from assigned to closed
  • Resolution set to worksforme

Going through the open TG 1 tickets, I cannot reproduce this one at all. The steps explained above cannot work since the command is looking for a *.egg-info directory which cannot be found inside /usr/share/israwhidebroken, and the -c switch is at the wrong place. Also, eggs are only installed like that with some strange options, probably --single-version-externally-managed or something like that. If you're still interested in this, please reopen on the  SF tracker and provide a complete, working documentation with all steps and commands how the problem can be reproduced with TG 1.1/1.5.

Note: See TracTickets for help on using tickets.