[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pygame] rpm creation (long)




Due to circumstances beyond my control (namely, a computer that emits
more smoke and loud banging noises with every passing moment), I have
to give up the job of creating rpm packages for pygame. In fact, I may
be knocked offline altogether, which is why I've typed up this little
guide. Hopefully, if I disappear completely, someone will find this
information helpful and take over the job of rpm maintainer.

If you run an rpm system (Redhat or Mandrake; there may be others),
please consider taking over this job.  Building rpms is pretty
painless and quite rewarding - I've been doing it ever since the
earliest days of pysdl, and I'll certainly miss it.

What follows is a step-by-step guide to producing rpms, the .spec file
I've been using, and a summary of some of the as-yet-unresolved issues
involved in rpm creation. If you have any questions, please write me
at silenus@telus.net, or try to find me in #pygame - I'm Futility, and
I'll try to stick around as long as I can.

==========================

First, a general overview. Building rpms requires two inputs - the
tar.gz source file that Pete gives us, and the pygame.spec file that
we create ourselves.  The outputs are a pygame-1.2.i386.rpm binary
package, and a pygame-1.2.src.rpm source package. These we send off to
Pete, and the rpm creation is done.

Of course, it's more complicated than that. If you've never really
worked with rpm packages before, the Maximum RPM book available online
from www.rpm.org will probably help. However, I'm going to try to
explain this as if you've never really looked into creating rpms at
all.

Here are the list of steps you go through to create the pygame rpm
packages.

1. First, you download the source distribution - the pygame-1.2.tar.gz
or whatever it ends up being called. You install it as if you were a
normal, non-rpm user; ie you type "python config.py; python setup.py
install" as root. Once pygame is installed, and you've confirmed that
it's working properly for you, you can go on to the next step. This
had me confused at first when I was learning rpm creation; I didn't
understand that you had to have the program installed before you could
create the installation package - that seems a little
redundant. However, it's true.

2. Now, copy the pygame-1.2.tar.gz thing you downloaded from Pete to
the /usr/src/redhat/SOURCES directory.

3. Now you need to edit the pygame.spec file. This file tells rpm what
to do with the source file mentioned in step 2. Here's the file:

------- file starts here - don't include this line -----------

%define name pygame
%define version 1.1
%define release 1

Name: %{name}
Version: %{version}
Release: %{release}
Source: http://pygame.seul.org/%{name}-%{version}.tar.gz
Summary: A Python module for interfacing with the SDL multimedia library
Copyright: LGPL Version 2
Group: System Environment/Libraries
URL: http://pygame.seul.org/
Requires: SDL >= 1.1.7
Packager: David Clark <silenus@telus.net>

Prefix: /usr

%description
pygame is a Python wrapper module for the SDL multimedia library, written by
Pete Shinners.  It contains python functions and classes that will allow you
to use SDL's support for playing cdroms, audio and video output, and keyboard,
mouse and joystick input. pygame also includes support for the Numerical
Python extension. pygame is the successor to the pySDL wrapper project, written
by Mark Baker.

Install pygame if you would like to write or play SDL games written in the
python language.

%package doc
Summary: pygame documentation and example programs
Group: Documentation
%description doc
pygame is a Python wrapper module for the SDL multimedia library, written by
Pete Shinners.  It contains python functions and classes that will allow you
to use SDL's support for playing cdroms, audio and video output, and keyboard,
mouse and joystick input. pygame also includes support for Numerical Python
extension. pygame is the successor to the pySDL wrapper project, written by
Mark Baker.

Install pygame-doc if you need the API documentation and example programs.

%prep
%setup

%build
python config.py
python setup.py build

%install
python setup.py install

%clean
rm -rf $RPM_BUILD_ROOT

