Skip to content

Commit

Permalink
sonnet: support split vendoring
Browse files Browse the repository at this point in the history
  • Loading branch information
abn committed Feb 10, 2022
1 parent a22937a commit 9d420d0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ linux_release:
docker pull quay.io/pypa/manylinux2010_x86_64:2021-02-06-3d322a5
docker pull quay.io/pypa/manylinux2010_x86_64:2022-02-05-4cb577c
docker run --rm -i -v `pwd`:/io \
-e VENDOR_ONLY=1 \
-e PYTHON=/opt/python/cp38-cp38/bin/python \
-e PYTHON27=/opt/python/cp27-cp27m/bin/python \
-e PYTHON35=/opt/python/cp35-cp35m/bin/python \
quay.io/pypa/manylinux2010_x86_64:2021-02-06-3d322a5 sh -c "cd /io && ./make-nix-release.sh"
docker run --rm -i -v `pwd`:/io \
-e VENDOR_REUSE=1 \
-e PYTHON=/opt/python/cp38-cp38/bin/python \
-e PYTHON36=/opt/python/cp36-cp36m/bin/python \
-e PYTHON37=/opt/python/cp37-cp37m/bin/python \
Expand Down
26 changes: 24 additions & 2 deletions sonnet
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ from clikit.api.formatter import Style


WINDOWS = sys.platform.startswith("win") or (sys.platform == "cli" and os.name == "nt")
VENDOR_ONLY = "VENDOR_ONLY" in os.environ
VENDOR_REUSE = "VENDOR_REUSE" in os.environ


class MakeReleaseCommand(Command):
Expand Down Expand Up @@ -69,17 +71,27 @@ class MakeReleaseCommand(Command):
pool.add_repository(project.locker.locked_repository(with_dev_reqs=True))

vcs = get_vcs(Path(__file__).parent)
poetry_vendor_relative = os.path.join("poetry", "_vendor")

if vcs:
vcs_excluded = [str(f) for f in vcs.get_ignored_files()]
# if vendor reuse is enabled do not exclude these files
vcs_excluded = [
str(f)
for f in vcs.get_ignored_files()
if not (VENDOR_REUSE and str(f).startswith(poetry_vendor_relative))
]
else:
vcs_excluded = []

created_files = []
poetry_dir_src = os.path.join(os.path.dirname(__file__), "poetry")
poetry_vendor_src = os.path.join(poetry_dir_src, "_vendor")

with temporary_directory() as tmp_dir:
# Copy poetry to tmp dir
poetry_dir = os.path.join(tmp_dir, "poetry")
shutil.copytree(
os.path.join(os.path.dirname(__file__), "poetry"),
poetry_dir_src,
poetry_dir,
ignore=lambda dir_, names: set(vcs_excluded).intersection(
set([os.path.join(dir_, name) for name in names])
Expand Down Expand Up @@ -129,6 +141,16 @@ class MakeReleaseCommand(Command):

self.line("")

if VENDOR_ONLY:
self.line("<info>Preserving generated vendor directory</info>")
shutil.copytree(
os.path.join(poetry_dir, "_vendor"),
poetry_vendor_src,
dirs_exist_ok=True,
)
self.line("<info>Skipping packaging</info>")
return

self.line("<info>Packaging files</info>")
with temporary_directory() as tmp_dir2:
base_name = "poetry-{}-{}".format(__version__, sys.platform)
Expand Down

0 comments on commit 9d420d0

Please sign in to comment.