summary refs log tree commit diff
path: root/gnu/packages/patches
diff options
context:
space:
mode:
authorMarius Bakke <marius@gnu.org>2021-12-13 19:19:52 +0100
committerMarius Bakke <marius@gnu.org>2021-12-13 23:28:58 +0100
commit99e0c4bc74670f9c25567781a3b243e6145f9406 (patch)
tree58a0eb1378185123536ee9964c668edc83b91edc /gnu/packages/patches
parent5940d4cfed213d87e7462b4d54e3bfcc985745d3 (diff)
downloadguix-99e0c4bc74670f9c25567781a3b243e6145f9406.tar.gz
gnu: python-versioneer: Add support for Guix build directories.
* gnu/packages/patches/python-versioneer-guix-support.patch: New file.
* gnu/local.mk (dist_patch_DATA): Adjust accordingly.
* gnu/packages/python-xyz.scm (python-versioneer)[source](patches): New field.
Diffstat (limited to 'gnu/packages/patches')
-rw-r--r--gnu/packages/patches/python-versioneer-guix-support.patch35
1 files changed, 35 insertions, 0 deletions
diff --git a/gnu/packages/patches/python-versioneer-guix-support.patch b/gnu/packages/patches/python-versioneer-guix-support.patch
new file mode 100644
index 0000000000..336020bc5e
--- /dev/null
+++ b/gnu/packages/patches/python-versioneer-guix-support.patch
@@ -0,0 +1,35 @@
+Versioneer does not work in the Guix build container because:
+
+* VCS information is unavailable
+* the build directory does not have the supported "$name-$version" format
+* as of 0.21, versioneer has no way to override the discovered values
+
+This patch adds support for extracting version from the
+'/tmp/guix-build-foo-0.1.drv-0' style directories created by the daemon.
+
+diff --git a/src/from_parentdir.py b/src/from_parentdir.py
+index 69ada9a..e0fac8f 100644
+--- a/src/from_parentdir.py
++++ b/src/from_parentdir.py
+@@ -15,6 +15,21 @@ def versions_from_parentdir(parentdir_prefix, root, verbose):
+             return {"version": dirname[len(parentdir_prefix):],
+                     "full-revisionid": None,
+                     "dirty": False, "error": None, "date": None}
++        # Guix specific patch: try extracting the version from the build
++        # directory.
++        elif dirname.startswith("guix-build-"):
++            delimiter = dirname.rindex(".drv-")
++            name_and_version = dirname[11:delimiter]
++            if name_and_version.startswith(parentdir_prefix):
++                guix_version = name_and_version[len(parentdir_prefix):]
++            elif name_and_version.startswith("python-{}".format(parentdir_prefix)):
++                guix_version = name_and_version[(7 + len(parentdir_prefix)):]
++            else:
++                break
++            return {"version": guix_version,
++                    "full-revisionid": None,
++                    "dirty": False, "error": None, "date": None}
++
+         rootdirs.append(root)
+         root = os.path.dirname(root)  # up a level
+