from pathlib import Path


def set_package_dir(dist, other_command):
    """Update distribution package_dir if not set
    
    Returns True if updated and other command is present
    """
    ret = not dist.package_dir
    if ret:
        # set package "source" files to be the dist_dir where CMake installs PY component to
        sdist = dist.get_command_obj("sdist")
        sdist.ensure_finalized()
        dist.package_dir = {"": sdist.dist_dir}

        # make sure the directory exists for egg-info creation
        Path(sdist.dist_dir).mkdir(parents=True, exist_ok=True)

        # return True only if other command is used in the build
        ret = bool(dist.get_command_obj(other_command, 0))
    return ret