[Distutils] Distributing python applications

Pehr Anderson pehr@eink.com
Wed Jul 11 11:07:00 2001


Dear Tessa, 

This may be helpful. It is a setup.py file for solarwolf,
modified to setup a gnome icon and such.
I use "glob.glob" to grab the filenames of all the datafiles
in each subdirectory.  The script is installed in the right place 
as specified in my setup.cfg
Hope this helps! 

	-pehr


#!/usr/local/bin/python
  
#
# setup.py
#   This file requires python-2.1 to be installed
#   If you are using redhat-7.1 you must set your
#   ~/.bash_profile path such that it calls /usr/local/bin first.
#   Otherwise, you will not be able to build or install the rpm.
#   something like "export PATH=/usr/local/bin:$PATH"
#   Read more at http://python.org/sigs/distutils-sig/doc/
# 
DESCRIPTION = """\
Solarwolf is a remake of my childhood favorite, SolarFox, back on the
Atari 2600. It features quick and smooth fullscreen 800x600 graphics.
There is alpha transparent blitting, colorkeying, animated sprites,
scrolling starfield background, antialiased font rendering, and more.
The sound system supports multiple sound channel playback, along wiht
streming music support. It also supports input form keyboard or joystick.
"""

import glob,os,os.path,string
from distutils.core import setup
# get version data from code/game.py, must have code/__init__.py
import code.game

# Include our data files
#files = string.split(os.popen("find data -type f").read(),"\n")[:-1]
files = glob.glob('data/*')
files.remove('data/audio')
files.remove('data/music')
DATA_FILES = [
              ('data', files),
              ('data/audio', glob.glob('data/audio/*')),
              ('data/music', glob.glob('data/music/*')),
              ('/etc/X11/applnk/Games', ['solarwolf.desktop']),
             ]

setup ( name="solarwolf",
        version = code.game.version,
        license = "GPL",
        author = "Pete Shinners",
        author_email = "pete@shinners.org",
        url = "http://pygame.org",
        description = "A great game written using pygame",
        long_description = DESCRIPTION,
        packages = ['', 'code'],
        scripts = ['solarwolf'],
        data_files = DATA_FILES,
      )


#
# setup.cfg
#
  
[install]
install_lib=/usr/local/share/solarwolf
install_data=/usr/local/share/solarwolf
install_scripts=/usr/local/bin
  
[sdist]
formats = gztar


[bdist_rpm]
release = 1
packager = Pehr Anderson <pehr@alum.mit.edu>
provides = solarwolf
requires = python SDL pygame
distribution_name = redhat-7.1
doc_files =     lgpl.txt
                readme.txt

changelog =
  * Fri Jul 06 2001 Pehr Anderson <pehr@alum.mit.edu> 0.1.0-1
  - created setup using distutils for python 2.1 and redhat 7.1







On Fri, Jul 06, 2001 at 05:41:52PM -0700, Tessa Lau wrote:
> 
> I'm switching from autoconf to the distutils for building and
> installing my Python application.  This application includes one
> pure-python package, one impure extension package, and various modules
> in the root package.
> 
> I've figured most of it out except for two things that I used to do
> using autoconf:
> 
> 1) Install two python scripts in a system-wide bin directory (not
> site-packages)
> 
> 2) Create a new .py file by doing textual substitution on a .py.in file
> 
> Suppose my program is called blarg.  I want users to be able to run
> "blarg" from their command prompt.  The file blarg is a python script
> that imports modules from blarg's library directory, which is usually
> something like ${exec_prefix}/lib/blarg-X.Y, where X.Y is the blarg
> version number.
> 
> The reason I used textual substitution is so that I only have to
> change the version string in one place, and the same string is
> propagated to everyplace that needs it, including the two main
> application scripts that are installed in ${prefix}/bin.
> 
> How can I do this using distutils?
> 
> --Tessa
> 
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-SIG@python.org
> http://mail.python.org/mailman/listinfo/distutils-sig

-- 
Pehr Anderson, E Ink Corporation, 617-499-6019, http://eink.com