Setuptools - help!

P

Peter Chant

Chaps,

any ideas, I'm floundering - I don't quite get it. I have the following
files, setup.py and main.py in a directory pphoto:

# more setup.py
from setuptools import setup, find_packages
setup(
name = "Pphoto",
version = "0.1",
packages = find_packages(),

# other arguments here...
entry_points = {'console_scripts': ['foo = pphoto.main:HelloWorld',]}


)

bash-3.1# more main.py


def HelloWorld():
print "Hello World!"

print "Odd world"


From various websites that should produce a script foo that runs HelloWorld.
It does produce a script that simply crashes.

bash-3.1# foo
Traceback (most recent call last):
File "/usr/bin/foo", line 8, in <module>
load_entry_point('Pphoto==0.1', 'console_scripts', 'foo')()
File "build/bdist.linux-i686/egg/pkg_resources.py", line 277, in
load_entry_point
File "build/bdist.linux-i686/egg/pkg_resources.py", line 2098, in
load_entry_point
File "build/bdist.linux-i686/egg/pkg_resources.py", line 1831, in load
ImportError: No module named pphoto.main
bash-3.1#


Note, doing this as root as it seems not to do anything usefull at all if I
run python setup develop as a user.

Any ideas? I must be missing something fundamental?

Pete
 
R

Robert Kern

Chaps,

any ideas, I'm floundering - I don't quite get it. I have the following
files, setup.py and main.py in a directory pphoto:

# more setup.py
from setuptools import setup, find_packages
setup(
name = "Pphoto",
version = "0.1",
packages = find_packages(),

# other arguments here...
entry_points = {'console_scripts': ['foo = pphoto.main:HelloWorld',]}


)

bash-3.1# more main.py


def HelloWorld():
print "Hello World!"

print "Odd world"

From various websites that should produce a script foo that runs HelloWorld.
It does produce a script that simply crashes.

bash-3.1# foo
Traceback (most recent call last):
File "/usr/bin/foo", line 8, in<module>
load_entry_point('Pphoto==0.1', 'console_scripts', 'foo')()
File "build/bdist.linux-i686/egg/pkg_resources.py", line 277, in
load_entry_point
File "build/bdist.linux-i686/egg/pkg_resources.py", line 2098, in
load_entry_point
File "build/bdist.linux-i686/egg/pkg_resources.py", line 1831, in load
ImportError: No module named pphoto.main
bash-3.1#


Note, doing this as root as it seems not to do anything usefull at all if I
run python setup develop as a user.

Any ideas? I must be missing something fundamental?

You need to put main.py into the pphoto package.

$ mkdir pphoto/
$ mv main.py pphoto/
$ touch pphoto/__init__.py

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 
P

Peter Chant

Robert said:
You need to put main.py into the pphoto package.

$ mkdir pphoto/
$ mv main.py pphoto/
$ touch pphoto/__init__.py

Thanks, it worked. Any ideas how to run the resulting scripts without
installing or running as root?

Pete
 
H

Heikki Toivonen

Peter said:
Thanks, it worked. Any ideas how to run the resulting scripts without
installing or running as root?

If you install as root, you should be able to run the scripts as normal
user. However, I don't recommend this approach since it could conflict
with your system Python packages.

I like using virtualenv to create isolated Python environments. I can
easily install whatever Python packages I want into each environment,
delete them when I am done with them or messed up etc.

http://pypi.python.org/pypi/virtualenv
 
E

Erik Vandamme

any ideas, I'm floundering - I don't quite get it.  I have the following
files, setup.py and main.py in a directory pphoto:
# more setup.py
from setuptools import setup, find_packages
setup(
     name = "Pphoto",
     version = "0.1",
     packages = find_packages(),
     # other arguments here...
     entry_points = {'console_scripts': ['foo = pphoto.main:HelloWorld',]}

bash-3.1# more main.py
def HelloWorld():
     print "Hello World!"
print "Odd world"
It does produce a script that simply crashes.
bash-3.1# foo
Traceback (most recent call last):
   File "/usr/bin/foo", line 8, in<module>
     load_entry_point('Pphoto==0.1', 'console_scripts', 'foo')()
   File "build/bdist.linux-i686/egg/pkg_resources.py", line 277, in
load_entry_point
   File "build/bdist.linux-i686/egg/pkg_resources.py", line 2098, in
load_entry_point
   File "build/bdist.linux-i686/egg/pkg_resources.py", line 1831, in load
ImportError: No module named pphoto.main
bash-3.1#
Note, doing this as root as it seems not to do anything usefull at all if I
run python setup develop as a user.
Any ideas?  I must be missing something fundamental?

You need to put main.py into the pphoto package.

$ mkdir pphoto/
$ mv main.py pphoto/
$ touch pphoto/__init__.py

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco
erik@erik-d2c:~/calibre-0.6.7$ mv main.py pphoto/
mv: cannot stat `main.py': No such file or directory
 
R

Robert Kern

any ideas, I'm floundering - I don't quite get it. I have the following
files, setup.py and main.py in a directory pphoto:
# more setup.py
from setuptools import setup, find_packages
setup(
name = "Pphoto",
version = "0.1",
packages = find_packages(),
# other arguments here...
entry_points = {'console_scripts': ['foo = pphoto.main:HelloWorld',]}

bash-3.1# more main.py
def HelloWorld():
print "Hello World!"
print "Odd world"
From various websites that should produce a script foo that runs HelloWorld.
It does produce a script that simply crashes.
bash-3.1# foo
Traceback (most recent call last):
File "/usr/bin/foo", line 8, in<module>
load_entry_point('Pphoto==0.1', 'console_scripts', 'foo')()
File "build/bdist.linux-i686/egg/pkg_resources.py", line 277, in
load_entry_point
File "build/bdist.linux-i686/egg/pkg_resources.py", line 2098, in
load_entry_point
File "build/bdist.linux-i686/egg/pkg_resources.py", line 1831, in load
ImportError: No module named pphoto.main
bash-3.1#
Note, doing this as root as it seems not to do anything usefull at all if I
run python setup develop as a user.
Any ideas? I must be missing something fundamental?

You need to put main.py into the pphoto package.

$ mkdir pphoto/
$ mv main.py pphoto/
$ touch pphoto/__init__.py

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
erik@erik-d2c:~/calibre-0.6.7$ mv main.py pphoto/
mv: cannot stat `main.py': No such file or directory

I was helping Peter Chant with his problem. You have a different problem. Why
are you trying to follow my advice verbatim for a completely different package?
What problem are you seeing?

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 
R

ryles

Thanks, it worked.  Any ideas how to run the resulting scripts without
installing or running as root?

Pete

--http://www.petezilla.co.uk

If you are using Python 2.6+ you have your own site-packages
directory, e.g. ~/.local/lib/python2.6/site-packages. So, if this
package is only for your own use, you can use easy_install's --install-
dir option to have setuptools install it there, and can also set --
script-dir to ~/bin, where your console script will go. This, and
other options are discussed here:

http://peak.telecommunity.com/DevCenter/EasyInstall#custom-installation-locations
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top