473,386 Members | 1,835 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Organising a python project

Dear all,

Can anyone point me to a resource that describes the best way of
organising a python project? My project (gausssum.sf.net) is based
around a class, and has a GUI that allows 'easy-access' to the methods
of the class. What is the best or typical directory structure that
allows the easy creation of binary packages for linux and windows,
source distributions, etc.

Rather than make up my own way, I'd prefer to know if there is a
typical python way...

Regards,
baoilleach

Sep 19 '05 #1
6 1685
ba********@gmail.com wrote:
Dear all,

Can anyone point me to a resource that describes the best way of
organising a python project? My project (gausssum.sf.net) is based
around a class, and has a GUI that allows 'easy-access' to the methods
of the class.
Err... Unless it's a *very* simple project, having the project based on
a *single* class smells of GodClassAntipattern (I can't say for sure
without seeing the source of course, so this is most a a priori than a
judgement !-).
What is the best or typical directory structure that
allows the easy creation of binary packages
'binary packages' ?
for linux and windows,
source distributions, etc.

Rather than make up my own way, I'd prefer to know if there is a
typical python way...


Usually, a program project is made of one or more library modules,
eventually organized in packages, and a 'main' script that's the entry
point for the program [1]. Most Python projects being OSS, you can
examine existing projects.
[1] Note that this not Python specific. You'll find the same overall
organisation in C, C++, Java, etc...

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Sep 20 '05 #2
bruno modulix wrote:
ba********@gmail.com wrote:
What is the best or typical directory structure that
allows the easy creation of binary packages


somedir:
test/
test_product.py # Really do include tests
product.py
setup.py

Look at distutils documentation. Also read up on "Python Eggs."

You might consider doing it as a package under a you-specific name:

somedir:
yourname:
test/
test_product.py # See unittest module
__init__.py # can be empty (and often is), also might have a
# doc string, author, copyright, and license info
# and a line like: __version__ = "0.2"
product.py
setup.py

--Scott David Daniels
Sc***********@Acm.Org
Sep 20 '05 #3
ba********@gmail.com wrote:
Dear all,

Can anyone point me to a resource that describes the best way of
organising a python project? My project (gausssum.sf.net) is based
around a class, and has a GUI that allows 'easy-access' to the methods
of the class. What is the best or typical directory structure that
allows the easy creation of binary packages for linux and windows,
source distributions, etc.

Rather than make up my own way, I'd prefer to know if there is a
typical python way...

Regards,
baoilleach

Here's what I've settled on for windows. This also keeps my src dir
clean and separate form all the additional install files needed. I don't
use automatic version control or CVS yet, but this seems to work well
enough for me. You could probably just add the neccisary script to
create linux distribution as well.

projectname <- main project directory

projectname1 <- version dir
dist <- py2exe output dir
docs <- addition documents, license, etc, dir
icons <- icons file(s) for exe file dir
src <- stand alone python source dir
notes <- addition development notes dir
Output <- inno setup output dir
makeexe.py <- py2exe script
pack.iss <- inno setup script

projectname2 <- next version...
... # copy the previous version to start.
...
Below is my basic py2exe script. You'll need to change it to suite your
own needs of course. The rmtree is my own module to remove directories
and contents. The newest version of py2exe I think does a better job of
cleaning up I think.

Cheers,
Ron

# makeexe.py
"""
Create a stand alone distribution using py2exe.
"""

from distutils.core import setup
import py2exe
import sys
import os
from mytools import rmtree

sys.path += ['.\\src']

try: rmtree.rmtree('dist')
except OSError: pass

try: rmtree.rmtree('build')
except OSError: pass

# Avoid having to use the command line.
# If run without args, build executables, in quiet mode.
if len(sys.argv) == 1:
#sys.argv.append("-h") # show options
sys.argv.append("py2exe")

opts = {
"py2exe": {
"optimize": "2",
}
}

setup(
options = opts,
name = 'Aztec',
windows = [{
"script": "src\\aztec.py",
"icon_resources": [(1, "icons\\aztec.ico")],
}]
)

os.rename('dist\\aztec.exe', 'dist\\aztec.scr')

try: rmtree.rmtree('build')
except OSError: pass

Sep 20 '05 #4
Thanks for the info, guys. Noel

Sep 21 '05 #5
Thanks for the info, guys. Noel

Sep 21 '05 #6
I don't know about a typical python way, but i'd like to know as well
;)

Personally i have a project for my project foo, which has
foo/__init__.py # with all the other modules
doc/ # documentation is always a good idea
script/ # everything executable, which later goes into 'bin'
directories by installing
setup.py
README, INSTALL, ... and other standard stuff

Of course often there is other stuff floating around in the base
directory, like some quick test scripts or sketches. And then my
version control system has an additional directory.

My tests are mostly within the modules.

def test():
return True
if __name__ == "__main__":
test()

My __init__.py tests every module, if executed directly. So far my
system works. It probably would be good to seperate tests, if they get
bigger.

Sep 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

38
by: kbass | last post by:
In different articles that I have read, persons have constantly eluded to the productivity gains of Python. One person stated that Python's productivity gain was 5 to 10 times over Java in some in...
36
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but...
1
by: Nick Evans | last post by:
Hey all, I am currently working on a simple program (small group membership database) just to get to grips with the language (bit of a newbie here :-)) and am wondering about the best way of...
0
by: Gargamel | last post by:
Hi. I wonder if someone can give me some advice on how to best organise my VS.Net projects. Say I have a web app with three main folders as follows: AppName (root) AppName\Admin...
1
by: jimburton | last post by:
I have a number of unit tests organised hierarchically, all of which inherit fixtures from a base class. To run these all at once I started out using from basic import map, directionalpan,...
158
by: Giovanni Bajo | last post by:
Hello, I just read this mail by Brett Cannon: http://mail.python.org/pipermail/python-dev/2006-October/069139.html where the "PSF infrastracture committee", after weeks of evaluation, recommends...
1
by: ganich | last post by:
Hello, i am looking for a javascript which could help me in organising my website. Ok the problem ... i have created index.html and made full layout in it. I use iframe in a table to view the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.