def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--overwrite', action='store_true', default=False,
                        help='Overwrite files if already exist')
    parser.add_argument('--dist-dir', default='./dist/',
                        help='The temporary directory to download artifacts')
    parser.add_argument(
        'tag',
        help=('Git tag of the version to upload.  If it has a leading slash, '
              'it means AppVeyor build number rather than Git tag.')
    )
    args = parser.parse_args()
    if args.tag.startswith('/'):
        build = {'version': args.tag.lstrip('/')}
    else:
        build = ci_tag_build(args.tag)
    jobs = ci_jobs(build)
    if not os.path.isdir(args.dist_dir):
        print(args.dist_dir, 'does not exist yet; creating a new directory...')
        os.makedirs(args.dist_dir)
    dists = []
    for job in jobs:
        artifacts = ci_artifacts(job)
        for artifact in artifacts:
            dist = download_artifact(artifact, args.dist_dir, args.overwrite)
            dists.append(dist)
    print('Uploading {0} file(s)...'.format(len(dists)))
    upload.main(('-r', 'pypi') + tuple(dists))
예제 #2
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--overwrite',
        action='store_true',
        default=False,
        help='Overwrite files if already exist',
    )
    parser.add_argument(
        '--dist-dir',
        default='./dist/',
        help='The temporary directory to download artifacts',
    )
    parser.add_argument(
        'tag',
        help=('Git tag of the version to upload.  If it has a leading slash, '
              'it means AppVeyor build number rather than Git tag.'),
    )
    args = parser.parse_args()
    if args.tag.startswith('/'):
        build = {'version': args.tag.lstrip('/')}
    else:
        build = ci_tag_build(args.tag)
    jobs = ci_jobs(build)
    if not os.path.isdir(args.dist_dir):
        print(args.dist_dir, 'does not exist yet; creating a new directory...')
        os.makedirs(args.dist_dir)
    dists = []
    for job in jobs:
        artifacts = ci_artifacts(job)
        for artifact in artifacts:
            dist = download_artifact(artifact, args.dist_dir, args.overwrite)
            dists.append(dist)
    print('Uploading {} file(s)...'.format(len(dists)))
    upload.main(('-r', 'pypi') + tuple(dists))
예제 #3
0
def _upload(dist, upload_repo):
    from twine.commands import upload
    _check_wheel_metadata_version(dist)
    args = _twine_upload_args(dist, upload_repo)
    try:
        upload.main(args)
    except Exception as e:
        _handle_twine_error(e)
def main():
    os.makedirs('dist', exist_ok=True)
    for python in (
            'cp27-cp27mu',
            'cp35-cp35m',
            'cp36-cp36m',
            'cp37-cp37m',
    ):
        with tempfile.TemporaryDirectory() as work:
            pip = '/opt/python/{}/bin/pip'.format(python)
            check_call(
                'docker',
                'run',
                '-ti',
                # Use this so the files are not owned by root
                '--user',
                '{}:{}'.format(os.getuid(), os.getgid()),
                # We'll do building in /work and copy results to /dist
                '-v',
                '{}:/work:rw'.format(work),
                '-v',
                '{}:/dist:rw'.format(os.path.abspath('dist')),
                'quay.io/pypa/manylinux1_x86_64:latest',
                'bash',
                '-exc',
                '{} wheel --verbose --wheel-dir /work --no-deps libsass && '
                'auditwheel repair --wheel-dir /dist /work/*.whl'.format(pip),
            )
    dists = tuple(os.path.join('dist', p) for p in os.listdir('dist'))
    return upload.main(('-r', 'pypi', '--skip-existing') + dists)
예제 #5
0
    def run(self):
        from twine.commands import upload
        from devops import PROJECT_PACKAGE
        assert hasattr(PROJECT_PACKAGE,
                       'PROJECT_DIR'), "No PROJECT_DIR variable declared"
        assert PROJECT_PACKAGE.PROJECT_DIR, "No PROJECT_DIR variable injected"

        distributions = [
            path.as_posix() for path in Path(PROJECT_PACKAGE.PROJECT_DIR).glob(
                self.distributions_glob) if path.is_file()
        ]
        return upload.main(distributions)
