upload a package to pypi or gemfury
    :return:
180975
def main():
    
    setup_main()
    config = ConfigData(clean=True)
    try:
        config.upload()
    finally:
        config.clean_after_if_needed()
622006
def create_package(package_format, owner, repo, **kwargs):
    """"""
    client = get_packages_api()

    with catch_raise_api_exception():
        upload = getattr(client, "packages_upload_%s_with_http_info" % package_format)

        data, _, headers = upload(
            owner=owner, repo=repo, data=make_create_payload(**kwargs)
        )

    ratelimits.maybe_rate_limit(client, headers)
    return data.slug_perm, data.slug
8575
def install():
    
    # check installed package
    print("Compare to '%s' ..." % DST)
    need_install_flag = check_need_install()
    if not need_install_flag:
        print("    package is up-to-date, no need to install.")
        return
    print("Difference been found, start installing ...")

    # remove __pycache__ folder and *.pyc file
    print("Remove *.pyc file ...")
    pyc_folder_list = list()
    for root, _, basename_list in os.walk(SRC):
        if os.path.basename(root) == "__pycache__":
            pyc_folder_list.append(root)

    for folder in pyc_folder_list:
        shutil.rmtree(folder)
    print("    all *.pyc file has been removed.")

    # install this package to all python version
    print("Uninstall %s from %s ..." % (PKG_NAME, DST))
    try:
        shutil.rmtree(DST)
        print("    Successfully uninstall %s" % PKG_NAME)
    except Exception as e:
        print("    %s" % e)

    print("Install %s to %s ..." % (PKG_NAME, DST))
    shutil.copytree(SRC, DST)
    print("    Complete!")
1358451
def _get_uploaded_versions_pypicloud(project_name, index_url, requests_verify=True):
    
    api_url = index_url
    for suffix in ('/pypi', '/pypi/', '/simple', '/simple/'):
        if api_url.endswith(suffix):
            api_url = api_url[:len(suffix) * -1] + '/api/package'
            break
    url = '/'.join((api_url, project_name))
    response = requests.get(url, verify=requests_verify)
    if response.status_code == 200:
        return [p['version'] for p in response.json()['packages']]
    return None
71837
def add_package(pkg_type, pkg_name, working=None):
    
    kvp = {pkg_type: pkg_name}
    working = os.getcwd() if not working else os.path.abspath(working)
    if '-dist/scripts' in working:
        config = working + "/config.JSON"
    elif '-dist' in working:
        config = working + "/scripts/config.JSON"
    else:
        config = working + "/*-dist/scripts/config.JSON"
        entropy = glob.glob(config)
        if entropy:
            config = entropy[0]  # we'll just assume it's the first one...
    print("config", config, 'working', working)
    config = load_config(config)
    config.update(kvp)
    export_to_json(config)
1275464
def install_package(package, upgrade=True,
                    target=None):
    
    # Not using 'import pip; pip.main([])' because it breaks the logger
    with INSTALL_LOCK:
        if check_package_exists(package, target):
            return True

        _LOGGER.info('Attempting install of %s', package)
        args = [sys.executable, '-m', 'pip', 'install', '--quiet', package]
        if upgrade:
            args.append('--upgrade')
        if target:
            args += ['--target', os.path.abspath(target)]

        try:
            return subprocess.call(args) == 0
        except subprocess.SubprocessError:
            _LOGGER.exception('Unable to install pacakge %s', package)
            return False
426641
def build
      trace "gem build #{gemspec}"
      spec = load_gemspec
      package = ::Gem::Package.build(spec)
      mkdir_p(pkgdir) unless File.directory?(pkgdir)
      mv(package, pkgdir)
    end
236382
def _upload_s3(self, zip_file):
        '''
        
        '''
        s3_client = self._aws_session.client('s3')
        transfer = boto3.s3.transfer.S3Transfer(s3_client)
        transfer.upload_file(zip_file, self._config.s3_bucket,
                             self._config.s3_package_name())
