setup.py - just what is it for ?

R

Richard Shea

Hi - This is probably quite a stupid question but I've never
understood what setup.py does. I've got a situation at the moment
where I would like to use a script (which someone else has written and
made available) to do CGI on a shared webserver to which I do not have
shell access.

The install instructions say "run python setup.py" but as far as I'm
aware I cannot do that.

There is only one script involved (except for the setup.py !) and so
I'm probably just going to copy it into my cgi-bin and give it a go
but I'd like to know for future reference just how bad could it be if
I did this ? Are there circumstances where you must use setup.py to
have any hope of the code working ?

BTW here is the setup.py in question ...

from distutils.core import setup

classifiers = """\
Development Status :: 5 - Production/Stable
Environment :: Web Environment
Intended Audience :: Developers
License :: OSI Approved :: GNU General Public License (GPL)
Operating System :: OS Independent
Topic :: Internet :: WWW/HTTP
Topic :: Internet :: WWW/HTTP :: Dynamic Content :: CGI
Tools/Libraries
"""
import sys
if sys.version_info < (2, 3):
_setup = setup
def setup(**kwargs):
if kwargs.has_key("classifiers"):
del kwargs["classifiers"]
_setup(**kwargs)

setup(name="cgi_app",py_modules=["cgi_app"],
version="1.3",
maintainer="Anders Pearson",
maintainer_email="(e-mail address removed)",
url = "http://thraxil.org/code/cgi_app/",
license = "http://www.gnu.org/licenses/gpl.html",
platforms = ["any"],
description = "CGI and mod_python MVC application framework",
long_description = """framework for building MVC CGI and
mod_python
applications. based on the perl CGI::Application module but
more
pythonic.""",
classifiers = filter(None, classifiers.split("\n")))


.... I would appreciate any information about this (or any tips on how
to deal with no shell access).

thanks

richard
 
F

Fredrik Lundh

Richard said:
Hi - This is probably quite a stupid question but I've never
understood what setup.py does. I've got a situation at the moment
where I would like to use a script (which someone else has written and
made available) to do CGI on a shared webserver to which I do not have
shell access.

The install instructions say "run python setup.py" but as far as I'm
aware I cannot do that.

http://www.python.org/doc/current/inst/
There is only one script involved (except for the setup.py !) and so
< I'm probably just going to copy it into my cgi-bin and give it a go
but I'd like to know for future reference just how bad could it be if
I did this ? Are there circumstances where you must use setup.py to
have any hope of the code working ?

depends on the package, of course. e.g. a package that includes C extensions
won't work if you don't compile the C extensions...

</F>
 
R

richardshea

OK thanks for the idea. I have tried this with rather strange restults.
First, in order to be sure I knew what was going on, I wrote a script,
SpawnvTestTarget0.py, which didn't do much apart from write to a file.

I then wrote another script which spawnv'd SpawnvTestTarget0.py from
within the CGI context.

This all worked fine. At this point I thought things were looking
pretty good.

I then added in a spawnv to the setup.py (ie the script I really wanted
to be able to run) but as soon as I tried that I got an 'Internal
Server Error' message.

I've also noticed that in the directions for installing it *does* say
that you should run setup.py as root which is probably at least
contributing to the problem. Anyway out of interest here is my script
....


#!/usr/bin/python2.2
"""
A script to try to run an install.py
on a webserver to which I do not have
shell access

Usage: /installshell.cgi
"""

import cgitb; cgitb.enable()
import sys, os, cgi, pickle
from Cookie import SimpleCookie
def print_headers(headers):
for k, v in headers.items():
sys.stdout.write('%s: %s\n' % (k, v))
sys.stdout.write('\n')

print_headers({'Content-type':'text/html'})

sys.stdout.write('<html><body>')
sys.stdout.write('About to execute SPAWNV Command - 1<BR>')
os.spawnv(os.P_WAIT,'/usr/bin/python2.2',['python','setup.py','install'])
os.spawnv(os.P_WAIT,'/usr/bin/python2.2',['python','SpawnvTestTarget0.py','install'])
sys.stdout.write('Finished in execute of SPAWNV Command')
sys.stdout.write('</body></html>')

.... I've got to go to bed now but later I'm going to try just using the
script as it is - I strongly suspect the setup.py in this case is icing
rather than cake ... then again I may be demonstrating my ignorance !
thanks for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top