Skip to content

Commit

Permalink
Improve sonnet script
Browse files Browse the repository at this point in the history
  • Loading branch information
sdispater committed Apr 11, 2019
1 parent e57e4ac commit c32ef78
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions sonnet
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class MakeReleaseCommand(Command):
else:
vcs_excluded = []

created_files = []
with temporary_directory() as tmp_dir:
# Copy poetry to tmp dir
poetry_dir = os.path.join(tmp_dir, "poetry")
Expand All @@ -78,6 +79,13 @@ class MakeReleaseCommand(Command):
set([os.path.join(dir_, name) for name in names])
),
)
created_files += [
p.relative_to(Path(tmp_dir))
for p in Path(poetry_dir).glob("**/*")
if p.is_file()
and p.suffix != ".pyc"
and str(p.relative_to(Path(tmp_dir))) not in vcs_excluded
]
for version, python in sorted(pythons.items()):
self.line(
"<info>Preparing files for Python <comment>{}</comment></info>".format(
Expand All @@ -93,6 +101,16 @@ class MakeReleaseCommand(Command):
self.vendorize_for_python(
python, [op.package for op in ops], poetry_dir, version
)
vendor_dir = Path(
os.path.join(poetry_dir, "_vendor", "py{}".format(python))
)
created_files += [
p.relative_to(Path(tmp_dir))
for p in vendor_dir.glob("**/*")
if p.is_file()
and p.suffix != ".pyc"
and str(p.relative_to(Path(tmp_dir))) not in vcs_excluded
]

self.line("")

Expand Down Expand Up @@ -132,6 +150,22 @@ class MakeReleaseCommand(Command):
finally:
gz.close()

self.line("<info>Checking release file</info>")
missing_files = []
with tarfile.open(os.path.join(tmp_dir2, name), "r") as tar:
names = tar.getnames()

for created_file in created_files:
if created_file.as_posix() not in names:
missing_files.append(created_file.as_posix())

if missing_files:
self.line("<error>Some files are missing:</error>")
for missing_file in missing_files:
self.line("<error> - {}</error>".format(missing_file))

return 1

releases_dir = os.path.join(os.path.dirname(__file__), "releases")
if not os.path.exists(releases_dir):
os.mkdir(releases_dir)
Expand Down

0 comments on commit c32ef78

Please sign in to comment.