(username=None, user='sympy', token=None,
    token_file_path="~/.sympy/release-token", repo='sympy', draft=False)
Upload the release files to GitHub.

    The tag must be pushed up first. You can test on another repo by changing
    user and repo.
Upload the release files to GitHub.
Upload the release files to GitHub .
def GitHub_release(username=None, user='sympy', token=None,
    token_file_path="~/.sympy/release-token", repo='sympy', draft=False):
    """
    Upload the release files to GitHub.

    The tag must be pushed up first. You can test on another repo by changing
    user and repo.
    """
    if not requests:
        error("requests and requests-oauthlib must be installed to upload to GitHub")

    release_text = GitHub_release_text()
    version = get_sympy_version()
    short_version = get_sympy_short_version()
    tag = 'sympy-' + version
    prerelease = short_version != version

    urls = URLs(user=user, repo=repo)
    if not username:
        username = raw_input("GitHub username: ")
    token = load_token_file(token_file_path)
    if not token:
        username, password, token = GitHub_authenticate(urls, username, token)

    # If the tag in question is not pushed up yet, then GitHub will just
    # create it off of master automatically, which is not what we want.  We
    # could make it create it off the release branch, but even then, we would
    # not be sure that the correct commit is tagged.  So we require that the
    # tag exist first.
    if not check_tag_exists():
        error("The tag for this version has not been pushed yet. Cannot upload the release.")

    # See http://developer.github.com/v3/repos/releases/#create-a-release
    # First, create the release
    post = {}
    post['tag_name'] = tag
    post['name'] = "SymPy " + version
    post['body'] = release_text
    post['draft'] = draft
    post['prerelease'] = prerelease

    print("Creating release for tag", tag, end=' ')

    result = query_GitHub(urls.releases_url, username, password=None,
        token=token, data=json.dumps(post)).json()
    release_id = result['id']

    print(green("Done"))

    # Then, upload all the files to it.
    for key in descriptions:
        tarball = get_tarball_name(key)

        params = {}
        params['name'] = tarball

        if tarball.endswith('gz'):
            headers = {'Content-Type':'application/gzip'}
        elif tarball.endswith('pdf'):
            headers = {'Content-Type':'application/pdf'}
        elif tarball.endswith('zip'):
            headers = {'Content-Type':'application/zip'}
        else:
            headers = {'Content-Type':'application/octet-stream'}

        print("Uploading", tarball, end=' ')
        sys.stdout.flush()
        with open(os.path.join("release", tarball), 'rb') as f:
            result = query_GitHub(urls.release_uploads_url % release_id, username,
                password=None, token=token, data=f, params=params,
                headers=headers).json()

        print(green("Done"))
def GitHub_release ( username = None , user = 'sympy' , token = None , token_file_path = "~/.sympy/release-token" , repo = 'sympy' , draft = False ) : if not requests : error ( "requests and requests-oauthlib must be installed to upload to GitHub" ) release_text = GitHub_release_text ( ) version = get_sympy_version ( ) short_version = get_sympy_short_version ( ) tag = 'sympy-' + version prerelease = short_version != version urls = URLs ( user = user , repo = repo ) if not username : username = raw_input ( "GitHub username: " ) token = load_token_file ( token_file_path ) if not token : username , password , token = GitHub_authenticate ( urls , username , token ) # If the tag in question is not pushed up yet, then GitHub will just # create it off of master automatically, which is not what we want.  We # could make it create it off the release branch, but even then, we would # not be sure that the correct commit is tagged.  So we require that the # tag exist first. if not check_tag_exists ( ) : error ( "The tag for this version has not been pushed yet. Cannot upload the release." ) # See http://developer.github.com/v3/repos/releases/#create-a-release # First, create the release post = { } post [ 'tag_name' ] = tag post [ 'name' ] = "SymPy " + version post [ 'body' ] = release_text post [ 'draft' ] = draft post [ 'prerelease' ] = prerelease print ( "Creating release for tag" , tag , end = ' ' ) result = query_GitHub ( urls . releases_url , username , password = None , token = token , data = json . dumps ( post ) ) . json ( ) release_id = result [ 'id' ] print ( green ( "Done" ) ) # Then, upload all the files to it. for key in descriptions : tarball = get_tarball_name ( key ) params = { } params [ 'name' ] = tarball if tarball . endswith ( 'gz' ) : headers = { 'Content-Type' : 'application/gzip' } elif tarball . endswith ( 'pdf' ) : headers = { 'Content-Type' : 'application/pdf' } elif tarball . endswith ( 'zip' ) : headers = { 'Content-Type' : 'application/zip' } else : headers = { 'Content-Type' : 'application/octet-stream' } print ( "Uploading" , tarball , end = ' ' ) sys . stdout . flush ( ) with open ( os . path . join ( "release" , tarball ) , 'rb' ) as f : result = query_GitHub ( urls . release_uploads_url % release_id , username , password = None , token = token , data = f , params = params , headers = headers ) . json ( ) print ( green ( "Done" ) )