def build_and_upload_distributions(self, version_tag_with_v): from infi.projector.helper.utils import execute_with_buildout, git_checkout from infi.projector.plugins.builtins.devenv import DevEnvPlugin for distribution in self.arguments.get("--distributions").split(','): for pypi in self.arguments.get("--pypi-servers").split(','): if not pypi: continue git_checkout(version_tag_with_v) DevEnvPlugin().create_setup_py() setup_cmd = "setup . register -r {pypi} {distribution} upload -r {pypi}" setup_cmd = setup_cmd.format(pypi=pypi, distribution=distribution) execute_with_buildout(setup_cmd, env=dict(LC_ALL="C"))
def upload(self): from infi.projector.helper.assertions import assert_version_tag_for_upload from infi.projector.helper.utils import release_version_with_git_flow, git_checkout, get_latest_version version_tag = self.arguments['<version>'] assert_version_tag_for_upload(version_tag) if version_tag == 'current': version_to_upload = 'HEAD' elif version_tag == 'latest': version_to_upload = get_latest_version() else: version_tag_without_v = version_tag.lstrip('v') version_to_upload = 'v{}'.format(version_tag_without_v) self.build_and_upload_distributions(version_to_upload) git_checkout("develop")
def build_and_upload_distributions(self, version_tag_with_v): from infi.projector.helper.utils import execute_with_buildout, git_checkout from infi.projector.plugins.builtins.devenv import DevEnvPlugin from infi.projector.scripts import projector from gitpy import LocalRepository from os import curdir repository = LocalRepository(curdir) for distribution in self.arguments.get("--distributions").split(','): for pypi in self.arguments.get("--pypi-servers").split(','): git_checkout(version_tag_with_v) DevEnvPlugin().create_setup_py() setup_cmd = "setup . register -r {pypi} {distribution} upload -r {pypi}" setup_cmd = setup_cmd.format(pypi=pypi, distribution=distribution) execute_with_buildout(setup_cmd)
def upload(self): from infi.projector.helper.assertions import assert_version_tag_for_upload from infi.projector.helper.utils import git_checkout, get_latest_version version_tag = self.arguments['<version>'] assert_version_tag_for_upload(version_tag) if version_tag == 'current': version_to_upload = 'HEAD' elif version_tag == 'latest': version_to_upload = get_latest_version() else: version_tag_without_v = version_tag.lstrip('v') version_to_upload = 'v{}'.format(version_tag_without_v) self.build_and_upload_distributions(version_to_upload) git_checkout("develop")
def build_and_upload_distributions(self, version_tag_with_v): from infi.projector.helper.utils import execute_with_buildout, git_checkout from infi.projector.plugins.builtins.devenv import DevEnvPlugin with open('setup.py') as fd: has_c_extensions = 'ext_modules' in fd.read() for distribution in self.arguments.get("--distributions").split(','): for pypi in self.arguments.get("--pypi-servers").split(','): if not pypi: continue git_checkout(version_tag_with_v) DevEnvPlugin().create_setup_py() setup_cmd = "setup . {distribution} upload -r {pypi} {universal_flag}" universal_flag = '--universal' if distribution == 'bdist_wheel' and has_c_extensions else '' setup_cmd = setup_cmd.format(pypi=pypi, distribution=distribution, universal_flag=universal_flag).strip() execute_with_buildout(setup_cmd, env=dict(LC_ALL="C")) git_checkout("develop")
def release(self): from infi.projector.helper import assertions from infi.projector.helper.utils import release_version_with_git_flow, git_checkout version_tag = self.replace_version_tag() if not self.arguments.get('--no-fetch', False): self.fetch_origin() assertions.assert_version_tag_for_release(version_tag) assertions.assert_develop_branch_on_top_of_master() assertions.assert_develop_and_master_not_behind_origin() version_tag_without_v = version_tag.lstrip('v') version_tag_with_v = 'v{}'.format(version_tag_without_v) release_version_with_git_flow(version_tag_with_v, self.arguments.get("--keep-leftovers", False)) self.arguments['<version>'] = version_tag push_changes = not self.arguments.get("--no-push-changes", False) if push_changes: self.push_commits_and_tags() if self.arguments.get('--no-upload', False): git_checkout("develop") else: self.upload()
def release(self): from infi.projector.helper import assertions from infi.projector.helper.utils import release_version_with_git_flow, git_checkout version_tag = self.replace_version_tag() if not self.arguments.get('--no-fetch', False): self.fetch_origin() assertions.assert_version_tag_for_release(version_tag) assertions.assert_develop_branch_on_top_of_master() assertions.assert_develop_and_master_not_behind_origin() version_tag_without_v = version_tag.lstrip('v') version_tag_with_v = 'v{}'.format(version_tag_without_v) release_version_with_git_flow(version_tag_with_v, self.arguments.get("--keep-leftovers", False)) self.arguments['<version>'] = version_tag push_changes = not self.arguments.get("--no-push-changes", False) if push_changes: self.push_commits_and_tags() if self.arguments.get('--no-upload', False) or len(self.arguments.get("--pypi-servers")) == 0: git_checkout("develop") else: self.upload()
def build_and_upload_distributions(self, version_tag_with_v): from infi.projector.helper.utils import execute_with_buildout, git_checkout from infi.projector.plugins.builtins.devenv import DevEnvPlugin from infi.execute import execute_assert_success from sys import argv from os.path import join, dirname from shutil import rmtree from tempfile import mkdtemp with open('setup.py') as fd: has_c_extensions = 'ext_modules' in fd.read() for distribution in self.arguments.get("--distributions").split(','): for pypi in self.arguments.get("--pypi-servers").split(','): if not pypi: continue git_checkout(version_tag_with_v) DevEnvPlugin().create_setup_py() setup_cmd = "setup . {distribution}{universal_flag} --dist-dir={temp_dir}" universal_flag = ' --universal' if distribution == 'bdist_wheel' and has_c_extensions else '' temp_dir = mkdtemp() logger.info( "Created temp dir {temp_dir}".format(temp_dir=temp_dir)) try: setup_cmd = setup_cmd.format(pypi=pypi, distribution=distribution, universal_flag=universal_flag, temp_dir=temp_dir).strip() execute_with_buildout(setup_cmd, env=dict(LC_ALL="C")) upload_cmd = "{twine_path} upload --repository {pypi} {temp_dir}" twine_path = join(dirname(argv[0]), "twine") upload_cmd = upload_cmd.format(twine_path=twine_path, pypi=pypi, temp_dir=join( temp_dir, '*')) execute_assert_success(upload_cmd, shell=True) finally: git_checkout("develop") logger.info("Removing temp dir {temp_dir}".format( temp_dir=temp_dir)) rmtree(temp_dir)
def build_and_upload_distributions(self, version_tag_with_v): from infi.projector.helper.utils import execute_with_buildout, git_checkout from infi.projector.plugins.builtins.devenv import DevEnvPlugin with open('setup.py') as fd: has_c_extensions = 'ext_modules' in fd.read() for distribution in self.arguments.get("--distributions").split(','): for pypi in self.arguments.get("--pypi-servers").split(','): if not pypi: continue git_checkout(version_tag_with_v) DevEnvPlugin().create_setup_py() setup_cmd = "setup . register -r {pypi} {distribution} upload -r {pypi} {universal_flag}" universal_flag = '--universal' if distribution == 'bdist_wheel' and has_c_extensions else '' setup_cmd = setup_cmd.format( pypi=pypi, distribution=distribution, universal_flag=universal_flag).strip() execute_with_buildout(setup_cmd, env=dict(LC_ALL="C")) git_checkout("develop")