How to work on a package
Roel Schroeven
roel at roelschroeven.net
Wed Feb 7 18:11:40 EST 2018
Rob Gaddi schreef op 7/02/2018 22:24:
> On 02/07/2018 12:34 PM, Roel Schroeven wrote:
>> dieter schreef op 7/02/2018 8:21:
>>> Likely, there are many ways to execute tests for your package.
>>> I am using "setuptools" for packaging (an extension
>>> of Python's standard "disutils"). Its "setup.py" supports the "test"
>>> command. This means, properly set up, I can run tests
>>> with "python setup.py test".
>> That can solve the testing issue, I guess, even though it feels weird to
>> me that the most straightforward way doesn't work.
>>
>> But testing is not the only issue. Often I'd like to start the Python
>> interpreter to load one of the modules in the package to try some things
>> out, or write a little script to do the same. These things are very
>> natural to me when writing Python code, so it seems very strange to me
>> that there's no easy way when working on a packages.
>>
>> Don't other people do that?
>>
>
> The state of Python packaging is... unfortunate. Improving, due to huge
> amounts of work by some very dedicated people, but still unfortunate.
>
> When I'm working on a module, the trick is to write a setup.py (using
> setuptools) from the very get-go. Before I write a single line of code,
> I've got a setup.py and the directory framework.
>
> Then you install the package using pip -e (or in practice --user -e).
> That's the missing piece. That way you can import your module from the
> interpreter, because it's now on the path, but its physical location is
> right there where you left it, complete with your VCS metadata and etc.
That seems like a workable solution. I'll try that out.
Thanks!
Best regards,
Roel
--
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
-- Isaac Asimov
Roel Schroeven
More information about the Python-list
mailing list