def __patch(self, basemap_dir):
     ## modify faulty pyproj data location
     problem_file = os.path.join(basemap_dir, 'pyproj.py')
     print('PATCH ' + problem_file)
     problem_exists = True
     pf = open(problem_file, 'r')
     for line in pf:
         if 'BASEMAPDATA' in line:
             problem_exists = False
             break
     pf.close()
     if problem_exists:
         replacement = \
                       "if 'BASEMAPDATA' in os.environ:\n" \
                       "    pyproj_datadir = os.environ['BASEMAPDATA']\n" \
                       "else:\n" \
                       "    pyproj_datadir = "
         try:
             patch_file(problem_file, "pyproj_datadir = ",
                        "pyproj_datadir = ", replacement)
         except IOError:  ## Permission denied
             sys.stderr.write('WARNING: installed basemap package at ' +
                              basemap_dir + ' cannot be relocated. ' +
                              'Most users can ignore this message.')
Beispiel #2
0
 def install(self, environ, version, strict=False, locally=True):
     if not 'darwin' in platform.system().lower():
         return
     mkdir(options.target_build_dir)
     log = open(os.path.join(options.target_build_dir,
                             'macports_setup.log'), 'w')
     python_version = '26'  ## Hard coded due to wxPython
     if not self.found:
         if version is None:
             version = '2.1.3'
         website = ('https://distfiles.macports.org/MacPorts/',)
         src_dir = 'MacPorts-' + str(version)
         archive = src_dir + '.tar.gz'
         autotools_install(environ, website, archive, src_dir, False)
         patch_file('/opt/local/share/macports/Tcl/port1.0/portconfigure.tcl',
                    'default configure.ldflags',
                    '{-L${prefix}/lib}',
                    '{"-L${prefix}/lib -Xlinker -headerpad_max_install_names"}')
         patch_file('/opt/local/etc/macports/macports.conf',
                    'build_arch  i386', '#', '')  ## Also due to wxPython
         admin_check_call(['port', 'selfupdate'], stdout=log, stderr=log)
     if not self.ports_found:
         admin_check_call(['port', 'install', 'python' + python_version,
                           'python_select'], stdout=log, stderr=log)
         admin_check_call(['port', 'select', '--set', 'python',
                           'python' + python_version],
                          stdout=log, stderr=log)
         admin_check_call(['port', 'install',
                           'py' + python_version + '-numpy'],
                          stdout=log, stderr=log)
         admin_check_call(['port', 'install',
                           'py' + python_version + '-py2app'],
                          stdout=log, stderr=log)
     log.close()
     if not self.is_installed(environ, version, strict):
         raise Exception("Macports installation failed.")