diff --git a/pigar/.db.sqlite3 b/pigar/.db.sqlite3 index d583a5c..604e0fd 100644 Binary files a/pigar/.db.sqlite3 and b/pigar/.db.sqlite3 differ diff --git a/pigar/dist.py b/pigar/dist.py index 9258254..c47fac7 100644 --- a/pigar/dist.py +++ b/pigar/dist.py @@ -535,13 +535,11 @@ async def _sync_project(self, project_url): dist = db.query_distribution_with_top_level_modules(project_name) try: - with tempfile.TemporaryDirectory() as tmp_download_dir: - # FIXME(damnever): create temporary directory on demand. - version, top_levels = await self._parse_top_levels( - project_name, - project_url, - tmp_download_dir, - ) + version, project_download_url = await self._pypi_distributions.get_latest_distribution_info( + project_name, + project_url, + include_prereleases=False, + ) if version is None: logger.warn( 'distribution "%s" has no valid versions', project_name @@ -553,6 +551,15 @@ async def _sync_project(self, project_url): project_name, dist.version ) return + with tempfile.TemporaryDirectory() as tmp_download_dir: + # FIXME(damnever): create temporary directory on demand. + top_levels = await self._parse_top_levels( + project_name, + project_download_url, + tmp_download_dir, + ) + if top_levels is None: + return modules_to_add = set(top_levels or []) modules_to_delete = None @@ -581,17 +588,12 @@ async def _sync_project(self, project_url): raise e async def _parse_top_levels( - self, project_name, project_url, tmp_download_dir + self, project_name, project_download_url, tmp_download_dir ): - version, url, dist_file = await self._pypi_distributions.get_latest_distribution( - project_name, - project_url, - include_prereleases=False, - tmp_download_dir=tmp_download_dir, + dist_file = await self._pypi_distributions._download_raw( + project_download_url, tmp_download_dir=tmp_download_dir ) - if version is None: - return None, None - filename = urlparse(url).path + filename = urlparse(project_download_url).path event_loop = asyncio.get_event_loop() try: @@ -605,7 +607,7 @@ async def _parse_top_levels( filename, exc_info=True, ) - return None, None + return None top_levels = _maybe_include_project_name_as_import_name( top_levels, project_name ) @@ -616,4 +618,4 @@ async def _parse_top_levels( logger.debug( 'distribution %s parsed top levels: %r', project_name, top_levels ) - return version, top_levels + return top_levels