Python Package: Difference between revisions
From charlesreid1
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
=Basics= | |||
==Basic Python Package Skeleton== | |||
A skeleton Python package takes the following structure: | A skeleton Python package takes the following structure: | ||
Revision as of 04:25, 19 March 2015
Basics
Basic Python Package Skeleton
A skeleton Python package takes the following structure:
myproject/
setup.py
myproject/
__init__.py
code.py
submodule/
somecode.py
morecode.py
tests/
test_code.py
test_somecode.py
test_morecode.py
Setup.py
Here's what the package setup file looks like:
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
config = {
'description': 'My Project',
'author': 'My Name',
'url': 'URL to get it at.',
'download_url': 'Where to download it.',
'author_email': 'My email.',
'version': '0.1',
'install_requires': ['nose'],
'packages': ['NAME'],
'scripts': [],
'name': 'projectname'
}
setup(**config)
Test_code.py
It is important to test your code. Here's a skeleton nose test suite:
from nose.tools import *
import NAME
def setup():
print "setup"
def teardown():
print "tear down"
def test_basic():
print "i run good"