diff --git a/build/fbcode_builder/docker_builder.py b/build/fbcode_builder/docker_builder.py index aa251f8a4..5f5de5587 100644 --- a/build/fbcode_builder/docker_builder.py +++ b/build/fbcode_builder/docker_builder.py @@ -47,10 +47,12 @@ class DockerFBCodeBuilder(FBCodeBuilder): ShellQuoted('FROM {}'.format(self.option('os_image'))), # /bin/sh syntax is a pain ShellQuoted('SHELL ["/bin/bash", "-c"]'), - ] + self.install_debian_deps() + [self._change_user()] - + [self.workdir(self.option('prefix')), - self.create_python_venv(), - self.python_venv()]) + ] + + self.install_debian_deps() + [self._change_user()] + + [self.workdir(self.option('prefix'))] + + self.create_python_venv() + + self.python_venv() + ) def python_venv(self): # To both avoid calling venv activate on each RUN command AND to ensure diff --git a/build/fbcode_builder/fbcode_builder.py b/build/fbcode_builder/fbcode_builder.py index c9aa5adf2..f57980f36 100644 --- a/build/fbcode_builder/fbcode_builder.py +++ b/build/fbcode_builder/fbcode_builder.py @@ -183,6 +183,12 @@ class FBCodeBuilder(object): ''' raise NotImplementedError + def python_deps(self): + return [ + 'wheel', + 'cython==0.28.6', + ] + def debian_deps(self): return [ 'autoconf-archive', @@ -252,18 +258,23 @@ class FBCodeBuilder(object): return self.step('Install packages for Debian-based OS', actions) def create_python_venv(self): - action = [] + actions = [] if self.option("PYTHON_VENV", "OFF") == "ON": - action = self.run(ShellQuoted("python3 -m venv {p}").format( - p=path_join(self.option('prefix'), "venv"))) - return(action) + actions.append(self.run(ShellQuoted("python3 -m venv {p}").format( + p=path_join(self.option('prefix'), "venv")))) + return(actions) def python_venv(self): - action = [] + actions = [] if self.option("PYTHON_VENV", "OFF") == "ON": - action = ShellQuoted("source {p}").format( - p=path_join(self.option('prefix'), "venv", "bin", "activate")) - return(action) + actions.append(ShellQuoted("source {p}").format( + p=path_join(self.option('prefix'), "venv", "bin", "activate"))) + + actions.append(self.run( + ShellQuoted("python3 -m pip install {deps}").format( + deps=shell_join(' ', (ShellQuoted(dep) for dep in + self.python_deps()))))) + return(actions) def debian_ccache_setup_steps(self): return [] # It's ok to ship a renderer without ccache support. diff --git a/build/fbcode_builder/shell_builder.py b/build/fbcode_builder/shell_builder.py index 5bb41fe57..eb3cccd79 100644 --- a/build/fbcode_builder/shell_builder.py +++ b/build/fbcode_builder/shell_builder.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env )python # Copyright (c) Facebook, Inc. and its affiliates. from __future__ import absolute_import from __future__ import division @@ -51,7 +51,7 @@ class ShellFBCodeBuilder(FBCodeBuilder): def setup(self): steps = [ ShellQuoted('set -exo pipefail'), - ] + [self.create_python_venv(), self.python_venv()] + ] + self.create_python_venv() + self.python_venv() if self.has_option('ccache_dir'): ccache_dir = self.option('ccache_dir') steps += [