Installing a package in editable mode

As we have mentioned, you can install a package from GitHub and it will behave the same as any other installed package—it can be upgraded or uninstalled.

Often, however, you will want to use a package while developing it. It would be hard to do both in the normal installation routine; you'd have to either update or re-install the package every time you made any developmental changes, just to reflect those changes. To get around this, there is a great feature that keeps the advantages of both worlds—your code is treated as a package but can be easily modified in place. This feature is called editable mode. Essentially, it means the folder on your filesystem is registered as a package, and so the imported package will always reflect all the changes that you've made.

In order to reap these benefits, you have to have a repository of the package in question on your local machine. We obviously have our package, but it is also easy to pull the raw code via git clone my/package/url. Next, you open the terminal, and while being one step above the package folder, you type the following:

pip install -e wikiwwii

Boom! You have an editable package. You can test it in your Jupyter Notebook:

>>> import wikiwwii  

See? It behaves as if it is a properly installed package but you can make changes to your code and they will be immediately applied upon your next import.

At the time of writing this book, editable mode is not supported for the TOML-based packages. This should change soon.

This section helped you to install a package in editable mode, so now we should be good to try out some new code files!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.119.97