コード例 #1
0
ファイル: setup.py プロジェクト: delicb/tea
def setup(module, target='zip', output_path=None, data_dir=None):
    dist = os.path.abspath('dist')
    try:
        if target == 'zip':
            assert er('setup.py', 'install', '--no-compile',
                      '--install-lib',     os.path.join(dist, 'lib'),
                      '--install-scripts', os.path.join(dist),
                      *(['--install-data',    os.path.join(dist, data_dir)]
                        if data_dir is not None else []))
            with shutil.goto(dist) as ok:
                assert ok
                assert compress.mkzip('%s.zip' % module,
                                      glob.glob(os.path.join('lib', '*')))
                assert shutil.remove('lib')
        elif target == 'exe':
            assert er('setup.py', 'install', '--no-compile',
                      '--install-lib',     os.path.join(dist, 'lib', 'python'),
                      '--install-scripts', os.path.join(dist, 'scripts'),
                      *(['--install-data',    os.path.join(dist, data_dir)]
                        if data_dir is not None else []))
            with shutil.goto(dist) as ok:
                assert ok

                modules = list(filter(os.path.exists,
                                      ['lib', 'scripts'] + (
                                          [data_dir] if data_dir is not None
                                          else [])))
                assert compress.seven_zip('%s.exe' % module, modules,
                                          self_extracting=True)
                # Cleanup
                for module in modules:
                    assert shutil.remove(module)
        if output_path is not None:
            output_path = os.path.abspath(output_path)
            if output_path != dist:
                if not os.path.isdir(output_path):
                    assert shutil.mkdir(output_path)
                for filename in shutil.search(dist, '*'):
                    output = os.path.join(output_path,
                                          filename.replace(dist, '', 1)
                                                  .strip('\\/'))
                    assert shutil.move(filename, output)
        return 0
    except AssertionError as e:
        print(e)
        return 1
    finally:
        # Cleanup
        if output_path != dist:
            shutil.remove(dist)
        if os.path.isdir('build'):
            shutil.remove('build')
コード例 #2
0
ファイル: utils.py プロジェクト: delicb/samovar
 def run(self, config):
     # Calculate the working dir
     working_dir = self.project.path if self.working_dir is None else os.path.join(self.project.path, self.working_dir)
     with shutil.goto(working_dir) as ok:
         if not ok:
             error = 'Could not change directory to "%s"!' % working_dir
             logger.error(error)
             return 1, error, ''
         if self.type == Step.MSBUILD:
             return self._msbuild(config)
         elif self.type == Step.SHELL:
             return self._command(config)
         else:
             error = 'Don\'t know how to build %s projects!' % self.type
             logger.error(error)
             return 1, error, ''
コード例 #3
0
 def run(self, config):
     # Calculate the working dir
     working_dir = self.project.path if self.working_dir is None else os.path.join(
         self.project.path, self.working_dir)
     with shutil.goto(working_dir) as ok:
         if not ok:
             error = 'Could not change directory to "%s"!' % working_dir
             logger.error(error)
             return 1, error, ''
         if self.type == Step.MSBUILD:
             return self._msbuild(config)
         elif self.type == Step.SHELL:
             return self._command(config)
         else:
             error = 'Don\'t know how to build %s projects!' % self.type
             logger.error(error)
             return 1, error, ''