303252
def pip_compile(*packages: str):
    """"""
    result = None
    packages = "\n".join(packages)

    with tempfile.TemporaryDirectory() as tmp_dirname, cwd(tmp_dirname):
        with open("requirements.in", "w") as requirements_file:
            requirements_file.write(packages)

        runner = CliRunner()

        try:
            result = runner.invoke(cli, ["requirements.in"], catch_exceptions=False)
        except Exception as exc:
            raise ThothPipCompileError(str(exc)) from exc

        if result.exit_code != 0:
            error_msg = (
                f"pip-compile returned non-zero ({result.exit_code:d}) " f"output: {result.output_bytes.decode():s}"
            )
            raise ThothPipCompileError(error_msg)

    return result.output_bytes.decode()
144615
def get_py_impl():
    """"""
    if hasattr(sys, 'pypy_version_info'):
        pyimpl = 'PyPy'
    elif sys.platform.startswith('java'):
        pyimpl = 'Jython'
    elif sys.platform == 'cli':
        pyimpl = 'IronPython'
    else:
        pyimpl = 'CPython'
    return pyimpl
757994
def build_package
      filename = config.tarball_filename(config.toml[:package][:version])
      relative_library_path = config.ruby_extension_path.sub("#{config.ruby_toplevel_dir}/", '')
      prepare_built_library
      Zlib::GzipWriter.open(filename) do |tgz|
        Dir.chdir(config.ruby_toplevel_dir) do
          Archive::Tar::Minitar.pack(relative_library_path, tgz)
        end
      end
    end
310206
def upload(target):
    # type: (str) -> None
    
    log.info("Uploading to pypi server <33>{}".format(target))
    with conf.within_proj_dir():
        shell.run('python setup.py sdist register -r "{}"'.format(target))
        shell.run('python setup.py sdist upload -r "{}"'.format(target))
414854
def install(self):
        
        packages = self.packages()
        if packages:
            print("")   # new line at start
            for pkg in packages:
                ver = SBoGrep(pkg).version()
                prgnam = "{0}-{1}".format(pkg, ver)
                if find_package(prgnam, self.meta.output):
                    binary = slack_package(prgnam)
                    PackageManager(binary).upgrade(flag="--install-new")
                else:
                    print("\nPackage {0} not found in the {1} for "
                          "installation\n".format(prgnam, self.meta.output))
        else:
            print("\nPackages not found in the queue for installation\n")
            raise SystemExit(1)
1033396
def unpack(&bl)
      dir = nil
      pkg = ::Gem::Installer.new gem_path, :unpack => true

      if bl
        Dir.mktmpdir do |tmpdir|
          pkg.unpack tmpdir
          bl.call tmpdir
        end
      else
        dir = Dir.mktmpdir
        pkg.unpack dir
      end

      dir
    end
497924
def upload(self, force=False):
        
        self.package and self.release
        try:
            return self.aserver_api.upload(self.username, self.project, self.version,
                                       basename(self.filepath), open(self.filepath, 'rb'),
                                       self.filepath.split('.')[-1])
        except errors.Conflict:
            if force:
                self.remove()
                return self.upload()
            else:
                msg = "Conflict: {} already exist in {}/{}".format(self.filepath,
                                                                   self.project,
                                                                   self.version)
                raise errors.BinstarError(msg)
917976
def upload(ui, repo, name, **opts):
	
	if codereview_disabled:
		raise hg_util.Abort(codereview_disabled)

	repo.ui.quiet = True
	cl, err = LoadCL(ui, repo, name, web=True)
	if err != "":
		raise hg_util.Abort(err)
	if not cl.local:
		raise hg_util.Abort("cannot upload non-local change")
	cl.Upload(ui, repo)
	print "%s%s\n" % (server_url_base, cl.name)
	return 0
1202023
def upload(dist_dir):
    

    if 'PYPI_USER' in os.environ and 'PYPI_PASS' in os.environ:
        pypi_user = os.environ['PYPI_USER']
        pypi_pass = os.environ['PYPI_PASS']
    else:
        pypi_user = None
        pypi_pass = None
        print("No PYPI user information in environment")

    packages = glob.glob(dist_dir)

    # Invoke upload this way since subprocess call of twine cli has cross platform issues
    twine_upload(packages, 'pypi', False, None, pypi_user, pypi_pass, None, None, '~/.pypirc', False, None, None, None)