- src_dir = os.path.dirname(os.path.dirname(path))
- if src_dir in self.seen_packages:
- return
- self.seen_packages.add(src_dir)
- # We also must run `sdist` before `upload`: `upload` uploads any
- # distributions previously generated in the command. It doesn't
- # know how to upload distributions already on disk. We write the
- # result to a dedicated directory to avoid interfering with our
- # timestamp tracking.
- cmd = ['python3', 'setup.py']
- if not self.logger.isEnabledFor(logging.INFO):
- cmd.append('--quiet')
- cmd.extend(['bdist_wheel', '--dist-dir', '.upload_dist'])
- cmd.extend(['sdist', '--dist-dir', '.upload_dist'])
- cmd.extend(['upload'])
- upload_returncode, repushed = run_and_grep(
- cmd, 'stderr', *self.REUPLOAD_REGEXPS, cwd=src_dir)
- if (upload_returncode != 0) and not repushed:
- raise subprocess.CalledProcessError(upload_returncode, cmd)
- shutil.rmtree(os.path.join(src_dir, '.upload_dist'))
+ subprocess.run([
+ 'twine', 'upload',
+ '--disable-progress-bar',
+ '--non-interactive',
+ '--skip-existing',
+ path,
+ ], stdin=subprocess.DEVNULL, check=True)