Lint.
This commit is contained in:
parent
d794b63d71
commit
d75c1a2f95
3 changed files with 40 additions and 22 deletions
|
@ -6,19 +6,18 @@ import argparse
|
||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import ast
|
|
||||||
import pathlib
|
import pathlib
|
||||||
from itertools import chain
|
|
||||||
import stat
|
import stat
|
||||||
import sys
|
import sys
|
||||||
from collections import defaultdict
|
|
||||||
import zipfile
|
import zipfile
|
||||||
|
from collections import defaultdict
|
||||||
from email.parser import Parser
|
from email.parser import Parser
|
||||||
|
from itertools import chain
|
||||||
from shutil import move
|
from shutil import move
|
||||||
from tempfile import TemporaryDirectory
|
from tempfile import TemporaryDirectory
|
||||||
|
|
||||||
from zapp.support.unpack import cache_wheel_path
|
|
||||||
from zapp.support.pep425 import compress_tags, decompress_tag
|
from zapp.support.pep425 import compress_tags, decompress_tag
|
||||||
|
from zapp.support.unpack import cache_wheel_path
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="The (bootstrap) Zapp compiler")
|
parser = argparse.ArgumentParser(description="The (bootstrap) Zapp compiler")
|
||||||
parser.add_argument("-o", "--out", dest="output", help="Output target file")
|
parser.add_argument("-o", "--out", dest="output", help="Output target file")
|
||||||
|
@ -84,12 +83,14 @@ def load_wheel(opts, manifest, path):
|
||||||
|
|
||||||
def _parse_email(msg):
|
def _parse_email(msg):
|
||||||
msg = Parser().parsestr(msg)
|
msg = Parser().parsestr(msg)
|
||||||
|
|
||||||
def _get(k):
|
def _get(k):
|
||||||
v = msg.get_all(k)
|
v = msg.get_all(k)
|
||||||
if len(v) == 1:
|
if len(v) == 1:
|
||||||
return v[0]
|
return v[0]
|
||||||
else:
|
else:
|
||||||
return v
|
return v
|
||||||
|
|
||||||
return {k: _get(k) for k in msg.keys()}
|
return {k: _get(k) for k in msg.keys()}
|
||||||
|
|
||||||
# RECORD seems to just record file reference checksums for validation
|
# RECORD seems to just record file reference checksums for validation
|
||||||
|
@ -104,7 +105,14 @@ def load_wheel(opts, manifest, path):
|
||||||
|
|
||||||
prefix = os.path.dirname(path)
|
prefix = os.path.dirname(path)
|
||||||
|
|
||||||
sources = [(dest, spec,) for dest, spec in manifest["sources"] if spec["source"].startswith(prefix)]
|
sources = [
|
||||||
|
(
|
||||||
|
dest,
|
||||||
|
spec,
|
||||||
|
)
|
||||||
|
for dest, spec in manifest["sources"]
|
||||||
|
if spec["source"].startswith(prefix)
|
||||||
|
]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
# "record": record,
|
# "record": record,
|
||||||
|
@ -171,6 +179,7 @@ def rezip_wheels(opts, manifest):
|
||||||
|
|
||||||
if opts.debug:
|
if opts.debug:
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
print("---")
|
print("---")
|
||||||
pprint({"$type": "whl", **w})
|
pprint({"$type": "whl", **w})
|
||||||
|
|
||||||
|
@ -187,7 +196,6 @@ def rezip_wheels(opts, manifest):
|
||||||
else:
|
else:
|
||||||
wf = zip_wheel(opts.tmpdir, w)
|
wf = zip_wheel(opts.tmpdir, w)
|
||||||
|
|
||||||
|
|
||||||
# Insert a new wheel source
|
# Insert a new wheel source
|
||||||
manifest["wheels"][wn] = {"hashes": [], "source": wf}
|
manifest["wheels"][wn] = {"hashes": [], "source": wf}
|
||||||
|
|
||||||
|
@ -248,15 +256,19 @@ def enable_unzipping(opts, manifest):
|
||||||
"""Inject unzipping behavior as needed."""
|
"""Inject unzipping behavior as needed."""
|
||||||
|
|
||||||
if manifest["wheels"]:
|
if manifest["wheels"]:
|
||||||
manifest["prelude_points"].extend([
|
manifest["prelude_points"].extend(
|
||||||
"zapp.support.unpack:unpack_deps",
|
[
|
||||||
"zapp.support.unpack:install_deps",
|
"zapp.support.unpack:unpack_deps",
|
||||||
])
|
"zapp.support.unpack:install_deps",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
if not manifest["zip_safe"]:
|
if not manifest["zip_safe"]:
|
||||||
manifest["prelude_points"].extend([
|
manifest["prelude_points"].extend(
|
||||||
"zapp.support.unpack:unpack_zapp",
|
[
|
||||||
])
|
"zapp.support.unpack:unpack_zapp",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
return manifest
|
return manifest
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,9 @@ def decompress_tag(tag: str) -> t.Iterable[Tag]:
|
||||||
"""Decompress tag string into a sequence of compatible tuples."""
|
"""Decompress tag string into a sequence of compatible tuples."""
|
||||||
|
|
||||||
pytags, abitags, archtags = tag.split("-", 2)
|
pytags, abitags, archtags = tag.split("-", 2)
|
||||||
for x in pytags.split('.'):
|
for x in pytags.split("."):
|
||||||
for y in abitags.split('.'):
|
for y in abitags.split("."):
|
||||||
for z in archtags.split('.'):
|
for z in archtags.split("."):
|
||||||
yield Tag(x, y, z)
|
yield Tag(x, y, z)
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,10 +27,12 @@ def compress_tags(tags: t.Iterable[Tag]) -> str:
|
||||||
abitags = set(t.abi for t in tags)
|
abitags = set(t.abi for t in tags)
|
||||||
archtags = set(t.arch for t in tags)
|
archtags = set(t.arch for t in tags)
|
||||||
|
|
||||||
tag = "-".join([
|
tag = "-".join(
|
||||||
".".join(sorted(pytags)),
|
[
|
||||||
".".join(sorted(abitags)),
|
".".join(sorted(pytags)),
|
||||||
".".join(sorted(archtags)),
|
".".join(sorted(abitags)),
|
||||||
])
|
".".join(sorted(archtags)),
|
||||||
|
]
|
||||||
|
)
|
||||||
assert set(decompress_tag(tag)) == tags
|
assert set(decompress_tag(tag)) == tags
|
||||||
return tag
|
return tag
|
||||||
|
|
|
@ -115,7 +115,11 @@ def unpack_zapp():
|
||||||
of.write(zf.read(src))
|
of.write(zf.read(src))
|
||||||
|
|
||||||
# Re-exec the current interpreter
|
# Re-exec the current interpreter
|
||||||
args = [sys.executable, "--", os.path.join(tmpdir, "usr", "__main__.py")] + sys.argv[1:]
|
args = [
|
||||||
|
sys.executable,
|
||||||
|
"--",
|
||||||
|
os.path.join(tmpdir, "usr", "__main__.py"),
|
||||||
|
] + sys.argv[1:]
|
||||||
os.execvpe(args[0], args[1:], {"PYTHONPATH": "", "ZAPP_TMPDIR": tmpdir})
|
os.execvpe(args[0], args[1:], {"PYTHONPATH": "", "ZAPP_TMPDIR": tmpdir})
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue