[reportlab-users] More 2.2 questions - package rearrangement

Dirk Holtwick dirk.holtwick at gmail.com
Mon Sep 1 12:45:35 EDT 2008


Robin Becker schrieb:

> OK so what packages get built with this scheme? reportlab is a package,

> but rl_addons is just a folder containing sources for two extensions.

> Surely I have to refer to those codes in the same way as before.


A package usually resides in its own namespace. If import will be done
like this:

import reportlab
import rl_addons

These are two packages. In setup.py they get defined more or less like this:

packages = [
"reportlab",
"rl_addons",
],

More on setuptools here:
<http://peak.telecommunity.com/DevCenter/setuptools>


> what actually gets executed when this happens? There is presumably some

> standard entry point, but looking in the 2.5 "Distributing Python

> Modules" stuff I can't see the word test anywhere in the index.


Get more informations from here:
<http://peak.telecommunity.com/DevCenter/setuptools#test-build-package-and-run-a-unittest-suite>


> Another thing which came up in my preliminary testing of this scheme is

> that we need to refer to files which are either in the docs folder or

> the tests folder. Previously we did this by assuming that the container

> was a package that could be imported. Now if tests/docs etc are not

> packages I need to have some more utilities to locate my files. What's

> the correct way to do that? I know that normally people will cd into

> tests to do python runAll.py, but nothing prevents them from doing stuff

> like python verylongpath/tests/runAll.py so presumably I need to obtain

> my script path and ensure it(or its parent) is on the path so I can

> locate my modules etc etc.


You can assume that the directory structure will be as defined before:

src/
test/
fonts/ ;)

So you may find the parent directory from runAll.py like this:

import os.path
parent = os.path.join(os.path.dirname(__file__), os.pardir)

A developer should also register his working version on his machine like
this:

$ python setup.py develop

This makes programmers live a lot easier ;)

Dirk


More information about the reportlab-users mailing list