summaryrefslogtreecommitdiffstats
path: root/flit_core/update-vendored-tomli.sh
diff options
context:
space:
mode:
Diffstat (limited to 'flit_core/update-vendored-tomli.sh')
-rwxr-xr-xflit_core/update-vendored-tomli.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/flit_core/update-vendored-tomli.sh b/flit_core/update-vendored-tomli.sh
new file mode 100755
index 0000000..c10af1f
--- /dev/null
+++ b/flit_core/update-vendored-tomli.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Update the vendored copy of tomli
+set -euo pipefail
+
+version=$1
+echo "Bundling tomli version $version"
+
+rm -rf flit_core/vendor/tomli*
+pip install --target flit_core/vendor/ "tomli==$version"
+
+# Convert absolute imports to relative (from tomli.foo -> from .foo)
+for file in flit_core/vendor/tomli/*.py; do
+ sed -i -E 's/((from|import)[[:space:]]+)tomli\./\1\./' "$file"
+done
+
+# Delete some files that aren't useful in this context.
+# Leave LICENSE & METADATA present.
+rm flit_core/vendor/tomli*.dist-info/{INSTALLER,RECORD,REQUESTED,WHEEL}