Jeremy Thanks. I needed that. CS On Tue, Sep 30, 2003 at 10:49:30PM -0400, Jeremy Hylton wrote:
On Tue, 2003-09-30 at 19:50, seberino@spawar.navy.mil wrote:
1. What goes into __init__.py files??? I know what setup.py contents are but I don't recall seeing advice on what to put in __init__.py.
You don't need to put anything into __init__.py files. They are necessary to make Python recognize a directory as a package, but they can be empty.
If you put code in __init__.py, it is executed when the package is imported, including the first time a submodule of a package is imported. It is sometimes useful to execute code here, but that's up to you.
2. I have a ton of data files to list in setup(...) with the data_files switch. Can I avoid listing EVERY file somehow??? Can I use a wildcard in the filename????
It can be tedious to list all the data files. The setup.py script is a regular Python script, though, so you can compute the full list from the wildcard. The glob module might do what you want or you can search for files using os.path.walk.
3. Will bdist_rpm install JUST pyc files (bytecode)??? Will sdist install JUST py (source) files??? What about installing source and bytecode?? (py and pyc)?? How do that and is THAT a good idea???
The bdist and sdist commands do not install anything. They generate distributions that can be used to install software. You probably know that, but I want to make sure we're on the same page.
An sdist distribution contains only .py files. The source distribution could work with many versions of Python, but .pyc files are tied to a particular version. The source distribution generates .pyc files when a user unpacks it and runs "python setup.py install".
I believe a bdist command will have the same effect. I'm not sure about bdist_rpm, but bdist_wininst only puts source files in the distribution.
4. If I tell setup(...) I have a package somewhere with packages = ["..."] does that mean it will get ALL files in that directory without me having to specify them individually??
It means all .py files. It will ignore any other file in the directory. Note that you have to explicitly include subpackages in the list.
What if I want to OMIT a file like the CVS directory?!?!
It gets skipped, because it isn't listed as a package. If you tried to list it as a package, it still wouldn't contain any .py files.
Note that it is a little tedious to get non-Python files installed with a package. If you want a data file to be included next to the .py file, you've got to go to a lot of trouble.
Jeremy
-- _______________________________________ Christian Seberino, Ph.D. SPAWAR Systems Center San Diego Code 2872 49258 Mills Street, Room 158 San Diego, CA 92152-5385 U.S.A. Phone: (619) 553-9973 Fax : (619) 553-6521 Email: seberino@spawar.navy.mil _______________________________________