[Numpy-discussion] setting package path
pearu at scipy.org
Tue Feb 28 22:35:02 CST 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:
> Then the first existing path name from the following list
> 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/.."
More information about the Numpy-discussion