def run(self): if platform.python_implementation() != "CPython": abort("twine command not supported on %s" % platform.python_implementation()) if not self.egg and not self.sdist and not self.wheel: abort("Specify at least one of: --egg, --dist or --wheel") twine = setupmeta.which('twine') if not twine: abort("twine is not installed") if not self.commit: print("Dryrun, use --commit to effectively build/publish") dist = setupmeta.project_path('dist') self.clean('dist', 'build') try: if self.should_run(self.egg): self.run_command("build egg distribution", sys.executable, 'setup.py', 'bdist_egg') if self.should_run(self.sdist): self.run_command("build source distribution", sys.executable, 'setup.py', 'sdist') if self.should_run(self.wheel): self.run_command("build wheel distribution", sys.executable, 'setup.py', 'bdist_wheel', '--universal') if self.commit and not os.path.exists(dist): abort("No files found in %s" % dist) files = [os.path.join(dist, name) for name in sorted(os.listdir(dist))] if self.commit else ['dist/*'] self.run_command("upload to PyPi via twine", twine, 'upload', *files) finally: self.clean('build')
def run(self): if not self.setupmeta: return if platform.python_implementation() != "CPython": abort("twine command not supported on %s" % platform.python_implementation()) if not self.egg and not self.sdist and not self.wheel: abort("Specify at least one of: --egg, --dist or --wheel") # Env var SETUPMETA_TWINE primarily used to allow for flexible testing # Can be set to instruct setupmeta to use a particular twine executable as well # Use absolute path, of filename (for example: "my-twine-wrapper") twine = setupmeta.which(os.environ.get("SETUPMETA_TWINE", "twine")) if not twine: abort("twine is not installed") if not self.commit: print("Dryrun, use --commit to effectively build/publish") dist = setupmeta.project_path("dist") self.clean("dist", "build") try: if self.should_run(self.egg): self.run_command("build egg distribution", sys.executable, "setup.py", "bdist_egg") if self.should_run(self.sdist): self.run_command("build source distribution", sys.executable, "setup.py", "sdist") if self.should_run(self.wheel): self.run_command("build wheel distribution", sys.executable, "setup.py", "bdist_wheel", "--universal") if self.commit and not os.path.exists(dist): abort("No files found in %s" % dist) files = [ os.path.join(dist, name) for name in sorted(os.listdir(dist)) ] if self.commit else ["dist/*"] self.run_command("upload to PyPi via twine", twine, "upload", *files) finally: self.clean("build")
def test_which(): assert setupmeta.which(None) is None assert setupmeta.which('/foo/does/not/exist') is None assert setupmeta.which('foo/does/not/exist') is None assert setupmeta.which('ls') assert setupmeta.which('setup.py')
def test_which(): assert setupmeta.which(None) is None assert setupmeta.which("/foo/does/not/exist") is None assert setupmeta.which("foo/does/not/exist") is None assert setupmeta.which("pip")