Beispiel #1
0
    def build_extension(self, ext):
        #  #[ the actual build

        """ initiate building the extension module """
        # don't re-initialise these properties here !
        # at his point the setup machinery already has processed
        # the cfg file and the commandline, so these will be lost
        # if you init these properties here again!
        #
        #self.preferred_fortran_compiler = None
        #self.preferred_c_compiler = None
        #self.fortran_compiler = None
        #self.fortran_ld_library_path = None
        #self.fortran_flags = None
        #self.c_compiler = None
        #self.c_ld_library_path = None
        #self.c_flags = None
        #self.download_library_sources = None

        #fullname = self.get_ext_fullname(ext.name)
        #print("trying to build extension: ", fullname)
        log.info("building '%s' extension", ext.name)

        #print("ext.sources = ", ext.sources)

        # this does not work properly yet for setup.py bdist
        # since in that case the pybufr_ecmwf/ecmwfbufr.so
        # needs to be created below build/lib.linux-i686-2.6/
        # so inspect the path settings for the build:

        build_dir = os.path.join(self.build_lib, "pybufr_ecmwf")
        build_dir = os.path.abspath(build_dir)
        #print("self.build_lib = ", self.build_lib)
        print("initiating build in dir: ", build_dir)

        #if os.path.isdir(build_dir):
        #    sys.path.append(build_dir)
        if os.path.isdir(build_dir):
            sys.path.append(build_dir)
        else:
            raise DistutilsSetupError( \
                  "could not find directory in which the module should"
                  "be build. Something seems wrong in setup.py."
                  "Please report this to the developer of this module.")

        # this enters the automatic build system, which is what I don't
        # want at the moment, since it seems not to handle fortran
        #_build_ext.build_extension(self, ext)

        cwd = os.getcwd()
        os.chdir(build_dir)

        # find parent dir that holds build_interface.py and
        # force path to include that dir
        base_build_dir = None
        tmp_dir = build_dir
        while base_build_dir is None:
            files = os.listdir(tmp_dir)
            if 'build_interface.py' in files:
                base_build_dir = tmp_dir
            else:
                tmp_dir, subdir = os.path.split(tmp_dir)
                if subdir == '':
                    break

        if base_build_dir is not None:
            print('base_build_dir = ', base_build_dir)
            sys.path.insert(0, os.path.abspath(base_build_dir))

        from build_interface import InstallBUFRInterfaceECMWF
        # this will fail, because it loads the __init__.py inside
        # the pybufr_ecmwf directory, which in turn tries to load the
        # ecmwfbufr module, and that one does not yet exist, but will be
        # created by the ibi.build() call below.
        #from pybufr_ecmwf.build_interface import InstallBUFRInterfaceECMWF

        do_download_library_sources = False
        if str(self.download_library_sources).lower() == 'true':
            do_download_library_sources = True

        # run the build method from the InstallBUFRInterfaceECMWF class
        # defined in the custom build script, to build the extension module
        ibi = InstallBUFRInterfaceECMWF(
                  verbose=True,
                  preferred_fortran_compiler=self.preferred_fortran_compiler,
                  preferred_c_compiler=self.preferred_c_compiler,
                  fortran_compiler=self.fortran_compiler,
                  fortran_ld_library_path=self.fortran_ld_library_path,
                  fortran_flags=self.fortran_flags,
                  c_compiler=self.c_compiler,
                  c_ld_library_path=self.c_ld_library_path,
                  c_flags=self.c_flags,
                  debug_f2py_c_api=False,
                  download_library_sources=do_download_library_sources)

        # Build ecmwfbufr.so interface
        ibi.build()

        # remove all object files to prevent them from ending up
        # in the binary or rpm distribution packages
        ibi.clean()

        os.chdir(cwd)
Beispiel #2
0
        from build_interface import InstallBUFRInterfaceECMWF
        from pybufr_ecmwf.custom_exceptions import BuildException

        BI = InstallBUFRInterfaceECMWF(verbose=True,
                                       preferred_fortran_compiler=fc,
                                       download_library_sources=False)

        # make sure we are in the right directory
        BUILD_DIR = 'pybufr_ecmwf'
        os.chdir(BUILD_DIR)

        this_result = []
        build_succesfull = True
        try:
            BI.build()
        except BuildException:
            this_result.append('manual build failed for compiler: '+fc)
            build_succesfull = False

        del BI

        # restore the original directory
        os.chdir(saved_cwd)

        # -verify the presence of the generated ecmwfbufr.so file
        so_files = glob.glob(os.path.join(temp_build_dir, BUILD_DIR,
                                          'ecmwfbufr.so'))

        this_result.append('test results for manual build for: '+fc)
        if len(so_files) > 0:
