0

I'm developing a CLI tool in python using docopt and packaging via wheels.

I can build and install the wheel package locally with the following:

python setup.py sdist bdist_wheel
pip install dist/mypackage.whl

I can then test my package from the command line

mypackage --v

This works fine, but does not provided a very practical dev / test loop. In order to view any changes I need to uninstall the package, rebuild it and reinstall it.

Is there a more practical way to easily test and run changes locally during development?

duncanhall
  • 11,035
  • 5
  • 54
  • 86
  • While it is probably an overkill, you can try to use Docker – Gianluca Jan 25 '17 at 10:31
  • I don't see that docker is a solution here. I don't need to virtualize anything or run my package in a container. I need my code changes to be automatically compiled and available to test in the CLI (or similar) – duncanhall Jan 25 '17 at 10:43
  • I understand. What you probably need is something like `nodemon`, which can be used with python to some extend (or at least, this is what the documentation say). Since as far as I know there is not a python equivalent, my suggestion is to use Docker to build a clean environment to test your package – Gianluca Jan 25 '17 at 11:17
  • Thanks but I think this is still the wrong direction and unnecessary. What I need is the ability to install the python package but pointing to my source, such that when the package runs, it is my source code that gets interpreted. – duncanhall Jan 25 '17 at 11:47

2 Answers2

1

Failing any better solution I have simply combined uninstall, build and install into a make task:

reload:
    pip uninstall -y mypkg && python setup.py sdist bdist_wheel && pip install dist/mypkg.whl

Now simply running make reload will achieve what I need.

duncanhall
  • 11,035
  • 5
  • 54
  • 86
0

and by using pip install --editable . in your dev folder?

You will have your package installed in editable mode, and continue to develop without having to resinstall all.