Skip to content

Commit

Permalink
Clear any prior vendorings when (re)vendoring.
Browse files Browse the repository at this point in the history
This allows for re-vendored distributions losing files as well as changing
the set of vendored distributions altogether.

Fixes pex-tool#1096
  • Loading branch information
jsirois committed Nov 7, 2020
1 parent ef99275 commit e307a79
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion pex/vendor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ class VendorSpec(

ROOT = _root()

_VENDOR_DIR = "_vendored"

@classmethod
def vendor_root(cls):
return os.path.join(cls.ROOT, *(_PACKAGE_COMPONENTS + [cls._VENDOR_DIR]))

@classmethod
def pinned(cls, key, version, rewrite=True):
return cls(
Expand All @@ -61,7 +67,7 @@ def vcs(cls, url, rewrite=True):

@property
def _subpath_components(self):
return ["_vendored", self.key]
return [self._VENDOR_DIR, self.key]

@property
def relpath(self):
Expand Down
5 changes: 3 additions & 2 deletions pex/vendor/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from pex import third_party
from pex.common import safe_delete, safe_rmtree
from pex.vendor import iter_vendor_specs
from pex.vendor import VendorSpec, iter_vendor_specs


class ImportRewriter(object):
Expand Down Expand Up @@ -285,9 +285,10 @@ def vendorize(root_dir, vendor_specs, prefix):
print("Usage: {}".format(sys.argv[0]), file=sys.stderr)
sys.exit(1)

root_directory = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
root_directory = VendorSpec.ROOT
import_prefix = third_party.import_prefix()
try:
safe_rmtree(VendorSpec.vendor_root())
vendorize(root_directory, list(iter_vendor_specs()), import_prefix)
sys.exit(0)
except VendorizeError as e:
Expand Down

0 comments on commit e307a79

Please sign in to comment.