Need advice on distributing small module

K

kj

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.

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).

The actual package would contain the module file and a README file.

Is there a standard tool I can use to create this distribution?

TIA!

kynn
 
C

Carl Banks

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
 
K

kj

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] >=3D (2, 6):
=A0 =A0 import json
else:
=A0 =A0 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.


Thanks, that's very useful advice.

kynn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top