Monday, November 3, 2014

Python Tip of the Year: pip install --editable .

Let's say you're developing an application in Python. Being a good citizen you've created a file setup.py that describes your application.

Kind of like this:
from setuptools import setup

setup(
    name='yourapp',
    author='Your name',
    version='0.0.1',
    description='Your app',
    packages=['yourapp'],
)
When developing an application you often want to install it into system/virtualenv site-packages directory. At the same time you don't want to run python setup.py install after every time you make a change. There is a simple solution.

Just cd into directory containing setup.py and run pip install --editable .

Slow motion instant replay: pip install --editable <period>. Trailing period is important.

Now your application is installed into site-packages via symlink (kind of) and you don't need to reinstall it after making a change. Just edit your code and site-packages will magically have a new version of your application.

1 comment:

  1. I like your blog, I read this blog please update more content on python, further check it once at python online training

    ReplyDelete