diff --git a/charmtools/build/builder.py b/charmtools/build/builder.py index ae18bff..5aab948 100755 --- a/charmtools/build/builder.py +++ b/charmtools/build/builder.py @@ -1163,6 +1163,18 @@ def main(args=None): help="Force raw output (color)") parser.add_argument('--charm-file', '-F', action='store_true', help='Create a .charm file in the current directory') + parser.add_argument('--binary-wheels', action='store_true', + help='Populate the charm wheelhouse with binary ' + 'wheels that matches the Python version and ' + 'architecture the charm is built on. Note that ' + 'to use this option you must ensure that you ' + 'have a series/architecture aware build and ' + 'distribution infrastructure configured for ' + 'your charm (such as Launchpad and Charmhub).') + parser.add_argument('--binary-wheels-from-source', action='store_true', + help='Same as --binary-wheels but build all the ' + 'wheels from source code, even if a binary ' + 'distribution is available on PyPi.') parser.add_argument('charm', nargs="?", default=".", type=path, help='Source directory for charm layer to build ' '(default: .)') @@ -1181,6 +1193,8 @@ def main(args=None): LayerFetcher.NO_LOCAL_LAYERS = build.no_local_layers WheelhouseTactic.per_layer = build.wheelhouse_per_layer + WheelhouseTactic.binary_build = build.binary_wheels + WheelhouseTactic.binary_build_from_source = build.binary_wheels_from_source configLogging(build) diff --git a/charmtools/build/tactics.py b/charmtools/build/tactics.py index 72b4b46..b316cd7 100644 --- a/charmtools/build/tactics.py +++ b/charmtools/build/tactics.py @@ -1044,6 +1044,8 @@ class WheelhouseTactic(ExactMatch, Tactic): FILENAME = 'wheelhouse.txt' removed = [] # has to be class level to affect all tactics during signing per_layer = False + binary_build = False + binary_build_from_source = False def __init__(self, *args, **kwargs): super(WheelhouseTactic, self).__init__(*args, **kwargs) @@ -1110,8 +1112,14 @@ def read(self): def _add(self, wheelhouse, *reqs): with utils.tempdir(chdir=False) as temp_dir: # put in a temp dir first to ensure we track all of the files - self._pip('download', '--no-binary', ':all:', '-d', temp_dir, - *reqs) + _no_binary_opts = ('--no-binary', ':all:') + if self.binary_build_from_source or self.binary_build: + self._pip('wheel', + *_no_binary_opts + if self.binary_build_from_source else tuple(), + '-w', temp_dir, *reqs) + else: + self._pip('download', *_no_binary_opts, '-d', temp_dir, *reqs) log.debug('Copying wheels:') for wheel in temp_dir.files(): log.debug(' ' + wheel.name)