%files
/usr/lib/python2.0/site-packages/pygame/UserRect.py
/usr/lib/python2.0/site-packages/pygame/__init__.py
/usr/lib/python2.0/site-packages/pygame/base.so
/usr/lib/python2.0/site-packages/pygame/bluebold.ttf
/usr/lib/python2.0/site-packages/pygame/bluebold.txt
/usr/lib/python2.0/site-packages/pygame/cdrom.so
/usr/lib/python2.0/site-packages/pygame/constants.so
/usr/lib/python2.0/site-packages/pygame/cursors.py
/usr/lib/python2.0/site-packages/pygame/display.so
/usr/lib/python2.0/site-packages/pygame/draw.so
/usr/lib/python2.0/site-packages/pygame/event.so
/usr/lib/python2.0/site-packages/pygame/font.so
/usr/lib/python2.0/site-packages/pygame/image.so
/usr/lib/python2.0/site-packages/pygame/imageext.so
/usr/lib/python2.0/site-packages/pygame/joystick.so
/usr/lib/python2.0/site-packages/pygame/key.so
/usr/lib/python2.0/site-packages/pygame/locals.py
/usr/lib/python2.0/site-packages/pygame/mixer.so
/usr/lib/python2.0/site-packages/pygame/mixer_music.so
/usr/lib/python2.0/site-packages/pygame/mouse.so
/usr/lib/python2.0/site-packages/pygame/rect.so
/usr/lib/python2.0/site-packages/pygame/rwobject.so
/usr/lib/python2.0/site-packages/pygame/surface.so
/usr/lib/python2.0/site-packages/pygame/surfarray.so
/usr/lib/python2.0/site-packages/pygame/surflock.so
/usr/lib/python2.0/site-packages/pygame/time.so
/usr/lib/python2.0/site-packages/pygame/transform.so
/usr/lib/python2.0/site-packages/pygame/version.py
/usr/include/python2.0/pygame/font.h
/usr/include/python2.0/pygame/mixer.h
/usr/include/python2.0/pygame/pygame.h

%files doc
%doc README.TXT WHATSNEW
%doc docs/
%doc examples/

%changelog
* Fri Jun 22 2001 David Clark
- Packaged 1.1 release.
* Fri Apr 6 2001 David Clark
- Packaged 1.0 release.
- Changed default install from /usr/local to /usr
* Tue Feb 13 2001 David Clark
- Packaged 0.9 release.
- Fixed typo in description
* Sat Jan 6 2001 David Clark
- Packaged 0.5 release.
* Fri Jan 5 2001 David Clark
- Packaged current cvs with config_unix.py fix from mailing list. Ready for 0.5.
* Thu Jan 4 2001 David Clark
- Included omitted joystick.so file. Doh!
* Thu Dec 14 2000 David Clark
- Packaged 0.4 release. Replaced autoconfiguration script with call to patched config.py.
* Mon Nov 20 2000 David Clark
- Packaged 0.3 release. Added -D_REENTRANT to the compiler flags.
* Sat Nov 18 2000 David Clark
- Divided distribution into binary and doc rpms.
* Sat Nov 4 2000 David Clark
- Packaged 0.2 release.
* Sun Oct 29 2000 David Clark
- added optional module autoconfiguration script. SRPMs will work now.
* Sun Oct 29 2000 David Clark
- initial spec file, supports binary package only.

------------ file ends here - don't include this line -----------

I'll step through each section of the pygame.spec file and let you
know what each section means, and how you'll have to change it.

-----------

%define name pygame
%define version 1.1
%define release 1

-----------

This section just establishes some variables. These variables are used
later in the file - by changing the values here, we won't have to
change them in multiple locations later. name is always pygame, don't
change that. version will probably be 1.2, it changes with each
release to match whatever Pete calls the latest version of
pygame. release is used only by the rpm maintainer - the first time
you release a certain version, it's 1. If you have to go back and fix
a bug and re-release, increment this to 2, and so on. Every time you
issue a new package, and Pete doesn't, you increase this by one. If
Pete eventually releases 1.3, you knock this back to 1.

------------------

Name: %{name}
Version: %{version}
Release: %{release}
Source: http://pygame.seul.org/%{name}-%{version}.tar.gz
Summary: A Python module for interfacing with the SDL multimedia library
Copyright: LGPL Version 2
Group: System Environment/Libraries
URL: http://pygame.seul.org/
Requires: SDL >= 1.1.7
Packager: David Clark <silenus@telus.net>

----------------------

