Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to make a Python Library without Publishing it?

I am trying to make a Python Library that I can use import statements with, but I do not want them published, I just want them stored on my local server. If there is a better way to do this without creating a library, I am all for it, my scripts are just getting too long as I am copying functions from another script.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

This can be seen as an opinion-based question, but I also see what you technically struggle with, because I have been through this process.

My advise is to create a pip package (via proper definition of a setup.py file as if you would publish it. See for instance here for advise: https://packaging.python.org/en/latest/tutorials/packaging-projects/.

Then, instead of publishing it, you can just install it on your local system.
The easiest way to do that is to run

pip install -e .

in the main project directory. This will use the files in your project folder, so that changes in the code of that package will take effect right away.

One hack more "professional", you can establish your own in-house pip server, see here: https://www.linode.com/docs/guides/how-to-create-a-private-python-package-repository/.

Note: I also created conda packages, but imho it is then not straight forward to a) package in conda and b) host your own private channel. Maybe I am wrong.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading