Robert Kern wrote:
Stanley A. Klein wrote:

>> I tried to do something to fix the numpy distutils bdist_rpm.py (by
>> trying to follow what was done in install.py) but it didn't work and I
>> got an error message I didn't understand.

>I'd like to help, but if you don't copy the exact error message here, I
can't.

OK, here is my revised numpy/distutils/commands/bdist_rpm.py (trying --
obviously not well -- to follow what was done in
numpy/distutils/commands/install.py:

import os
import sys

if 'setuptools' in sys.modules:
    import setuptools.command.bdist_rpm as old_bdist_rpm
    class bdist_rpm(old_bdist_rpm):
        pass

else:
    from distutils.command.bdist_rpm import bdist_rpm as old_bdist_rpm

    class bdist_rpm(old_bdist_rpm):

        def _make_spec_file(self):
            spec_file = old_bdist_rpm._make_spec_file(self)

            # Replace hardcoded setup.py script name
            # with the real setup script name.
            setup_py = os.path.basename(sys.argv[0])
            if setup_py == 'setup.py':
                return spec_file
            new_spec_file = []
            for line in spec_file:
                line = line.replace('setup.py',setup_py)
                new_spec_file.append(line)
            return new_spec_file

And here is the error message I got (using the kiva setup.py):

[EMAIL PROTECTED] enthought.kiva_2.0]$ python setup.py bdist_rpm
Traceback (most recent call last):
  File "setup.py", line 2, in ?
    from numpy.distutils.core import setup
  File "/usr/lib/python2.4/site-packages/numpy/distutils/core.py", line
32, in ?    from numpy.distutils.command import bdist_rpm
  File
"/usr/lib/python2.4/site-packages/numpy/distutils/command/bdist_rpm.py",
line 6, in ?
    class bdist_rpm(old_bdist_rpm):
TypeError: Error when calling the metaclass bases
    module.__init__() takes at most 2 arguments (3 given)

BTW, below is what the unpackaged files error looks like (with a traceback
generated by having the DISTUTILS_DEBUG environment variable set).  In a
much earlier thread I learned that this can usually be resolved by setting
[install] optimize=1 in setup.cfg.
---------------------------------------------------------------------------
    Installed (but unpackaged) file(s) found:
   /usr/lib/python2.4/site-packages/enthought/__init__.pyc
   /usr/lib/python2.4/site-packages/enthought/__init__.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/benchmark.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/benchmark.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/conv.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/conv.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/dash.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/dash.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/lion.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/lion.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/lion_data.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/lion_data.pyo
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/polygon_hit_test.pyc
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/polygon_hit_test.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/rect.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/rect.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/simple.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/simple.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/simple2.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/simple2.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/simple_clip.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/simple_clip.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/star.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/star.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/star1.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/star1.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/star2.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/star2.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/star_path.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/star_path.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/sub_path.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/sub_path.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/text_ex.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/text_ex.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/tk_ex.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/tk_ex.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/wx_brain.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/wx_brain.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/wx_demo.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/wx_demo.pyo
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/wx_image_copy.pyc
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/wx_image_copy.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/wx_lines.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/wx_lines.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/wx_lion.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/examples/wx_lion.pyo
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/affine_matrix_test_case.pyc
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/affine_matrix_test_case.pyo
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/clip_to_rect_test_case.pyc
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/clip_to_rect_test_case.pyo
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/compiled_path_test_case.pyc
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/compiled_path_test_case.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/gcmemtest.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/gcmemtest.pyo
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/graphics_context_test_case.pyc
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/graphics_context_test_case.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/image_test_case.pyc
 
/usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/image_test_case.pyo
 
/usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/join_stroke_path_test_case.pyc
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/join_stroke_path_test_case.pyo
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/points_in_polygon_test_case.pyc
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/points_in_polygon_test_case.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/rgba_test_case.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/rgba_test_case.pyo
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/stroke_path_test_case.pyc
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/stroke_path_test_case.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/test_arc.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/test_arc.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/test_draw_dash.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/test_draw_dash.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/test_ft.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/test_ft.pyo
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/test_graphics_context_system.pyc
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/test_graphics_context_system.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/test_image3.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/test_image3.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/test_save.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/test_save.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/test_utils.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/test_utils.pyo
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/unicode_font_test_case.pyc
   
/usr/lib/python2.4/site-packages/enthought/kiva/agg/tests/unicode_font_test_case.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/tests/affine_test_case.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/tests/affine_test_case.pyo
   
/usr/lib/python2.4/site-packages/enthought/kiva/tests/basecore2d_test_case.pyc
   