This section is called the 'Preamble', and just lets rpm know a few
things about the package. Most of the fields are
self-explanitory. You'll want to change the Packager: field to your
own e-mail address and name.  You'll notice that Requires only
mentions SDL, not sdl_image or sdl_ttf - that's because those are
optional packages; pygame can live without them.  It also doesn't
mention Python, which is weird. However, there are currently so many
different Python packages out there (many different versions, and
package names like BeOpen, PythonLabs and Activestate). I couldn't
figure out a way to Require a package without possibly excluding
someone who'd just installed a package I didn't know about.

------------------------

Prefix: /usr

------------------------

This line indicates that the package expects everything to be
installed under /usr - in other words, it expects Python itself to be
installed under /usr/bin and /usr/lib. This is a bit tricky, sinceAcActivestate released a Python rpm that installs python in
/usr/local/bin and /usr/local/lib - a real no-no. I've tried to
accomodate this as best I can by including the above line; this lets
people install pygame with rpm -Uvh --prefix=/usr/local if they want
pygame to be installed into /usr/local/lib. If this is confusing, I
don't blame you - read about Relocatable Packages in Maximum
RPM. Basically, I've just tried to give people a little added
flexibility in where they install pygame to compensate for some broken
Python installations out there.

-----------------------------

%description
pygame is a Python wrapper module for the SDL multimedia library, written by
Pete Shinners.  It contains python functions and classes that will allow you
to use SDL's support for playing cdroms, audio and video output, and keyboard,
mouse and joystick input. pygame also includes support for the Numerical
Python extension. pygame is the successor to the pySDL wrapper project, written
by Mark Baker.

Install pygame if you would like to write or play SDL games written in the
python language.

%package doc
Summary: pygame documentation and example programs
Group: Documentation
%description doc
pygame is a Python wrapper module for the SDL multimedia library, written by
Pete Shinners.  It contains python functions and classes that will allow you
to use SDL's support for playing cdroms, audio and video output, and keyboard,
mouse and joystick input. pygame also includes support for Numerical Pythonexextension. pygame is the successor to the pySDL wrapper project, written by
Mark Baker.

Install pygame-doc if you need the API documentation and example
programs.

---------------------------------

This section gives us verbose text descriptions of two packages we'll
be building. The first one is the standard pygame package I mentioned
before; the second is the 'doc' package I haven't yet
mentioned. Basically, I wanted to give people the ability to just
download pygame, without downloading the docs or the example programs,
in case they're just a user, and they don't care about development.
In order to do this, I created a doc package using the %package doc
thingy - it will create a pygame-doc-1.2.rpm package later. Don't
worry about this yet - neither of these sections will need to be
changed unless Pete dramatically changes pygame in the future.

----------------------


%prep
%setup

%build
python config.py
python setup.py build

%install
python setup.py install

%clean
rm -rf $RPM_BUILD_ROOT

------------------------

This section comprise the actual bash commands needed to install
pygame. This section used to be much more elaborate, but distutils
have allowed us to reduce it to the few lines you see here. The five
sections listed - each starts with a percent sign, have to stay the
way they are. The commands listed under each header are the commands
necessary to accomplish that particular task. For example, if the user
types rpm -i pygame-1.2.i386.rpm, the commands "python config.py;
python setup.py build; python setup.py install" will be executed by
rpm. This shouldn't need to be changed unless distutils changes
dramatically.

--------------------------