예제 #6
0
파일: publish.py 프로젝트: lhaze/dharma
    def run(self):
        from twine.commands import upload
        from devops import PROJECT_PACKAGE
        assert hasattr(PROJECT_PACKAGE, 'PROJECT_DIR'), "No PROJECT_DIR variable declared"
        assert PROJECT_PACKAGE.PROJECT_DIR, "No PROJECT_DIR variable injected"

        distributions = [
            path.as_posix() for path in
            Path(PROJECT_PACKAGE.PROJECT_DIR).glob(self.distributions_glob)
            if path.is_file()
        ]
        return upload.main(distributions)
예제 #7
0
    def upload(self, wheel):
        """
        Upload a wheel to PyPI.

        Args:
            wheel (str): Path to a wheel package.

        Raises:
            WheelAlreadyPublishedException: Raised when the wheel already exists in the PyPI
                repository.
        """

        wheel = os.path.abspath(wheel)

        wheel_version = os.path.basename(wheel).split('-')[1]

        wheel_url = 'https://{}/manage/project/{}/release/{}/'.format(
            self._site, self._extract_project_name(wheel), wheel_version)

        args = '--username {} --password {}'.format(self.username,
                                                    self.password)
        if self.repository_url:
            args = '{} --repository-url {}'.format(args, self.repository_url)

        args = shlex_split('{} {}'.format(args, wheel))

        try:
            self._debug('Uploading wheel to PyPI repository...', wheel=wheel)
            upload.main(args)
            self._debug('Successfully uploaded wheel', wheel_url=wheel_url)
            return wheel_url
        except BaseException as e:

            if 'File already exists' in str(e):
                wheel_name = os.path.basename(wheel)
                raise exceptions.WheelAlreadyPublishedException(
                    wheel=wheel_name, url=wheel_url)

            raise exceptions.FailedPublishingWheelException(wheel=wheel,
                                                            error=str(e))
예제 #8
0
def upload_to_pypi(release_name):
    with open("version.json", "r") as f:
        version = json.load(f)

    version_name = '{major}.{minor}.{patch}'.format(**version)

    print(
        f'{bcolors.UNDERLINE}{bcolors.BOLD}{bcolors.WARNING}-- Using version {version_name}!{bcolors.ENDC}'
    )

    if release_name and release_name.lower() in [
            'master', 'test', 'development'
    ]:
        raise ValueError(
            'May not rename wheel to {}. To deploy a wheel by that name, checkout that branch'
        )

    if not release_name:
        release_name = version_name

    release_name = release_name.replace("-", "_")
    local_file = f"dist/{_project_name}-{version_name}.tar.gz"
    remote_file = f"{_project_name}-{release_name}.tar.gz"

    os.mkdir('deploy')
    shutil.copy(local_file, f"deploy/{remote_file}")

    print(
        f"{bcolors.UNDERLINE}{bcolors.BOLD}{bcolors.OKBLUE}-- Deploying [{local_file}] -> [{remote_file}]{bcolors.ENDC}"
    )

    upload.main([
        'deploy/*', '-u',
        os.getenv('TWINE_USERNAME'), '-p',
        os.getenv('TWINE_PASSWORD')
    ])

    print(f"{bcolors.OKGREEN}{bcolors.BOLD}-- Deployed!{bcolors.ENDC}")
예제 #9
0
def main():
    os.makedirs('dist', exist_ok=True)
    for python in (
            'cp27-cp27mu',
            'cp34-cp34m',
            'cp35-cp35m',
    ):
        with tempfile.TemporaryDirectory() as work:
            pip = '/opt/python/{}/bin/pip'.format(python)
            check_call(
                'docker', 'run', '-ti',
                # Use this so the files are not owned by root
                '--user', '{}:{}'.format(os.getuid(), os.getgid()),
                # We'll do building in /work and copy results to /dist
                '-v', '{}:/work:rw'.format(work),
                '-v', '{}:/dist:rw'.format(os.path.abspath('dist')),
                'quay.io/pypa/manylinux1_x86_64:latest',
                'bash', '-exc',
                '{} wheel --verbose --wheel-dir /work --no-deps libsass && '
                'auditwheel repair --wheel-dir /dist /work/*.whl'.format(pip)
            )
    dists = tuple(os.path.join('dist', p) for p in os.listdir('dist'))
    return upload.main(('-r', 'pypi') + dists)
예제 #10
0
파일: setup.py 프로젝트: Yaroglek/abu
 def deploy():
     from twine.commands import upload
     upload.main(['dist/*'])