Skip to content
Advertisement

How to make a Python Library without Publishing it? [closed]

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.

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement