debugging during package development

Ben Finney ben+python at benfinney.id.au
Sat Aug 1 07:30:34 CEST 2015


Seb <spluque at gmail.com> writes:

> With lots of debugging to do, the last thing I'd want is to worry
> about the search path.

Short answer: you need ‘python3 ./setup.py develop’.

Medium-length answer: you need to add some infrastructure to get your
project to the point where you can run ‘python3 ./setup.py develop’.

Longer answer below.

> So I've been searching for better ways to work,
> but I can't seem hit the right keywords and come with all sorts of
> tangentially related stuff.

The Python module search path is an abstraction, with only a partial
relationship to the location of modules files in the filesystem.

The expectation is that a module (or a package of modules) will be
*installed* to a location already in the module search path (with
‘python ./setup.py .

This allows for cross-platform package management, especially on systems
that don't have a working OS package manager. The trouble is that it
does cause a significant learning curve for Python programmers, and is
an ongoing sore point of Python.

> I'm sure there must be some tool that sets up the development
> environment when the package source is not on `sys.path`. Any advice
> on this topic would be appreciated.

What you need is to tell Distutils which Python modules form your
project <URL:https://docs.python.org/3/library/distutils.html>.

Once you've got a working ‘setup.py’ for your project, run ‘python3
./setup.py develop’ to allow your packages to be run in-place while you
develop them.

-- 
 \        “I think it would be a good idea.” —Mohandas K. Gandhi (when |
  `\                    asked what he thought of Western civilization) |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list