diff --git a/autospec/autospec.py b/autospec/autospec.py index e8c3587a..d6d14643 100644 --- a/autospec/autospec.py +++ b/autospec/autospec.py @@ -240,7 +240,7 @@ def package(args, url, name, archives, workingdir): license.scan_for_licenses(os.path.dirname(_dir), conf, name) exit(0) - requirements.scan_for_configure(_dir, content.name, conf) + requirements.scan_for_configure(_dir, content.name, conf, content) specdescription.scan_for_description(content.name, _dir, conf.license_translations, conf.license_blacklist) # Start one directory higher so we scan *all* versions for licenses license.scan_for_licenses(os.path.dirname(_dir), conf, content.name) diff --git a/autospec/buildreq.py b/autospec/buildreq.py index 0cd4197b..b22ea258 100644 --- a/autospec/buildreq.py +++ b/autospec/buildreq.py @@ -767,7 +767,7 @@ def parse_catkin_deps(self, cmakelists_file, conf32): self.extra_cmake.add("-DCATKIN_BUILD_BINARY_PACKAGE=ON") self.extra_cmake.add("-DSETUPTOOLS_DEB_LAYOUT=OFF") - def scan_for_configure(self, dirn, tname, config): + def scan_for_configure(self, dirn, tname, config, content): """Scan the package directory for build files to determine build pattern.""" if config.default_pattern == "distutils36": self.add_buildreq("buildreq-distutils36") @@ -902,7 +902,7 @@ def scan_for_configure(self, dirn, tname, config): if config.alias: tname = config.alias pypi_name = pypidata.get_pypi_name(tname) - pypi_json = pypidata.get_pypi_metadata(pypi_name) + pypi_json = pypidata.get_pypi_metadata(pypi_name, content.version) if pypi_json: try: package_pypi = json.loads(pypi_json) diff --git a/autospec/pypidata.py b/autospec/pypidata.py index 3535b683..bfb2c5f0 100755 --- a/autospec/pypidata.py +++ b/autospec/pypidata.py @@ -44,7 +44,7 @@ def get_pypi_name(name): return name -def get_pypi_metadata(name): +def get_pypi_metadata(name, version=None): """Get metadata for a pypi package.""" show = [] # Create virtenv to do the pip install (needed for pip show) @@ -52,7 +52,11 @@ def get_pypi_metadata(name): proc = subprocess.run(["virtualenv", "--no-periodic-update", tdir], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) if proc.returncode != 0: return "" - proc = subprocess.run(f"source bin/activate && pip install {name}", cwd=tdir, shell=True, + if version: + target = f"{name}=={version}" + else: + target = name + proc = subprocess.run(f"source bin/activate && pip install {target}", cwd=tdir, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, env=pip_env()) if proc.returncode != 0: