Skip to content

Commit 0842b81

Browse files
Brant Knudsonsdague
authored andcommitted
Support extra dependencies when setup_develop
Recent pip supports using [extras] to install extra dependencies from the project setup.cfg. Add support so that projects can take advantage of it. For example, if devstack is configured to use ldap, install the extra ldap dependencies using: setup_develop $KEYSTONE_DIR ldap Partial-Bug: 1479962 Change-Id: Ic13d95b99aaa4d3854b2723343e90f5de6b98aa2
1 parent e60d52c commit 0842b81

File tree

1 file changed

+49
-7
lines changed

1 file changed

+49
-7
lines changed

inc/python

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,31 @@ function setup_dev_lib {
239239

240240
# this should be used if you want to install globally, all libraries should
241241
# use this, especially *oslo* ones
242+
#
243+
# setup_install project_dir [extras]
244+
# project_dir: directory of project repo (e.g., /opt/stack/keystone)
245+
# extras: comma-separated list of optional dependencies to install
246+
# (e.g., ldap,memcache).
247+
# See http://docs.openstack.org/developer/pbr/#extra-requirements
248+
# The command is like "pip install <project_dir>[<extras>]"
242249
function setup_install {
243250
local project_dir=$1
244-
setup_package_with_constraints_edit $project_dir
251+
local extras=$2
252+
_setup_package_with_constraints_edit $project_dir "" $extras
245253
}
246254

247255
# this should be used for projects which run services, like all services
256+
#
257+
# setup_develop project_dir [extras]
258+
# project_dir: directory of project repo (e.g., /opt/stack/keystone)
259+
# extras: comma-separated list of optional dependencies to install
260+
# (e.g., ldap,memcache).
261+
# See http://docs.openstack.org/developer/pbr/#extra-requirements
262+
# The command is like "pip install -e <project_dir>[<extras>]"
248263
function setup_develop {
249264
local project_dir=$1
250-
setup_package_with_constraints_edit $project_dir -e
265+
local extras=$2
266+
_setup_package_with_constraints_edit $project_dir -e $extras
251267
}
252268

253269
# determine if a project as specified by directory is in
@@ -269,10 +285,17 @@ function is_in_projects_txt {
269285
# install this package we get the from source version.
270286
#
271287
# Uses globals ``REQUIREMENTS_DIR``
272-
# setup_develop directory
273-
function setup_package_with_constraints_edit {
288+
# _setup_package_with_constraints_edit project_dir flags [extras]
289+
# project_dir: directory of project repo (e.g., /opt/stack/keystone)
290+
# flags: pip CLI options/flags
291+
# extras: comma-separated list of optional dependencies to install
292+
# (e.g., ldap,memcache).
293+
# See http://docs.openstack.org/developer/pbr/#extra-requirements
294+
# The command is like "pip install <flags> <project_dir>[<extras>]"
295+
function _setup_package_with_constraints_edit {
274296
local project_dir=$1
275297
local flags=$2
298+
local extras=$3
276299

277300
if [ -n "$REQUIREMENTS_DIR" ]; then
278301
# Constrain this package to this project directory from here on out.
@@ -283,19 +306,38 @@ function setup_package_with_constraints_edit {
283306
"$flags file://$project_dir#egg=$name"
284307
fi
285308

286-
setup_package $project_dir $flags
309+
setup_package $project_dir "$flags" $extras
287310

288311
}
289312

290313
# ``pip install -e`` the package, which processes the dependencies
291314
# using pip before running `setup.py develop`
315+
#
292316
# Uses globals ``STACK_USER``
293-
# setup_develop_no_requirements_update directory
317+
# setup_package project_dir [flags] [extras]
318+
# project_dir: directory of project repo (e.g., /opt/stack/keystone)
319+
# flags: pip CLI options/flags
320+
# extras: comma-separated list of optional dependencies to install
321+
# (e.g., ldap,memcache).
322+
# See http://docs.openstack.org/developer/pbr/#extra-requirements
323+
# The command is like "pip install <flags> <project_dir>[<extras>]"
294324
function setup_package {
295325
local project_dir=$1
296326
local flags=$2
327+
local extras=$3
328+
329+
# if the flags variable exists, and it doesn't look like a flag,
330+
# assume it's actually the extras list.
331+
if [[ -n "$flags" && -z "$extras" && ! "$flags" =~ ^-.* ]]; then
332+
extras=$flags
333+
flags=""
334+
fi
335+
336+
if [[ ! -z "$extras" ]]; then
337+
extras="[$extras]"
338+
fi
297339

298-
pip_install $flags $project_dir
340+
pip_install $flags "$project_dir$extras"
299341
# ensure that further actions can do things like setup.py sdist
300342
if [[ "$flags" == "-e" ]]; then
301343
safe_chown -R $STACK_USER $1/*.egg-info

0 commit comments

Comments
 (0)