stashutils.wheels: support for wheel v1.9 dependencies
@@ -9,7 +9,10 @@ import zipfile
import six
from six.moves import configparser
+try:
from stashutils.extensions import create_command
+except ImportError:
+ create_command = None
class WheelError(Exception):
@@ -205,6 +208,11 @@ class ConsoleScriptsHandler(BaseHandler):
print("No console_scripts definition found, skipping.")
return
+ if create_command is None:
+ if self.verbose:
+ print("Warning: could not import create_command(); skipping.")
+ return
+
files_installed = []
mdp = os.path.join(src, self.distinfo_name, "metadata.json")
@@ -268,16 +276,40 @@ class DependencyHandler(BaseHandler):
name = "dependency handler"
def handle_install(self, src, dest):
- metap = os.path.join(src, self.distinfo_name, "metadata.json")
- if not os.path.exists(metap):
+ metajsonp = os.path.join(src, self.distinfo_name, "metadata.json")
+ metadatap = os.path.join(src, self.distinfo_name, "METADATA")
+ if not os.path.exists(metajsonp):
+ if os.path.exists(metadatap):
+ dependencies = self.read_dependencies_from_METADATA(metadatap)
+ else:
if self.verbose:
- print("Warning: could not find 'metadata.json', can not detect dependencies!")
+ print("Warning: could find neither 'metadata.json' not `METADATA`, can not detect dependencies!")
return
- with open(metap, "r") as fin:
+ else:
+ with open(metajsonp, "r") as fin:
content = json.load(fin)
dependencies = content.get("run_requires", [{"requires": []}])[0]["requires"]
self.wheel.dependencies += dependencies
+ def read_dependencies_from_METADATA(self, p):
+ """read dependencies from distinfo/METADATA"""
+ dependencies = []
+ with open(p, "r") as fin:
+ for line in fin:
+ if line.startswith("Requires-Dist: "):
+ t = line[len("Requires-Dist: "):]
+ if ";" in t:
+ # TODO: handle extras
+ es = t[t.find(";") + 1]
+ t = t[:t.find(";")]
+ if "(" in t:
+ # TODO: handle versions
+ t = t[:t.find("(")]
+ while t.endswith(" "):
+ t = t[:-1]
+ dependencies.append(t)
+ return dependencies
+
# list of default handlers
DEFAULT_HANDLERS = [
