Browse code

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

Brant Knudson authored on 2015/08/04 03:31:25
Showing 1 changed files
... ...
@@ -239,15 +239,31 @@ function setup_dev_lib {
239 239
 
240 240
 # this should be used if you want to install globally, all libraries should
241 241
 # 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>]"
242 249
 function setup_install {
243 250
     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
245 253
 }
246 254
 
247 255
 # 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>]"
248 263
 function setup_develop {
249 264
     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
251 267
 }
252 268
 
253 269
 # determine if a project as specified by directory is in
... ...
@@ -269,10 +285,17 @@ function is_in_projects_txt {
269 269
 # install this package we get the from source version.
270 270
 #
271 271
 # Uses globals ``REQUIREMENTS_DIR``
272
-# setup_develop directory
273
-function setup_package_with_constraints_edit {
272
+# _setup_package_with_constraints_edit project_dir flags [extras]
273
+# project_dir: directory of project repo (e.g., /opt/stack/keystone)
274
+# flags: pip CLI options/flags
275
+# extras: comma-separated list of optional dependencies to install
276
+#         (e.g., ldap,memcache).
277
+#         See http://docs.openstack.org/developer/pbr/#extra-requirements
278
+# The command is like "pip install <flags> <project_dir>[<extras>]"
279
+function _setup_package_with_constraints_edit {
274 280
     local project_dir=$1
275 281
     local flags=$2
282
+    local extras=$3
276 283
 
277 284
     if [ -n "$REQUIREMENTS_DIR" ]; then
278 285
         # Constrain this package to this project directory from here on out.
... ...
@@ -283,19 +306,38 @@ function setup_package_with_constraints_edit {
283 283
             "$flags file://$project_dir#egg=$name"
284 284
     fi
285 285
 
286
-    setup_package $project_dir $flags
286
+    setup_package $project_dir "$flags" $extras
287 287
 
288 288
 }
289 289
 
290 290
 # ``pip install -e`` the package, which processes the dependencies
291 291
 # using pip before running `setup.py develop`
292
+#
292 293
 # Uses globals ``STACK_USER``
293
-# setup_develop_no_requirements_update directory
294
+# setup_package project_dir [flags] [extras]
295
+# project_dir: directory of project repo (e.g., /opt/stack/keystone)
296
+# flags: pip CLI options/flags
297
+# extras: comma-separated list of optional dependencies to install
298
+#         (e.g., ldap,memcache).
299
+#         See http://docs.openstack.org/developer/pbr/#extra-requirements
300
+# The command is like "pip install <flags> <project_dir>[<extras>]"
294 301
 function setup_package {
295 302
     local project_dir=$1
296 303
     local flags=$2
304
+    local extras=$3
305
+
306
+    # if the flags variable exists, and it doesn't look like a flag,
307
+    # assume it's actually the extras list.
308
+    if [[ -n "$flags" && -z "$extras" && ! "$flags" =~ ^-.* ]]; then
309
+        extras=$flags
310
+        flags=""
311
+    fi
312
+
313
+    if [[ ! -z "$extras" ]]; then
314
+        extras="[$extras]"
315
+    fi
297 316
 
298
-    pip_install $flags $project_dir
317
+    pip_install $flags "$project_dir$extras"
299 318
     # ensure that further actions can do things like setup.py sdist
300 319
     if [[ "$flags" == "-e" ]]; then
301 320
         safe_chown -R $STACK_USER $1/*.egg-info