What's the best layout for a python command line application?
Asked Answered
R

1

9

What is the right way (or I'll settle for a good way) to lay out a command line python application of moderate complexity? I've created a python project skeleton using paster, which gave me a few files to start with:

myproj/__init__.py
MyProj.egg-info/
 dependency_links.txt
 entry_points.txt
 PKG-INFO
 SOURCES.txt
 top_level.txt
 zip-safe
setup.cfg
setup.py

I want to know, mainly, where should my program entry point go, and how can I get it installed on the path? Does setuptools create it for me? I'm trying to find this in the HHGTP, but maybe I'm just missing it.

Rikkiriksdag answered 12/8, 2010 at 5:49 Comment(0)
E
7

You don't need to create all that, the .egg-info directory is generated by setuptools. You mention the command line, so I assumed you have a 'top level' script somewhere, let's say myproj-bin. Then this would work:

./setup.py
./myproj
./myproj/__init__.py
./scripts
./scripts/myproj-bin

And then put something like this in setup.py:

#! /usr/bin/python

from setuptools import setup

setup(name="myproj",
      description='shows how to create a python package',
      version='123',
      packages=['myproj'],  # python package names here
      scripts=['scripts/myproj-bin'],  # scripts here
      )

There's a lot more that you can do if your project is complex, the full manual of setuptools is here: http://peak.telecommunity.com/DevCenter/setuptools.

Emend answered 12/8, 2010 at 9:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.