changeset 157:150085e39072

flatpak (build_manifest): version can be forced in setup_requirements + force cython version in cagou template
author Goffi <goffi@goffi.org>
date Tue, 23 Jul 2019 21:57:41 +0200
parents 0a92bb60db12
children c5037f25490a
files flatpak/_tpl_org.salutatoi.Cagou.json flatpak/build_manifest.py
diffstat 2 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/flatpak/_tpl_org.salutatoi.Cagou.json	Fri Jun 28 15:21:43 2019 +0200
+++ b/flatpak/_tpl_org.salutatoi.Cagou.json	Tue Jul 23 21:57:41 2019 +0200
@@ -2,7 +2,7 @@
     "_build_settings": {
         "wrapped_command": "cagou",
         "dev_repos": {"type": "hg", "url": "https://repos.goffi.org/cagou"},
-        "setup_requirements": ["cython"],
+        "setup_requirements": [["cython", "0.29.10"]],
         "icon": "https://repos.goffi.org/sat_media/raw-file/tip/icons/muchoslava/svg/cagou_profil_bleu_avec_cou.svg",
         "desktop_file": "org.salutatoi.Cagou.desktop",
         "appdata_file": "_tpl_org.salutatoi.Cagou.appdata.xml"
--- a/flatpak/build_manifest.py	Fri Jun 28 15:21:43 2019 +0200
+++ b/flatpak/build_manifest.py	Tue Jul 23 21:57:41 2019 +0200
@@ -232,7 +232,13 @@
     """Generate module for a Python package
 
     @param package_name(str, list[str]): name of the Python package
-        use list of str to get several packages at once
+        use list of str to get several packages at once.
+        A (name, version) tuple (or any size 2 iterable) can be used to force version of a
+        package.
+        If package is a list with iterables, it will be modified in place to keep only the
+        name as string. This is because version is not needed anymore after that, but
+        name is still used to remove dependencies already installed with setup
+        requirements.
     @param step_name(None, str): name of the step, None to use package_name
     @param step_message(None, str): message of the step (None to use default one)
         use empty string to disable it
@@ -250,13 +256,22 @@
         return cache
     package_names = [package_name] if single else package_name
     data = []
-    for name in package_names:
+
+    for idx, name in enumerate(package_names):
+        if not isinstance(name, str):
+            if version is not None:
+                raise ValueError(
+                    "forced version can't be used with packages versions (i.e. tuples)")
+            name, forced_version = name
+            package_names[idx] = name
+        else:
+            forced_version = version
         r = requests.get(f"https://pypi.org/pypi/{name}/json")
         r.raise_for_status()
 
         releases_data = []
         for version_raw, release_data in r.json()["releases"].items():
-            if version is not None and version != version_raw:
+            if forced_version is not None and forced_version != version_raw:
                 continue
             release_version = parse_version(version_raw)
             if release_version.is_prerelease and not with_pre: