def btc_tx_make_input_signature(tx, idx, prevout_script, privkey_str, hashcode):
    """
    Sign a single input of a transaction, given the serialized tx,
    the input index, the output's scriptPubkey, and the hashcode.

    tx must be a hex-encoded string
    privkey_str must be a hex-encoded private key

    Return the hex signature.

    THIS DOES NOT WORK WITH SEGWIT TRANSACTIONS
    """
    if btc_tx_is_segwit(tx):
        raise ValueError('tried to use the standard sighash to sign a segwit transaction')

    pk = ecdsalib.ecdsa_private_key(str(privkey_str))
    priv = pk.to_hex()

    # get the parts of the tx we actually need to sign
    sighash = btc_tx_sighash(tx, idx, prevout_script, hashcode)
    # print 'non-segwit sighash: {}'.format(sighash)

    # sign using uncompressed private key
    pk_uncompressed_hex, pubk_uncompressed_hex = ecdsalib.get_uncompressed_private_and_public_keys(priv)
    sigb64 = ecdsalib.sign_digest( sighash, priv )

    # sanity check 
    # assert ecdsalib.verify_digest( txhash, pubk_uncompressed_hex, sigb64 )

    sig_r, sig_s = ecdsalib.decode_signature(sigb64)
    sig_bin = btc_tx_der_encode_signature(sig_r, sig_s)
    sig = sig_bin.encode('hex') + encoding.encode(hashcode, 16, 2)

    return sig