def get_package_name_and_version()

in aws_lambda_builders/workflows/python_pip/packager.py [0:0]


    def get_package_name_and_version(self, sdist_path: str) -> Tuple[str, str]:
        """
        Gets the package's name and version from the metadata file

        Parameters
        ----------
        sdist_path: str
            The string path of the downloaded source distribution artifact

        Returns
        -------
        Tuple[str, str]
            A tuple of the name and version of the package
        """
        with self._osutils.tempdir() as tempdir:
            package_dir = self._unpack_sdist_into_dir(sdist_path, tempdir)

            # get the name and version from the result setup.py
            pkg_info_filepath = self._get_pkg_info_filepath(package_dir)
            name, version = self._get_name_version(pkg_info_filepath)

            # return values if it is not the default values
            if not self._is_default_setuptools_values(name, version):
                return name, version

            # see if we can get the fallback PKG_INFO file from the sdist
            fallback_pkg_info_fp = self._get_fallback_pkg_info_filepath(package_dir)

            if self._osutils.file_exists(fallback_pkg_info_fp):
                # use the fallback values instead of the ones we generated
                fallback_name, fallback_version = self._get_name_version(fallback_pkg_info_fp)

                if not self._is_default_setuptools_values(fallback_name, fallback_version):
                    name = fallback_name
                    version = fallback_version

        return name, version