%files
/usr/lib/python2.0/site-packages/pygame/UserRect.py
/usr/lib/python2.0/site-packages/pygame/__init__.py
/usr/lib/python2.0/site-packages/pygame/base.so
/usr/lib/python2.0/site-packages/pygame/bluebold.ttf
/usr/lib/python2.0/site-packages/pygame/bluebold.txt
/usr/lib/python2.0/site-packages/pygame/cdrom.so
/usr/lib/python2.0/site-packages/pygame/constants.so
/usr/lib/python2.0/site-packages/pygame/cursors.py
/usr/lib/python2.0/site-packages/pygame/display.so
/usr/lib/python2.0/site-packages/pygame/draw.so
/usr/lib/python2.0/site-packages/pygame/event.so
/usr/lib/python2.0/site-packages/pygame/font.so
/usr/lib/python2.0/site-packages/pygame/image.so
/usr/lib/python2.0/site-packages/pygame/imageext.so
/usr/lib/python2.0/site-packages/pygame/joystick.so
/usr/lib/python2.0/site-packages/pygame/key.so
/usr/lib/python2.0/site-packages/pygame/locals.py
/usr/lib/python2.0/site-packages/pygame/mixer.so
/usr/lib/python2.0/site-packages/pygame/mixer_music.so
/usr/lib/python2.0/site-packages/pygame/mouse.so
/usr/lib/python2.0/site-packages/pygame/rect.so
/usr/lib/python2.0/site-packages/pygame/rwobject.so
/usr/lib/python2.0/site-packages/pygame/surface.so
/usr/lib/python2.0/site-packages/pygame/surfarray.so
/usr/lib/python2.0/site-packages/pygame/surflock.so
/usr/lib/python2.0/site-packages/pygame/time.so
/usr/lib/python2.0/site-packages/pygame/transform.so
/usr/lib/python2.0/site-packages/pygame/version.py
/usr/include/python2.0/pygame/font.h
/usr/include/python2.0/pygame/mixer.h
/usr/include/python2.0/pygame/pygame.h

--------------------

This is the files section of the spec file for the main pygame rpm
package. This section contains the absolute paths to each file
included in the normal pygame package, the one normal users will
install. Note that it is all the files in the
/lib/python2.0/site-packages/pygame directory, and all the files in
the /include/python2.0/pygame directory. Note also that there are no
.pyd files - we'll just give them the .py files and let them compile
their own versions locally the first time they run a pygame program.

This is the section that requires the most attention. Pete
periodically extends pygame, adding new modules to it. After you
install pygame in step 1, check to make sure that all the files in the
directories listed above are listed in the %files section - if you
miss some, they won't be included in the package you create.

------------------------

%files doc
%doc README.TXT WHATSNEW
%doc docs/
%doc examples/

-----------------------

These are the files that go in the pygame-doc package. They work a
little differently than the above listing - these paths are relativetoto the pygame-1.2 path that the source tar.gz creates. This shouldn't
change unless Pete adds another text file to the mix, or renames his
doc directory, for example. Now that I think of it, where is the
LICENSE file?? Why isn't that in there? It should be.

-------------------------

%changelog
* Fri Jun 22 2001 David Clark
- Packaged 1.1 release.
* Fri Apr 6 2001 David Clark
- Packaged 1.0 release.
- Changed default install from /usr/local to /usr
* Tue Feb 13 2001 David Clark
- Packaged 0.9 release.
- Fixed typo in description
* Sat Jan 6 2001 David Clark
- Packaged 0.5 release.
* Fri Jan 5 2001 David Clark
- Packaged current cvs with config_unix.py fix from mailing list. Ready for 0.5.
* Thu Jan 4 2001 David Clark
- Included omitted joystick.so file. Doh!
* Thu Dec 14 2000 David Clark
- Packaged 0.4 release. Replaced autoconfiguration script with call to patched config.py.
* Mon Nov 20 2000 David Clark
- Packaged 0.3 release. Added -D_REENTRANT to the compiler flags.
* Sat Nov 18 2000 David Clark
- Divided distribution into binary and doc rpms.
* Sat Nov 4 2000 David Clark
- Packaged 0.2 release.
* Sun Oct 29 2000 David Clark
- added optional module autoconfiguration script. SRPMs will work now.
* Sun Oct 29 2000 David Clark
- initial spec file, supports binary package only.

----------------------------

The last section is the changelog. Every time you alter this spec
file, add an entry to this section, newest entries at the top. Just
follow the format here, and it'll be fine.

-----------------------------

4. Ok, you've edited your .spec file, and you're happy with the
changes you've made. Now, copy the spec file to /usr/src/redhat/SPECS

5. So pygame is installed, the spec file is in /usr/src/redhat/SPECS,
and the source tar.gz is in /usr/src/redhat/SOURCES.  Go to
/usr/src/redhat/SPECS, and type the following (as root):

rpm -ba pygame.spec

6. Several pages of text will flow by as the packages are
created. Hopefully (I pray) there will be no errors - if there are,
I'll try to help, but there's not much I can do from Windows. If all
goes well, you will have the following packages:

/usr/src/redhat/RPMS/i386/pygame-1.2.i386.rpm/u/usr/src/redhat/RPMS/i386/pygame-doc-1.2.i386.rpm
/usr/src/redhat/SRPMS/pygame-1.2.src.rpm

7. Rename pygame-1.2.i386.rpm to pygame-python20-1.2.i386.rpm. This is
necessary because of a ugly little problem with python and rpm. You
see, the spec file I've given you has the python library directory
listed as /usr/lib/python2.0/site-packages/pygame. Note the 2.0 - each
version of python has a different directory it installs libraries like
pygame to. Ugh. As a result, we need a different spec file for each
version of python. That means that you'll have to do the above, then
go back to the spec file, and change all the 2.0's in the %files
section to 2.1's, then redo steps 4,5 and 6 above. Then rename the
pygame-1.2.i386.rpm file to pygame-python21-1.2.i386.rpm. Then do it
all again for python 2.2. Yucky, huh? Unfortunately, there's no way
around it. Luckily, only the .i386.rpm file, the binary package, needs
to be redone like this.

8. Yay. Now you have the following:

/usr/src/redhat/RPMS/i386/pygame-python20-1.2.i386.rpm
/usr/src/redhat/RPMS/i386/pygame-python21-1.2.i386.rpm
/usr/src/redhat/RPMS/i386/pygame-python22-1.2.i386.rpm
/usr/src/redhat/RPMS/i386/pygame-doc-1.2.i386.rpm
/usr/src/redhat/SRPMS/pygame-1.2.src.rpm

Upload those to contrib - I think it's at www.pygame.org/ftp/contrib,
and let Pete know about it. Bask in the adulation that comes with
being part of the team :)



Issues:

There are a few problems with the current pygame package situation
that I haven't been able to solve. Future maintainers will have to
keep these issues in mind, and solve them, if possible:

1. pygame is a modular library - it's perfectly possible to install it
without image or ttf support. That said, I've always had the policy of
'Make the binary packages include everything necessary to run all the
example programs'. As a result, people really need Numeric, PyOpenGl,
SDL_ttf, SDL_image and SDL_mixer in order to install the binary
package. The only alternative is to create a ton of additional
packages - pygame.rpm, pygame-image.rpm, pygame-ttf.rpm,
pygame-numeric.rpm, and so on. A user would have to download all the
packages compatible with their setup, then install them. This is
perhaps more correct, but less convenient. When you inherit pygame rpm
packaging, you inherit this dilemna as well.

Note this has nothing to do with the src.rpm, which will configure
itself automatically depending on what you have installed. Only the
binary packages are an issue.

2. A resolution has to be found for the problem mentioned in step 7
above - python has too many library directories - at least these, and
perhaps more:

/usr/lib/python2.0/site-packages
/usr/lib/python2.1/site-packages
/usr/lib/python2.2/site-packages

Ideally, these would all be symlinked to
/usr/lib/python/site-packages; in practice this is almost never
done. Until this situation is resolved, a binary package will have to
be created for each of the above situations.

Note that this problem combines with problem 1 above - each of the
additional packages mentioned would need three versions to accomodate
the different python versions available.

Again, this problem doesn't affect the src.rpm, which automatically
does the right thing (thank you distutils).

3. The doc package is designated as pygame-doc-1.2.i386.rpm, which is
incorrect; there's nothing architecture-specific about the docs or
examples. This should instead be pygame-doc-1.2.noarch.rpm. I didn't
figure out how to do this during my stint as rpm guy; considering that
for the last four months I've been running debian, it's a miracle I
got rpms built at all.


That's it. I hope this little write-up has interested you - rpm
maintainer is a pretty cool job. It lets you contribute in a fairly
high-profile way every couple of months, and doesn't require much more
than a little text file editing and a couple of bash commands.  I
can't predict how long my nearly-dead computer will keep running, but
if you have any questions, I'll try to help.

-- 
David Clark
silenus@telus.net


____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org