[Numpy-discussion] setting package path
Pearu Peterson
pearu at scipy.org
Tue Feb 28 22:35:02 EST 2006
On Wed, 1 Mar 2006, Stefan van der Walt wrote:
> In numpytest.py, set_package_path is provided for handling path
> changes while doing unit tests. It reads
>
> def set_package_path(level=1):
> """ Prepend package directory to sys.path.
>
> set_package_path should be called from a test_file.py that
> satisfies the following tree structure:
>
> <somepath>/<somedir>/test_file.py
>
> Then the first existing path name from the following list
>
> <somepath>/build/lib.<platform>-<version>
> <somepath>/..
>
> is prepended to sys.path.
> ...
>
> However, the line that supposedly calculates "somepath/.." is
>
> d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))
>
>
> which calculates "somepath". Which is wrong: the docstring, the code
> or my interpretation?
You have to read also following code:
d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))
if not os.path.isdir(d1):
d1 = os.path.dirname(d) # <- here we get "somepath/.."
sys.path.insert(0,d1)
Pearu
More information about the NumPy-Discussion
mailing list