I'd like to share a program I'm in the process of writing. Is there any way to distribute it along with the modules it uses? Ideally, something that will pull all of the necessary modules from the main file and create a new directory with everything needed to run from source. I do not want to compile and would like to be able to simply share the source and modules in a .zip file or on gitub.

Thanks!

有帮助吗?

解决方案

Make a requirements.txt file that will list all the Python libraries your project requires.

Ideally you'd have a virtualenv for your project, and all the dependencies of your project installed in it - in that case you can simply use pip freeze > requirements.txt to (re)generate it.

Then someone will be easily able to pull the dependencies from PyPI using pip install -r requirements.txt.

http://www.pip-installer.org/en/latest/cookbook.html


Or you could go a step further and make a real Python package? This way it will be very easy to install it directly from github using a single pip install command. Or you could even share it to PyPI.

There's a lot of writing about Python packaging that you might want to read up, for example:

其他提示

Here's a link to another SO thread that shows how you could create and structure a folder with your modules and then zip the folder and share it; Python: sharing common code among a family of scripts

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top