Commit 19eadc88 authored by Ahmed Soliman's avatar Ahmed Soliman Committed by Facebook Github Bot

Install wheel and cython on fbcode_builder venv environments

Summary:
This is an update to the fbcode_builder codebase to allow setting up the python virtualenv with python dependencies installed. I've included wheel and cython (with a pinned version to 0.28.6 which is the only version that works with thriftpy3 at the moment, due to https://github.com/cython/cython/issues/2985) as standard packages since these are required by some of our top-level dependencies (folly and thrift)

As far as I know, there are no other projects that use PYTHON_VENV at the moment except LogDevice so the impact should be minimal.

Reviewed By: lucaspmelo

Differential Revision: D18758383

fbshipit-source-id: 264941311c5e3a19dc4ef2bb78c9a1baa34dfd8c
parent 3d0c1200
...@@ -47,10 +47,12 @@ class DockerFBCodeBuilder(FBCodeBuilder): ...@@ -47,10 +47,12 @@ class DockerFBCodeBuilder(FBCodeBuilder):
ShellQuoted('FROM {}'.format(self.option('os_image'))), ShellQuoted('FROM {}'.format(self.option('os_image'))),
# /bin/sh syntax is a pain # /bin/sh syntax is a pain
ShellQuoted('SHELL ["/bin/bash", "-c"]'), ShellQuoted('SHELL ["/bin/bash", "-c"]'),
] + self.install_debian_deps() + [self._change_user()] ]
+ [self.workdir(self.option('prefix')), + self.install_debian_deps() + [self._change_user()]
self.create_python_venv(), + [self.workdir(self.option('prefix'))]
self.python_venv()]) + self.create_python_venv()
+ self.python_venv()
)
def python_venv(self): def python_venv(self):
# To both avoid calling venv activate on each RUN command AND to ensure # To both avoid calling venv activate on each RUN command AND to ensure
......
...@@ -183,6 +183,12 @@ class FBCodeBuilder(object): ...@@ -183,6 +183,12 @@ class FBCodeBuilder(object):
''' '''
raise NotImplementedError raise NotImplementedError
def python_deps(self):
return [
'wheel',
'cython==0.28.6',
]
def debian_deps(self): def debian_deps(self):
return [ return [
'autoconf-archive', 'autoconf-archive',
...@@ -252,18 +258,23 @@ class FBCodeBuilder(object): ...@@ -252,18 +258,23 @@ class FBCodeBuilder(object):
return self.step('Install packages for Debian-based OS', actions) return self.step('Install packages for Debian-based OS', actions)
def create_python_venv(self): def create_python_venv(self):
action = [] actions = []
if self.option("PYTHON_VENV", "OFF") == "ON": if self.option("PYTHON_VENV", "OFF") == "ON":
action = self.run(ShellQuoted("python3 -m venv {p}").format( actions.append(self.run(ShellQuoted("python3 -m venv {p}").format(
p=path_join(self.option('prefix'), "venv"))) p=path_join(self.option('prefix'), "venv"))))
return(action) return(actions)
def python_venv(self): def python_venv(self):
action = [] actions = []
if self.option("PYTHON_VENV", "OFF") == "ON": if self.option("PYTHON_VENV", "OFF") == "ON":
action = ShellQuoted("source {p}").format( actions.append(ShellQuoted("source {p}").format(
p=path_join(self.option('prefix'), "venv", "bin", "activate")) p=path_join(self.option('prefix'), "venv", "bin", "activate")))
return(action)
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): def debian_ccache_setup_steps(self):
return [] # It's ok to ship a renderer without ccache support. return [] # It's ok to ship a renderer without ccache support.
......
#!/usr/bin/env python #!/usr/bin/env )python
# Copyright (c) Facebook, Inc. and its affiliates. # Copyright (c) Facebook, Inc. and its affiliates.
from __future__ import absolute_import from __future__ import absolute_import
from __future__ import division from __future__ import division
...@@ -51,7 +51,7 @@ class ShellFBCodeBuilder(FBCodeBuilder): ...@@ -51,7 +51,7 @@ class ShellFBCodeBuilder(FBCodeBuilder):
def setup(self): def setup(self):
steps = [ steps = [
ShellQuoted('set -exo pipefail'), ShellQuoted('set -exo pipefail'),
] + [self.create_python_venv(), self.python_venv()] ] + self.create_python_venv() + self.python_venv()
if self.has_option('ccache_dir'): if self.has_option('ccache_dir'):
ccache_dir = self.option('ccache_dir') ccache_dir = self.option('ccache_dir')
steps += [ steps += [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment