mpl 0.65: no bdist_rpm, harcoded paths...

hi all,

A few minor nits with mpl 0.65:

1. I just tried to build an rpm for mpl via bdist_rpm, and it unfortunately
fails. The problem is the extra -debuginfo rpm which gets generated in the
process, which then causes the setup.py process to abort. It would be very
nice to be able to use bdist_rpm to cleanly generate RPMs out of the sources,
for handling installation via yum on multiple boxes.

2. I think there are some hardcoded paths in mpl which shouldn't. I installed
   it (after the rpm failure) with 'install --prefix=/usr/local', and the date
demos fail:

planck[examples]> python date_demo1.py
Could not find bitmap file "/usr/share/matplotlib/home.xpm"; dying

Note that:

planck[examples]> d /usr/local/share/matplotlib/home.xpm
-rw-r--r-- 1 root 5135 Jul 20 12:13 /usr/local/share/matplotlib/home.xpm

which is as it should, since I specified my prefix as /usr/local. The runtime
code should not assume that the base prefix is necessarily /usr, since this
can be changed at installation time by the user.

3. The dates stuff also has problems when running in non-english locales:

In [1]: run date_demo2.py

···

---------------------------------------------------------------------------
exceptions.ValueError Traceback (most recent
call last)

/home/fperez/code/python/pylab/examples/date_demo2.py
       20
       21
---> 22 quotes = quotes_historical_yahoo('INTC', date1, date2)
       23 if not quotes:
       24 print 'Found no quotes'

/usr/local/lib/python2.3/site-packages/matplotlib/finance.py in
quotes_historical_yahoo(ticker, date1, date2)
       61 if len(vals)!=7: continue
       62 datestr = vals[0]
---> 63 dt = datetime.date(*time.strptime(datestr, '%d-%b-%y')[:3])
       64 d = date2num(dt)
       65 open, high, low, close = [float(val) for val in vals[1:5]]

/usr/src/build/394694-i386/install/usr/lib/python2.3/_strptime.py in
strptime(data_string, format)
      422 found = format_regex.match(data_string)
      423 if not found:
--> 424 raise ValueError("time data did not match format: data=%s
fmt=%s" %
      425 (data_string, format))
      426 if len(data_string) != found.end():

ValueError: time data did not match format: data=1-Dec-03 fmt=%d-%b-%y
WARNING: Failure executing file: <date_demo2.py>

In [3]: !echo $$LANG
de_DE.UTF-8

If I switch to the US locale, the code runs (until the crash listed in #2
because of the path problem).

Anyway, this is _my_ Christmas gift to matplotlib :wink:

Cheers,

f

Fernando Perez wrote:

hi all,

A few minor nits with mpl 0.65:

1. I just tried to build an rpm for mpl via bdist_rpm, and it unfortunately
fails. The problem is the extra -debuginfo rpm which gets generated in the
process, which then causes the setup.py process to abort. It would be very
nice to be able to use bdist_rpm to cleanly generate RPMs out of the sources,
for handling installation via yum on multiple boxes.

OK, here's a quick and dirty fix I found. In distutils/command/bdist_rpm.py, around line 309, use the following:

         if not self.dry_run:
             if not self.binary_only:
                 srpms = glob.glob(os.path.join(rpm_dir['SRPMS'], "*.rpm"))
                 #assert len(srpms) == 1, \
                 # "unexpected number of SRPM files found: %s" % srpms
                 #self.move_file(srpms[0], self.dist_dir)
                 map(lambda f:self.move_file(f,self.dist_dir),srpms)

             if not self.source_only:
                 rpms = glob.glob(os.path.join(rpm_dir['RPMS'], "*/*.rpm"))
                 #assert len(rpms) == 1, \
                 # "unexpected number of RPM files found: %s" % rpms
                 #self.move_file(rpms[0], self.dist_dir)
                 map(lambda f:self.move_file(f,self.dist_dir),rpms)

I commented out the asserts which cause the operation to fail, and replaced them with a brute-force map call. I'll try to have some form of this change sent upstream to python-dev, b/c that stupid assert causes no end of grief for extension RPMs.

I guess this makes it a bit of a real Xmas gift :slight_smile:

Cheers,

f