Packing python programs with command line script

I'm trying to run my pet's Python project in a freed state, and I'm at a standstill when it comes to packing it.

Mark Pilgrim recommends this directory structure in Dive Into Python

httplib2/                 
|  
+--README.txt             
|  
+--setup.py               
|  
+--httplib2/              
    |  
    +--__init__.py  
    |  
    +--iri2uri.py

What I can’t understand if I have a script runner, that is, a command line executable, say foo, and my project name is foo, what should I call the internal package directory?

To give a concrete example, if I have

README.md
LICENSE
somefile1.py
somefile2.py
foo

What is the best way to pack this?

for instance

+--README.md
|
+--LICENSE
|
+--foo
|
+--foo/
    |
    +--somefile1.py
    |
    +--somefile2.py

Does not work due to a double name.

+3
source share
1 answer

You are doing it wrong ...

Here the structure should look like this:

foo 1.0/
| +--README.txt
| +--setup.py
| +--foo/__init__.py
| +--foo/iri2uri.py
| +--foo/httplib2/__init__.py
| +--foo/httplib2/bar.py

, . LICENSE, README, MANIFEST, setup.py. ( "/foo" ) .

, :

import foo                # represented by foo/__init__.py
import foo.iri2uri        # represented by foo/iri2uri.py
import foo.httplib2       # represented by foo/httplib2/__init__.py
import foo.httplib2.bar   # represented by foo/httplib/bar.py

. .

:

foo 1.0/
| +--/foo/iri2uri.py
| +--/foo/iri2uri/__init__.py

.

:

import foo.iri2uri

, , - , .

: ,

, .

examples/
| +--/foo.py

(foo).

+3

All Articles