29a12eb86a
This adds pep517(needed for flit-core to build itself) and flit python package types. We need to add an installer script and pass it appropriate options for installing pep517 wheels generated by python-pypa-build during the build stage. Unfortunately it seems pep517 does not support builds without using the wheel format. We also need to add a patch fixing the version parser in flit-core. Signed-off-by: James Hilliard <james.hilliard1@gmail.com> [Arnout: - fix indentation in pkg-python.mk (tabs, not spaces); - use the new _CMD variables instead of duplicating the entire _CMDS definitions; - no need to filter dependencies (they're not self-referencing); - _NEEDS_HOST_PYTHON no longer exists; - host-python-pypa-build gets added to DEPENDENCIES automatically. ] Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
81 lines
3.0 KiB
Diff
81 lines
3.0 KiB
Diff
From 2cd8b5708be88b90ea2fa0fb35407a5ec2038c8e Mon Sep 17 00:00:00 2001
|
|
From: James Hilliard <james.hilliard1@gmail.com>
|
|
Date: Sat, 27 Nov 2021 02:36:15 -0700
|
|
Subject: [PATCH] Fix ast version parser for multiple assignments
|
|
|
|
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
|
|
[Upstream status:
|
|
https://github.com/takluyver/flit/pull/474]
|
|
---
|
|
flit_core/common.py | 21 +++++++++++--------
|
|
.../tests/samples/moduleunimportabledouble.py | 8 +++++++
|
|
flit_core/tests/test_common.py | 5 +++++
|
|
3 files changed, 25 insertions(+), 9 deletions(-)
|
|
create mode 100644 flit_core/tests/samples/moduleunimportabledouble.py
|
|
|
|
diff --git a/flit_core/common.py b/flit_core/common.py
|
|
index f1f378f..86bcf4b 100644
|
|
--- a/flit_core/common.py
|
|
+++ b/flit_core/common.py
|
|
@@ -132,15 +132,18 @@ def get_docstring_and_version_via_ast(target):
|
|
for child in node.body:
|
|
# Only use the version from the given module if it's a simple
|
|
# string assignment to __version__
|
|
- is_version_str = (
|
|
- isinstance(child, ast.Assign)
|
|
- and len(child.targets) == 1
|
|
- and isinstance(child.targets[0], ast.Name)
|
|
- and child.targets[0].id == "__version__"
|
|
- and isinstance(child.value, ast.Str)
|
|
- )
|
|
- if is_version_str:
|
|
- version = child.value.s
|
|
+ if isinstance(child, ast.Assign):
|
|
+ for target in child.targets:
|
|
+ is_version_str = (
|
|
+ isinstance(target, ast.Name)
|
|
+ and target.id == "__version__"
|
|
+ and isinstance(child.value, ast.Str)
|
|
+ )
|
|
+ if is_version_str:
|
|
+ version = child.value.s
|
|
+ break
|
|
+ else:
|
|
+ continue
|
|
break
|
|
else:
|
|
version = None
|
|
diff --git a/flit_core/tests/samples/moduleunimportabledouble.py b/flit_core/tests/samples/moduleunimportabledouble.py
|
|
new file mode 100644
|
|
index 0000000..42d51f3
|
|
--- /dev/null
|
|
+++ b/flit_core/tests/samples/moduleunimportabledouble.py
|
|
@@ -0,0 +1,8 @@
|
|
+
|
|
+"""
|
|
+A sample unimportable module with double assignment
|
|
+"""
|
|
+
|
|
+raise ImportError()
|
|
+
|
|
+VERSION = __version__ = "0.1"
|
|
diff --git a/flit_core/tests/test_common.py b/flit_core/tests/test_common.py
|
|
index 02cfab7..42e230b 100644
|
|
--- a/flit_core/tests/test_common.py
|
|
+++ b/flit_core/tests/test_common.py
|
|
@@ -70,6 +70,11 @@ class ModuleTests(TestCase):
|
|
'version': '0.1'}
|
|
)
|
|
|
|
+ info = get_info_from_module(Module('moduleunimportabledouble', samples_dir))
|
|
+ self.assertEqual(info, {'summary': 'A sample unimportable module with double assignment',
|
|
+ 'version': '0.1'}
|
|
+ )
|
|
+
|
|
info = get_info_from_module(Module('module1', samples_dir / 'constructed_version'))
|
|
self.assertEqual(info, {'summary': 'This module has a __version__ that requires runtime interpretation',
|
|
'version': '1.2.3'}
|
|
--
|
|
2.33.1
|
|
|