/usr/lib/python2.4/site-packages/enthought/kiva/tests/basecore2d_test_case.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/tests/mac_simpletest.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/tests/mac_simpletest.pyo
   /usr/lib/python2.4/site-packages/enthought/kiva/tests/macport_test.pyc
   /usr/lib/python2.4/site-packages/enthought/kiva/tests/macport_test.pyo
Traceback (most recent call last):
  File "setup.py", line 108, in ?
    version = '2.0b1',
  File "/usr/lib/python2.4/site-packages/numpy/distutils/core.py", line
174, in setup
    return old_setup(**new_attr)
  File "/usr/lib/python2.4/distutils/core.py", line 149, in setup
    dist.run_commands()
  File "/usr/lib/python2.4/distutils/dist.py", line 946, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.4/distutils/dist.py", line 966, in run_command
    cmd_obj.run()
  File "/usr/lib/python2.4/distutils/command/bdist_rpm.py", line 365, in run
    self.spawn(rpm_cmd)
  File "/usr/lib/python2.4/distutils/cmd.py", line 398, in spawn
    spawn(cmd, search_path, dry_run= self.dry_run)
  File "/usr/lib/python2.4/distutils/spawn.py", line 37, in spawn
    _spawn_posix(cmd, search_path, dry_run=dry_run)
  File "/usr/lib/python2.4/distutils/spawn.py", line 165, in _spawn_posix
    raise DistutilsExecError, \
distutils.errors.DistutilsExecError: command 'rpmbuild' failed with exit
status 1


Robert Kern wrote:
Stanley A. Klein wrote:

>> Robert -
>> 
>> Thanks for illuminating the issue.
>> 
>> The problem I had was as follows.  Fedora (also RedHat) uses SE-Linux,
>> which needs to know all the files expected to be in sensitive directories
>> such as the Python site-packages.  This includes the pyc and pyo files
>> ordinarily generated by Python as the .py files are executed.
>> 
>> It turns out that to do a bdist_rpm for Fedora, it is necessary to create
>> a setup.cfg file containing the lines:
>> 
>> [install]
>> optimize = 1
>> 
>> or to add these lines to the existing setup.cfg file.
>> 
>> If that is not done, the result in Fedora is an unpackaged files error. 
>> This is due to the fact that if distutils/setuptools doesn't cause the pyc
>> and pyo files to be created, Fedora will create them but they won't be
>> properly handled in the spec file created by distutils/setuptools.
>> 
>> In trying to do bdist_rpm with kiva, I got the unpackaged files error. 
>> This implies that numpy distutils did not properly handle the optimize=1
>> in the setup.cfg (when I did "python setup.py bdist_rpm").  That's when I
>> went to the workaround that resulted in this thread.
>> 
>> I hope this clarifies the problem.

>Not quite. I don't know what "the unpackaged files error" looks like. Can you
>try Phillip's suggestion using --root and --record and show us the results? Did
>you run "python setup.py build" before "python setup.py bdist_rpm"? We've often
>seen problems with the dependency-handling between distutils commands.

I tried your second suggestion and it didn't work.  Running bdist_rpm starts the whole process from scratch.

Regarding Phillip's suggestion, when running bdist_rpm I don't have direct access to --root and --record.  However, in trying to track it down, I think I may have found something that is contributing to the problem. 

When running bdist_rpm, the install command options appear to be set in a script located in the %install part of the rpm spec file.  Most likely, the install is called by the rpm program and is controlled by the spec file.  The install script in the kiva spec file is "python setup.py install --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES".  The install scripts in the other spec files (that worked) are "python setup.py install --single-version-externally-managed --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES"

I looked at the numpy distutils.  In many cases they check to see if setuptools is installed, and if so they import the relevant setuptools modules (otherwise they import the distutils modules).  In particular, the install command does that.  However, in the numpy distutils, the bdist_rpm command does not.  It only uses the distutils bdist_rpm, that produces the spec file install script shown above.  It seems to me that the setuptools install is being called via the numpy distutils without the --single-version-externally-managed option it would expect if its own bdist_rpm were being used to build the spec file.

I don't know if that is enough to get the install to ignore including the pyc and pyo files in the INSTALLED_FILES as essentially specified in the setup.cfg option, but it is clearly a glitch that could cause unexpected behavior.

The issue with the .so files arose because of my effort to work around the issue of the pyc and pyo files.  I think the proper choice of bdist_rpm to import may be closer to the cause of the original problem.

I tried to do something to fix the numpy distutils bdist_rpm.py (by trying to follow what was done in install.py) but it didn't work and I got an error message I didn't understand.


Stan Klein

_______________________________________________
Distutils-SIG maillist  -  Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig

Reply via email to