in chalice/deploy/packager.py [0:0]
def _get_pkg_info_filepath(self, package_dir: str) -> str:
setup_py = self._osutils.joinpath(package_dir, 'setup.py')
script = self._SETUPTOOLS_SHIM % setup_py
cmd = [
sys.executable,
'-c',
script,
'--no-user-cfg',
'egg_info',
'--egg-base',
'egg-info',
]
egg_info_dir = self._osutils.joinpath(package_dir, 'egg-info')
self._osutils.makedirs(egg_info_dir)
p = subprocess.Popen(
cmd,
cwd=package_dir,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
_, stderr = p.communicate()
if p.returncode != 0:
logger.debug(
"Non zero rc (%s) from the setup.py egg_info command: %s",
p.returncode,
stderr,
)
info_contents = self._osutils.get_directory_contents(egg_info_dir)
if info_contents:
pkg_info_path = self._osutils.joinpath(
egg_info_dir, info_contents[0], 'PKG-INFO'
)
else:
# This might be a pep 517 package in which case this PKG-INFO file
# should be available right in the top level directory of the sdist
# in the case where the egg_info command fails.
logger.debug(
"Using fallback location for PKG-INFO file in "
"package directory: %s",
package_dir,
)
pkg_info_path = self._osutils.joinpath(package_dir, 'PKG-INFO')
if not self._osutils.file_exists(pkg_info_path):
raise UnsupportedPackageError(self._osutils.basename(package_dir))
return pkg_info_path