Exemple #1
0
 def byte_compile(self, files):
     for f in files:
         if f.endswith(".py"):
             # Create temp file
             fh, abs_path = mkstemp()
             new_file = open(abs_path, "w")
             old_file = open(f, "rU")
             for line in old_file:
                 if line[0:11] == "__version__":
                     new_file.write("__version__ = '" + version_nr + "'" + "\n")
                 elif line[0:12] == "__revision__":
                     new_file.write("__revision__ = '" + revision_nr + "'" + "\n")
                 elif line[0:8] == "__date__":
                     new_file.write("__date__ = '" + date + "'" + "\n")
                 else:
                     new_file.write(line)
             # Close temp file
             new_file.close()
             close(fh)
             old_file.close()
             # Remove original file
             remove(f)
             # Move new file
             move(abs_path, f)
             chmod(f, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
     build_py.byte_compile(self, files)
Exemple #2
0
    def byte_compile(self, files):
        "Compile files *.py and *.po"
        if hasattr(sys, "dont_write_bytecode") and sys.dont_write_bytecode:
            self.warn('byte-compiling is disabled, skipping.')
            return

        _build_py.byte_compile(self, files)

        if 'no_mo' not in self.distribution.get_option_dict('install'):
            from freddist.util import pomo_compile
            pomo_compile(files)
Exemple #3
0
    def byte_compile(self, files):
        "Compile files *.py and *.po"
        if hasattr(sys, "dont_write_bytecode") and sys.dont_write_bytecode:
            self.warn("byte-compiling is disabled, skipping.")
            return

        _build_py.byte_compile(self, files)

        if "no_mo" not in self.distribution.get_option_dict("install"):
            from freddist.util import pomo_compile

            pomo_compile(files)
Exemple #4
0
 def byte_compile(self, files):
     try:
         from qpy.compile import compile_qpy_file
     except ImportError:
         build_py.byte_compile(self, files)
     else:
         existing = []
         for file in files:
             if os.path.exists(file):
                 existing.append(file)
             else:
                 alt = file[:-3] + ".qpy"
                 compile_qpy_file(alt)
                 sys.stdout.write('byte-compiling %s\n' % alt)
         build_py.byte_compile(self, existing)
Exemple #5
0
    def byte_compile(self, files):
        build_py.byte_compile(self, files)

        try:
            build_dir = os.path.dirname(files[0])

            # Clean .py files.
            for f in files:
                os.unlink(f)

            # Clean .pyo files.
            for f in glob.glob(build_dir + '/*.pyo'):
                os.unlink(f)
        except Exception, msg:
            print 'Exception caught while byte compiling: ' + str(msg)
Exemple #6
0
  def byte_compile (self, files):
    build_py.byte_compile (self, files)

    try:
      build_dir = os.path.dirname(files[0])

      # Clean .py files.
      for f in files:
        os.unlink(f)

      # Clean .pyo files.
      for f in glob.glob(build_dir + '/*.pyo'):
        os.unlink(f)
    except Exception, msg:
      print 'Exception caught while byte compiling: ' + str(msg)
Exemple #7
0
    def byte_compile(self, files):
        build_py.byte_compile(self, files)

        # Skip compiling
        if sys.dont_write_bytecode:
            return

        for pofile in files:
            if pofile[-3:] != ".po":
                # Don't compile anything else
                continue
            mofile = pofile[:-3] + '.mo'
            if self.force or newer(pofile, mofile):
                log.info("byte-compiling %s to %s", pofile, mofile)
                if not self.dry_run:
                    subprocess.check_call(['msgfmt', '-o', mofile, pofile])
            else:
                log.debug("skipping byte-compilation of %s to %s",
                          pofile, mofile)
Exemple #8
0
 def byte_compile(self, files):
     """Byte-compile all Python modules and all Kid templates."""
     build_py.byte_compile(self, files)
     kid_files = [f for f in files if f.endswith('.kid')]
     if not kid_files:
         return
     from distutils import log
     try:
         from kid.compiler import compile_file
     except ImportError:
         log.warn("Kid templates cannot be compiled,"
             " because Kid is not installed.")
         return
     if self.dry_run:
         return
     for kid_file in kid_files:
         if compile_file(kid_file, force=self.force):
             log.info("byte-compiling %s", kid_file)
         else:
             log.debug("skipping byte-compilation of %s", kid_file)