On May 14, 1:26 pm, kj <so...@987jk.com.invalid> wrote: > I've written a tiny module that I'd like to make available online > from my website. This module is not "production-grade" code; it > is meant only as an illustration, but still I'd like to make its > download and installation as painless as possible. > > I could simply bundle everything into a .tgz file, but I'd like > the distribution to conform to the expectations of Python users, > as far as the installation sequence is concerned. I'm fairly new > to Python, and would appreciate your advice on this last point.
First of all, if it's just a single module, I recommend that one of the options is to allow the file to be downloaded as-is, with no packaging, because a lot of Python users would find it least cumbersome to simply drop the file right into the site-packages directory. The README file would be a separate download or just a page on the website. For more official-looking packages, you want to create a setup.py file that lists your module's build information and meta-information. Read the section of the Python documentation entitled "Distributing Python Modules" for information on how to write a setup file. Once you write it, you can run python setup.py sdist and it'll build a distrribution for you. > The module has only one non-standard dependency, described by the > following code: > > if sys.version_info[:2] >= (2, 6): > import json > else: > import simplejson as json > > If possible, I'd like to make distribution procedure such that if > necessary it also installs json or simplejson (as the case may be). Next recommendation: just tell your users to download and install json if they want to use the module. A small demo module shouldn't be taking the initiative to install a fairly large package on the user's behalf. Furthermore, some users have extreme hatred for software that "helpfully" downloads and installs other packages without asking first. If you want to proceed along these lines in spite of this, the way to do it is to add some information to setup.py that lists dependencies. There is a script, easy_install.py, that uses this information to install dependencies automatically. However, I don't know the details of how to do that. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list