def create_setup_py(self, target, dist_dir): chroot = Chroot(dist_dir, name=target.provides.name) dependency_calculator = self.DependencyCalculator(self.context.build_graph) reduced_deps = dependency_calculator.reduced_dependencies(target) self.write_contents(target, reduced_deps, chroot) self.write_setup(target, reduced_deps, chroot) target_base = '{}-{}'.format(target.provides.name, target.provides.version) setup_dir = os.path.join(dist_dir, target_base) safe_rmtree(setup_dir) shutil.move(chroot.path(), setup_dir) return setup_dir, reduced_deps
def create_setup_py(self, target, dist_dir): chroot = Chroot(dist_dir, name=target.provides.name) dependency_calculator = self.DependencyCalculator(self.context.build_graph) reduced_deps = dependency_calculator.reduced_dependencies(target) self.write_contents(target, reduced_deps, chroot) self.write_setup(target, reduced_deps, chroot) target_base = '{}-{}'.format(target.provides.name, target.provides.version) setup_dir = os.path.join(dist_dir, target_base) safe_rmtree(setup_dir) shutil.move(chroot.path(), setup_dir) return setup_dir, reduced_deps
def execute(self): config = Config.load() distdir = config.getdefault('pants_distdir') setup_dir = os.path.join( distdir, '%s-%s' % (self.target.provides._name, self.target.provides._version)) chroot = Chroot(distdir, name=self.target.provides._name) self.write_sources(chroot) self.write_setup(chroot) if os.path.exists(setup_dir): import shutil shutil.rmtree(setup_dir) os.rename(chroot.path(), setup_dir) with pushd(setup_dir): cmd = '%s setup.py %s' % (sys.executable, self.options.run or 'sdist') print('Running "%s" in %s' % (cmd, setup_dir)) extra_args = {} if self.options.run else dict( stdout=subprocess.PIPE, stderr=subprocess.PIPE) po = subprocess.Popen(cmd, shell=True, **extra_args) po.wait() if self.options.run: print('Ran %s' % cmd) print('Output in %s' % setup_dir) return po.returncode elif po.returncode != 0: print('Failed to run %s!' % cmd) for line in po.stdout.read().splitlines(): print('stdout: %s' % line) for line in po.stderr.read().splitlines(): print('stderr: %s' % line) return po.returncode expected_tgz = '%s-%s.tar.gz' % (self.target.provides._name, self.target.provides._version) expected_target = os.path.join(setup_dir, 'dist', expected_tgz) dist_tgz = os.path.join(distdir, expected_tgz) if not os.path.exists(expected_target): print('Could not find expected target %s!' % expected_target) sys.exit(1) safe_delete(dist_tgz) os.rename(expected_target, dist_tgz) print('Wrote %s' % dist_tgz) safe_rmtree(setup_dir)
def execute(self): dist_dir = self._config.getdefault('pants_distdir') target_base = '%s-%s' % ( self.target.provides.name, self.target.provides.version) setup_dir = os.path.join(dist_dir, target_base) expected_tgz = '%s.tar.gz' % target_base expected_target = os.path.join(setup_dir, 'dist', expected_tgz) dist_tgz = os.path.join(dist_dir, expected_tgz) chroot = Chroot(dist_dir, name=self.target.provides.name) self.write_contents(chroot) self.write_setup(chroot) safe_rmtree(setup_dir) os.rename(chroot.path(), setup_dir) with pushd(setup_dir): cmd = '%s setup.py %s' % (sys.executable, self.options.run or 'sdist') print('Running "%s" in %s' % (cmd, setup_dir)) extra_args = {} if self.options.run else dict(stdout=subprocess.PIPE, stderr=subprocess.PIPE) po = subprocess.Popen(cmd, shell=True, **extra_args) stdout, stderr = po.communicate() if self.options.run: print('Ran %s' % cmd) print('Output in %s' % setup_dir) return po.returncode elif po.returncode != 0: print('Failed to run %s!' % cmd) for line in ''.join(stdout).splitlines(): print('stdout: %s' % line) for line in ''.join(stderr).splitlines(): print('stderr: %s' % line) return po.returncode else: if not os.path.exists(expected_target): print('Could not find expected target %s!' % expected_target) sys.exit(1) safe_delete(dist_tgz) os.rename(expected_target, dist_tgz) safe_rmtree(setup_dir) print('Wrote %s' % dist_tgz)
def execute(self): config = Config.load() distdir = config.getdefault('pants_distdir') setup_dir = os.path.join(distdir, '%s-%s' % ( self.target.provides._name, self.target.provides._version)) chroot = Chroot(distdir, name=self.target.provides._name) self.write_sources(chroot) self.write_setup(chroot) if os.path.exists(setup_dir): import shutil shutil.rmtree(setup_dir) os.rename(chroot.path(), setup_dir) with pushd(setup_dir): cmd = '%s setup.py %s' % (sys.executable, self.options.run or 'sdist') print('Running "%s" in %s' % (cmd, setup_dir)) extra_args = {} if self.options.run else dict(stdout=subprocess.PIPE, stderr=subprocess.PIPE) po = subprocess.Popen(cmd, shell=True, **extra_args) po.wait() if self.options.run: print('Ran %s' % cmd) print('Output in %s' % setup_dir) return po.returncode elif po.returncode != 0: print('Failed to run %s!' % cmd) for line in po.stdout.read().splitlines(): print('stdout: %s' % line) for line in po.stderr.read().splitlines(): print('stderr: %s' % line) return po.returncode expected_tgz = '%s-%s.tar.gz' % (self.target.provides._name, self.target.provides._version) expected_target = os.path.join(setup_dir, 'dist', expected_tgz) dist_tgz = os.path.join(distdir, expected_tgz) if not os.path.exists(expected_target): print('Could not find expected target %s!' % expected_target) sys.exit(1) safe_delete(dist_tgz) os.rename(expected_target, dist_tgz) print('Wrote %s' % dist_tgz) safe_rmtree(setup_dir)
def run_one(self, target): dist_dir = self._config.getdefault('pants_distdir') chroot = Chroot(dist_dir, name=target.provides.name) self.write_contents(target, chroot) self.write_setup(target, chroot) target_base = '%s-%s' % (target.provides.name, target.provides.version) setup_dir = os.path.join(dist_dir, target_base) safe_rmtree(setup_dir) shutil.move(chroot.path(), setup_dir) if not self.old_options.run: print('Running packager against %s' % setup_dir) setup_runner = Packager(setup_dir) tgz_name = os.path.basename(setup_runner.sdist()) print('Writing %s' % os.path.join(dist_dir, tgz_name)) shutil.move(setup_runner.sdist(), os.path.join(dist_dir, tgz_name)) safe_rmtree(setup_dir) else: print('Running %s against %s' % (self.old_options.run, setup_dir)) setup_runner = SetupPyRunner(setup_dir, self.old_options.run) setup_runner.run()
def run_one(self, target): dist_dir = self._config.getdefault('pants_distdir') chroot = Chroot(dist_dir, name=target.provides.name) self.write_contents(target, chroot) self.write_setup(target, chroot) target_base = '%s-%s' % (target.provides.name, target.provides.version) setup_dir = os.path.join(dist_dir, target_base) safe_rmtree(setup_dir) os.rename(chroot.path(), setup_dir) if not self.options.run: print('Running packager against %s' % setup_dir) setup_runner = Packager(setup_dir) tgz_name = os.path.basename(setup_runner.sdist()) print('Writing %s' % os.path.join(dist_dir, tgz_name)) os.rename(setup_runner.sdist(), os.path.join(dist_dir, tgz_name)) safe_rmtree(setup_dir) else: print('Running %s against %s' % (self.options.run, setup_dir)) setup_runner = SetupPyRunner(setup_dir, self.options.run) setup_runner.run()
def run_one(self, target): dist_dir = self.get_options().pants_distdir chroot = Chroot(dist_dir, name=target.provides.name) self.write_contents(target, chroot) self.write_setup(target, chroot) target_base = '%s-%s' % (target.provides.name, target.provides.version) setup_dir = os.path.join(dist_dir, target_base) safe_rmtree(setup_dir) shutil.move(chroot.path(), setup_dir) if not self._run: self.context.log.info('Running packager against %s' % setup_dir) setup_runner = Packager(setup_dir) tgz_name = os.path.basename(setup_runner.sdist()) self.context.log.info('Writing %s' % os.path.join(dist_dir, tgz_name)) shutil.move(setup_runner.sdist(), os.path.join(dist_dir, tgz_name)) safe_rmtree(setup_dir) else: self.context.log.info('Running %s against %s' % (self._run, setup_dir)) setup_runner = SetupPyRunner(setup_dir, self._run) setup_runner.run()