Beispiel #3
0
    def build_extension(self, ext):
        #  #[ the actual build
        """ initiate building the extension module """
        # don't re-initialise these properties here !
        # at his point the setup machinery already has processed
        # the cfg file and the commandline, so these will be lost
        # if you init these properties here again!
        #
        #self.preferred_fortran_compiler = None
        #self.preferred_c_compiler = None
        #self.fortran_compiler = None
        #self.fortran_ld_library_path = None
        #self.fortran_flags = None
        #self.c_compiler = None
        #self.c_ld_library_path = None
        #self.c_flags = None

        #fullname = self.get_ext_fullname(ext.name)
        #print("trying to build extension: ", fullname)
        log.info("building '%s' extension", ext.name)

        #print("ext.sources = ", ext.sources)

        # this does not work properly yet for setup.py bdist
        # since in that case the pybufr_ecmwf/ecmwfbufr.so
        # needs to be created below build/lib.linux-i686-2.6/
        # so inspect the path settings for the build:

        build_dir = os.path.join(self.build_lib, "pybufr_ecmwf")
        build_dir = os.path.abspath(build_dir)
        #print("self.build_lib = ", self.build_lib)
        print("initiating build in dir: ", build_dir)

        #if os.path.isdir(build_dir):
        #    sys.path.append(build_dir)
        if os.path.isdir(build_dir):
            sys.path.append(build_dir)
        else:
            raise DistutilsSetupError( \
                  "could not find directory in which the module should"
                  "be build. Something seems wrong in setup.py."
                  "Please report this to the developer of this module.")

        # this enters the automatic build system, which is what I don't
        # want at the moment, since it seems not to handle fortran
        #_build_ext.build_extension(self, ext)

        cwd = os.getcwd()
        os.chdir(build_dir)

        # find parent dir that holds build_interface.py and
        # force path to include that dir
        base_build_dir = None
        tmp_dir = build_dir
        while base_build_dir is None:
            files = os.listdir(tmp_dir)
            if 'build_interface.py' in files:
                base_build_dir = tmp_dir
            else:
                tmp_dir, subdir = os.path.split(tmp_dir)
                if subdir == '':
                    break

        if base_build_dir is not None:
            print('base_build_dir = ', base_build_dir)
            sys.path.insert(0, os.path.abspath(base_build_dir))

        from build_interface import InstallBUFRInterfaceECMWF
        # this will fail, because it loads the __init__.py inside
        # the pybufr_ecmwf directory, which in turn tries to load the
        # ecmwfbufr module, and that one does not yet exist, but will be
        # created by the ibi.build() call below.
        #from pybufr_ecmwf.build_interface import InstallBUFRInterfaceECMWF

        # run the build method from the InstallBUFRInterfaceECMWF class
        # defined in the custom build script, to build the extension module
        ibi = InstallBUFRInterfaceECMWF(
            verbose=verbose,
            preferred_fortran_compiler=self.preferred_fortran_compiler,
            preferred_c_compiler=self.preferred_c_compiler,
            fortran_compiler=self.fortran_compiler,
            fortran_ld_library_path=self.fortran_ld_library_path,
            fortran_flags=self.fortran_flags,
            c_compiler=self.c_compiler,
            c_ld_library_path=self.c_ld_library_path,
            c_flags=self.c_flags,
            debug_f2py_c_api=False)

        # Build ecmwfbufr.so interface
        ibi.build()

        # remove all object files to prevent them from ending up
        # in the binary or rpm distribution packages
        # disable this line in case of trouble to enable debugging
        # or access to the log files below ecmwf_bufr_lib
        ibi.clean()

        os.chdir(cwd)
Beispiel #4
0
        from build_interface import InstallBUFRInterfaceECMWF
        from pybufr_ecmwf.custom_exceptions import BuildException

        BI = InstallBUFRInterfaceECMWF(verbose=True,
                                       preferred_fortran_compiler=fc,
                                       download_library_sources=False)

        # make sure we are in the right directory
        BUILD_DIR = 'pybufr_ecmwf'
        os.chdir(BUILD_DIR)

        this_result = []
        build_succesfull = True
        try:
            BI.build()
        except BuildException:
            this_result.append('manual build failed for compiler: ' + fc)
            build_succesfull = False

        del BI

        # restore the original directory
        os.chdir(saved_cwd)

        # -verify the presence of the generated ecmwfbufr.so file
        so_files = glob.glob(
            os.path.join(temp_build_dir, BUILD_DIR, 'ecmwfbufr.so'))

        this_result.append('test results for manual build for: ' + fc)
        if len(so_files) > 0: