modwsgi_deploy Helper Script

17 views
Skip to first unread message

Enrico

unread,
Nov 17, 2010, 10:50:19 PM11/17/10
to TurboGears
Re. http://www.turbogears.org/2.1/docs/main/Deployment/ModWSGI.html#apache-mod-wsgi

I get through the first half ok, creating a "pythonenv" directory
containing virtualenv "myapp". Then there's two notes and a warning
and then "modwsgi_deploy Helper Script" starts talking about
modwsgideploy which I was able to easy_install (0.4.20dev)

Then this section of the page now starts talking about the default
location being /usr/local/turbogears when the start of the page tells
you to put two virtual env's in /usr/local/pythonenv (BASELINE and
myapp.) Should I go back and do it again substituting "turbogears"
for "pythonenv"?

I followed the paster modwsgi_deploy -h example usage but I get this
error trace:

me@mine:/usr/local/pythonenv/myapp$ source bin/activate
(myapp)me@mine:/usr/local/pythonenv/myapp$ paster modwsgi_deploy
Traceback (most recent call last):
File "/usr/local/pythonenv/myapp/bin/paster", line 9, in <module>
load_entry_point('PasteScript==1.7.3', 'console_scripts', 'paster')
()
File "/usr/local/pythonenv/myapp/lib/python2.6/site-packages/
PasteScript-1.7.3-py2.6.egg/paste/script/command.py", line 84, in run
invoke(command, command_name, options, args[1:])
File "/usr/local/pythonenv/myapp/lib/python2.6/site-packages/
PasteScript-1.7.3-py2.6.egg/paste/script/command.py", line 123, in
invoke
exit_code = runner.run(args)
File "/usr/local/pythonenv/myapp/lib/python2.6/site-packages/
PasteScript-1.7.3-py2.6.egg/paste/script/command.py", line 218, in run
result = self.command()
File "/usr/local/pythonenv/myapp/lib/python2.6/site-packages/
modwsgideploy-0.4.20dev-py2.6.egg/modwsgideploy/commands.py", line
100, in command
plugins= os.path.splitext(os.path.basename(egg_info_dir))[0]
File "/usr/local/pythonenv/myapp/lib/python2.6/posixpath.py", line
111, in basename
i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'

bvdb

unread,
Jan 12, 2011, 8:39:49 PM1/12/11
to TurboGears
Same problem here, on a fresh Debian lenny.
Now that two month have passed since your report it seems no one from
turbogears really bothers ...

On Nov 18 2010, 4:50 am, Enrico <enrico.manto...@gmail.com> wrote:
> Re.http://www.turbogears.org/2.1/docs/main/Deployment/ModWSGI.html
>
> I get through the first half ok, creating a "pythonenv" directory
> containing virtualenv "myapp". Then there's two notes and a warning
> and then "modwsgi_deploy Helper Script" starts talking about
> modwsgideploy which I was able to easy_install (0.4.20dev)
>
> I followed the paster modwsgi_deploy -h example usage but I get this
> error trace: ..
> ...

Ralph Bean

unread,
Jan 13, 2011, 12:04:13 AM1/13/11
to turbo...@googlegroups.com
I started deploying my first TG app today and hit the same thing. I
asked in the TG irc but got no response.. so I cracked open the source.

I started with the stack trace.. in particular the lines:

File "/usr/lib/python2.6/site-packages/modwsgideploy/commands.py",


line 100, in command
plugins= os.path.splitext(os.path.basename(egg_info_dir))[0]

It looks like os.path.basename doesn't expect egg_info_dir to be None,
it just assumes it to be a str (or something with a bound rfind method).

By looking in commands.py, I found that egg_info_dir gets assigned in
the preceding line with:

from paste.script import pluginlib
...
egg_info_dir = pluginlib.find_egg_info_dir(os.getcwd())

I followed the trail. pluginlib lives in
/usr/lib/python2.6/site-packages/paste/script/pluginlib.py

Here I'll quote the whole definition of find_egg_info_dir(...):

def find_egg_info_dir(dir):
while 1:
try:
filenames = os.listdir(dir)
except OSError:
# Probably permission denied or something
return None
for fn in filenames:
if fn.endswith('.egg-info'):
return os.path.join(dir, fn)
parent = os.path.dirname(dir)
if parent == dir:
# Top-most directory
return None
dir = parent

It looks like its returning None because it can't find a file
that ends with .egg-info! After a google or two, I found you
can generate that (if you don't still have it from your quickstart)
with:
python setup.py sdist

And that fixed it for me.


-RJ Bean

Ralph Bean

unread,
Jan 13, 2011, 10:58:49 AM1/13/11
to TurboGears
I started deploying my first TG app yesterday and hit the same thing.
I
asked in the TG irc but got no response.. so I cracked open the
source.

I started with the stack trace.. in particular the lines:

File "/usr/lib/python2.6/site-packages/modwsgideploy/commands.py",
line 100, in command
plugins= os.path.splitext(os.path.basename(egg_info_dir))[0]

python setup.py develop

That generated a myapp.egg-info and fixed it for me.

-RJ Bean

bvdb

unread,
Jan 13, 2011, 3:22:35 PM1/13/11
to TurboGears
Thanks for digging into this.
Anyhow, it did not help here, or maybe I missed something.

Which setup.py are you refering? - On this page:
http://turbogears.org/2.1/docs/main/Deployment/ModWSGI.html
.. there is only one place where setup.py is mentioned, after the
bzr.. command.

Probably you are talking about a different setup.py?
Or where should egg.info be placed and what does it contain?


On Jan 13, 4:58 pm, Ralph Bean <ralph.b...@gmail.com> wrote:
> I started deploying my first TG app yesterday and hit the same thing.
...
>  File "/usr/lib/python2.6/site-packages/modwsgideploy/commands.py",
>  line 100, in command
>    plugins= os.path.splitext(os.path.basename(egg_info_dir))[0]
>
> It looks like os.path.basename doesn't expect egg_info_dir to be None,
> it just assumes it to be a str (or something with a bound rfind
> method).
...

Ralph Bean

unread,
Jan 13, 2011, 3:44:01 PM1/13/11
to turbo...@googlegroups.com
For sure. I'm referring to the setup.py of my app `myapp` itself.

I have virtualenvs in two places:
/usr/local/pythonenv/BASELINE
/usr/local/pythonenv/myapp

I keep my project in git, so I also clone it to
/usr/local/turbogears/myapp

So, after having done the above (and setting bzr branching
modwsgideploy, python setup.py develop'ing it, etc), I did:

1 $ source /usr/local/pythonenv/myapp/bin/activate
2 $ cd /usr/local/turbogears/myapp
3 $ python setup.py develop
4 $ paster modwsgi_deploy --logging

Line 3 should create a myapp.egg-info folder at:
/usr/local/turbogears/myapp/myapp.egg-info

I found some info on .egg-info folders here
http://peak.telecommunity.com/DevCenter/EggFormats

In short, they contain metadata about your project that presumably
modwsgi_deploy uses to write your apache configuration.

> --
> You received this message because you are subscribed to the Google Groups "TurboGears" group.
> To post to this group, send email to turbo...@googlegroups.com.
> To unsubscribe from this group, send email to turbogears+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/turbogears?hl=en.
>

--
RJ Bean

bvdb

unread,
Jan 14, 2011, 6:17:53 AM1/14/11
to TurboGears
Oookay, but let me guess - the wisdom of having a clone in /usr/local/
turbogears, organized by git, comes from work and experience you've
had before starting with mod_wsgi.

That's not my situation, I'm doing a fresh start on this (having
experience only with PHP and RoR) and trying to find out if I could
recommend this path to others in the same situation, i.e. non-python-
hackers.

I looked thru the docs again and found that 'quickstart' seems to be
involved in creating a setup.py, so I went into my virtualenv 'tg1'
and started a new project 'test1' there ('t6lx' being my machine):
(tg1)www-data@t6lx:/usr/local/pythonenv/tg1$ paster quickstart test1

This generated setup.py and now I could do:
(tg1)www-data@t6lx:/usr/local/pythonenv/tg1/test1$ python setup.py
develop
(tg1)www-data@t6lx:/usr/local/pythonenv/tg1/test1$ paster
modwsgi_deploy

Bingo! This generates the folder /usr/local/pythonenv/tg1/test1/apache
But this contains various invalid paths like /usr/local/turbogears/
test1 .. wtf?

So after this I decided to write a rant on TG-wsgi ..
Reply all
Reply to author
Forward
0 new messages