def upload()

in build/upload_release.py [0:0]


def upload():
    release_id = get_release_id(GIT_TAG)
    platform = "libneuropod-{gpustring}-{os}-{tag}".format(
        gpustring="gpu-cuda-{}".format(CUDA_VERSION) if IS_GPU else "cpu",
        os="macos" if IS_MAC else "linux",
        tag=GIT_TAG,
    )

    # Only upload the main library on one build (because we don't need to upload once per backend version)
    # This is also not CPU/GPU dependent
    # For each OS:
    if REQUESTED_TF_VERSION == "1.14.0" and not IS_GPU:
        upload_package(
            "source/bazel-bin/neuropod/libneuropod.tar.gz",
            release_id,
            "libneuropod-{os}-{tag}.tar.gz".format(
                os="macos" if IS_MAC else "linux",
                tag=GIT_TAG,
            )
        )

    if should_upload("torchscript"):
        # For each OS: For each backend version: For each CPU/GPU:
        upload_package("source/bazel-bin/neuropod/backends/torchscript/neuropod_torchscript_backend.tar.gz", release_id, "{}-torchscript-{}-backend.tar.gz".format(platform, REQUESTED_TORCH_VERSION))

    if should_upload("tensorflow"):
        # For each OS: For each backend version: For each CPU/GPU:
        upload_package("source/bazel-bin/neuropod/backends/tensorflow/neuropod_tensorflow_backend.tar.gz", release_id, "{}-tensorflow-{}-backend.tar.gz".format(platform, REQUESTED_TF_VERSION))

    # The python package is the same across CPU/GPU and different versions of backends so we'll only upload once for mac and once for linux
    # TODO(vip): Do this better
    if REQUESTED_TORCH_VERSION not in ["1.6.0", "1.7.0", "1.8.1", "1.9.0"] and not IS_GPU:
        # For each OS: For each python version
        # Upload the pythonbridge backend
        upload_package("source/bazel-bin/neuropod/backends/python_bridge/neuropod_pythonbridge_backend.tar.gz", release_id, "{}-python-{}-backend.tar.gz".format(platform, PYTHON_VERSION))

        # Upload the wheels
        for gpath in ["source/python/dist/neuropod-*.whl"]:
            whl_path = glob.glob(gpath)[0]
            fname = os.path.basename(whl_path)
            upload_package(whl_path, release_id, fname, content_type="application/zip")