MCPcopy Create free account
hub / github.com/apache/impala / exec_pip_install

Function exec_pip_install

infra/python/bootstrap_virtualenv.py:139–193  ·  view source on GitHub ↗

Executes "pip install" with the provided command line arguments. If 'cc' is set, it is used as the C compiler. Otherwise compilation of C/C++ code is disabled by setting the CC environment variable to a bogus value. Other environment vars can optionally be set with the 'env' argument. By defau

(venv_dir, args, cc="no-cc-available", env=None)

Source from the content-addressed store, hash-verified

137
138
139def exec_pip_install(venv_dir, args, cc="no-cc-available", env=None):
140 '''Executes "pip install" with the provided command line arguments. If 'cc' is set,
141 it is used as the C compiler. Otherwise compilation of C/C++ code is disabled by
142 setting the CC environment variable to a bogus value.
143 Other environment vars can optionally be set with the 'env' argument. By default the
144 current process's command line arguments are inherited.'''
145 if not env: env = dict(os.environ)
146 env["CC"] = cc
147 # Since gcc is now built with toolchain binutils which may be newer than the
148 # system binutils, we need to include the toolchain binutils on the PATH.
149 toolchain_binutils_dir = toolchain_pkg_dir("binutils")
150 binutils_bin_dir = os.path.join(toolchain_binutils_dir, "bin")
151 env["PATH"] = "{0}:{1}".format(binutils_bin_dir, env["PATH"])
152 # Sometimes pip install invokes gcc directly without using the CC environment
153 # variable. If system GCC is too new, then it will fail, because it needs symbols
154 # that are not in Impala's libstdc++. To avoid this, we add GCC to the PATH,
155 # so any direct reference will use our GCC rather than the system GCC.
156 toolchain_gcc_dir = toolchain_pkg_dir("gcc")
157 gcc_bin_dir = os.path.join(toolchain_gcc_dir, "bin")
158 env["PATH"] = "{0}:{1}".format(gcc_bin_dir, env["PATH"])
159
160 # Parallelize the slow numpy build.
161 # Use getconf instead of nproc because it is supported more widely, e.g. on older
162 # linux distributions.
163 env["NPY_NUM_BUILD_JOBS"] = exec_cmd(["getconf", "_NPROCESSORS_ONLN"]).strip()
164
165 # Don't call the virtualenv pip directly, it uses a hashbang to to call the python
166 # virtualenv using an absolute path. If the path to the virtualenv is very long, the
167 # hashbang won't work.
168 impala_pip_base_cmd = [os.path.join(venv_dir, "bin", "python3"),
169 os.path.join(venv_dir, "bin", "pip3"), "install", "-v"]
170
171 # Passes --no-binary for IMPALA-3767: without this, Cython (and
172 # several other packages) fail download.
173 #
174 # --no-cache-dir is used to prevent caching of compiled artifacts, which may be built
175 # with different compilers or settings.
176 third_party_pkg_install_cmd = \
177 impala_pip_base_cmd[:] + ["--no-binary", ":all:", "--no-cache-dir"]
178
179 # Prevent fetching additional packages from the index. If we forget to add a package
180 # to one of the requirements.txt files, this should trigger an error. However, we will
181 # still access the index for version/dependency resolution, hence we need to change it
182 # when using a private mirror.
183 third_party_pkg_install_cmd.append("--no-index")
184
185 third_party_pkg_install_cmd.extend(["--find-links",
186 "file://%s" % pathname2url(os.path.abspath(DEPS_DIR))])
187 third_party_pkg_install_cmd.extend(args)
188 exec_cmd(third_party_pkg_install_cmd, env=env)
189
190 # Finally, we want to install the packages from our own internal python lib
191 local_package_install_cmd = impala_pip_base_cmd + \
192 ['-e', os.path.join(os.getenv('IMPALA_HOME'), 'lib', 'python')]
193 exec_cmd(local_package_install_cmd)
194
195
196def find_file(*paths):

Callers 4

install_depsFunction · 0.85
install_adls_depsFunction · 0.85
install_gcovr_depsFunction · 0.85

Calls 5

toolchain_pkg_dirFunction · 0.85
exec_cmdFunction · 0.70
joinMethod · 0.45
formatMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected