-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPythonPipRecipe
More file actions
45 lines (42 loc) · 2.06 KB
/
PythonPipRecipe
File metadata and controls
45 lines (42 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# PythonPipRecipe — recipe for pure-Python packages installed from PyPI
#
# Installs the package by running:
# python -m pip install <PYPI_NAME>==<PKGVERSION>
#
# No source tarball is required; omit the `sources:` field in the recipe header.
# The package name passed to pip is derived from PKGNAME (set by bits from the
# `package:` field). pip normalises underscores and hyphens, so both forms work.
#
# When the PyPI package name differs from the bits package name, set PYPI_NAME
# in the recipe before or after the bits-include line, e.g.:
# PYPI_NAME="python-prctl"
# . $(bits-include PythonPipRecipe)
# PYPI_NAME overrides the default (PKGNAME) only for the pip install call;
# all other bits machinery continues to use PKGNAME.
#
# Requirement: Python must be in the recipe's `requires:` list so that
# Python_ROOT is set in the environment before this file is sourced.
. ${BITS_RECIPE_TOOLS_ROOT}/PythonRecipe
# No source tarball: skip the rsync Prepare step
function Prepare() { true; }
function MakeInstall() {
mkdir -p "${SITE_PACKAGES}"
# PYPI_NAME may be set by the recipe to override the PyPI package name when
# it differs from the bits package name (e.g. PYPI_NAME="python-prctl").
local _pip_name="${PYPI_NAME:-${PKGNAME}}"
# --no-deps deps are managed by bits, not pip
# --ignore-installed don't try to uninstall system packages before installing;
# avoids "Permission denied" when a system copy exists
# --root=/ --prefix= install directly into our package tree; no staging dir
"${PYTHON_EXE}" -m pip install \
--no-deps --ignore-installed \
--root=/ --prefix="${INSTALLROOT}" \
"${_pip_name}==${PKGVERSION}"
# Verify pip actually installed something — catches silent failures where pip
# exits 0 but the package was not found or the index was unreachable.
if [ -z "$(ls -A "${SITE_PACKAGES}" 2>/dev/null)" ]; then
echo "PythonPipRecipe: pip exited 0 but ${SITE_PACKAGES} is empty" >&2
echo "PythonPipRecipe: check that ${_pip_name}==${PKGVERSION} exists on the configured index" >&2
return 1
fi
}