Development testing without reinstalling egg constantly?
Ned Batchelder
ned at nedbatchelder.com
Thu Jun 29 10:52:34 EDT 2017
On Thursday, June 29, 2017 at 10:04:30 AM UTC-4, Grant Edwards wrote:
> I've forked a copy of https://github.com/Roguelazer/muttdown and have
> been adding a few features and fixing a few bugs. It's meant to be
> installed using setup tools, and then invoked via /usr/bin/muttdown
> which looks like this:
>
> #!/usr/lib/python-exec/python2.7/python2
> # EASY-INSTALL-ENTRY-SCRIPT: 'muttdown==0.3','console_scripts','muttdown'
> __requires__ = 'muttdown==0.3'
> import re
> import sys
> from pkg_resources import load_entry_point
>
> if __name__ == '__main__':
> sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
> sys.exit(
> load_entry_point('muttdown==0.3', 'console_scripts', 'muttdown')()
> )
>
> The projects 'main.py' can't be run directly from the command line,
> since it contains code like this:
>
> from . import config
> from . import __version__
> __name__ = 'muttdown'
>
> [ stuff that does real work ]
>
> if __name__ == '__main__':
> main()
>
> I've hacked up the main.py bits shown above to allow it to be run
> directly in order to test changes without installing, but then I
> always have to remember to change it back before committing a change.
>
> This seems like the wrong way to do things, but I can't figure out
> what the _right_ way is. What's the Pythonic way to do deal with
> this?
$ pip install -e .
This will install the code in the current directory in "editable"
fashion. The files in the current directory *are* the installed
code, so when you edit them, you don't have to re-install.
--Ned.
More information about the Python-list
mailing list