Move element-info to a standard entry-point

Move element-info from a wrapper script to a standard entry-point
console_script.

Update the documentation to explain how to run it for development.  I
don't think we should support the idea that you can check-out the code
and run ./bin/disk-image-create -- it has dependencies (dib-utils,
etc) and needs to be run from a virtualenv (this is what CI in the
gate does).  A follow-up can clean-up some of the path munging stuff
we have for this in disk-image-create.

Change-Id: Ic0c03995667f320a27ac30441279f3e6abb6bca8
This commit is contained in:
Ian Wienand 2016-06-17 15:45:20 +10:00
parent 3d48a528c1
commit 91b431ce78
7 changed files with 27 additions and 26 deletions

View File

@ -1,5 +1,4 @@
include bin/disk-image-create
include bin/element-info
include bin/ramdisk-image-create
graft lib
graft elements

View File

@ -1,21 +0,0 @@
#!/usr/bin/env python
# Copyright 2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import sys
from diskimage_builder.element_dependencies import main
sys.exit(main(sys.argv))

View File

@ -179,7 +179,7 @@ def find_all_elements(paths=None):
return all_elements
def main(argv):
def main():
diskimage_builder.logging_config.setup()
parser = argparse.ArgumentParser()
@ -194,7 +194,7 @@ def main(argv):
help=('Output eval-able bash strings for '
'IMAGE_ELEMENT variables'))
args = parser.parse_args(argv[1:])
args = parser.parse_args(sys.argv[1:])
all_elements = find_all_elements()
@ -232,3 +232,6 @@ def main(argv):
print(' '.join(elements))
return 0
if __name__ == "__main__":
main()

View File

@ -1,3 +1,13 @@
Installation
============
For general use, you can use distribution packages or install via
``pip`` in a ``virtualenv``
For development purposes, you can use ``pip -e`` to install into a
local development/testing ``virtualenv``, or use ``tox -e venv --
disk-image-create`` to run within a ``tox`` created environment.
Invocation
==========

View File

@ -194,6 +194,7 @@ function arg_to_elements() {
IMAGE_ELEMENT="$RAMDISK_ELEMENT $IMAGE_ELEMENT"
fi
echo "Building elements: $IMAGE_ELEMENT"
export IMAGE_ELEMENT
# element-info will output bash code to create
# * IMAGE_ELEMENT
@ -217,7 +218,7 @@ function arg_to_elements() {
# element=$i
# path=${image_elements[$i]
# done
eval "$($SCRIPT_HOME/element-info --env $IMAGE_ELEMENT)"
eval "$(element-info --env $IMAGE_ELEMENT)"
echo "Expanded element dependencies to: $IMAGE_ELEMENT"
}

View File

@ -0,0 +1,9 @@
---
deprecations:
- The ``element-info`` script is now provided by a standard python
entry-point, rather than an explicit wrapper script. This may
affect you if you were running this script directly out of ``bin``
in the source directory without installing. See developer notes
for details on using developer-installs with virtual environments
for testing.

View File

@ -28,7 +28,6 @@ packages =
scripts =
bin/dib-lint
bin/disk-image-create
bin/element-info
bin/ramdisk-image-create
data_files =
share/diskimage-builder/elements = elements/*
@ -57,4 +56,5 @@ universal = 1
[entry_points]
console_scripts =
element-info = diskimage_builder.element_dependencies:main
dib-block-device = diskimage_builder.block_device:main