Sounds good idea.

On Fri, Nov 30, 2012 at 02:37:08PM +0900, FUJITA Tomonori wrote:
> Let's enable pip to solve the dependency.
> 
> The code is taken from OpenStack.

We'd also like to add such comment in the code. Otherwise the reader
would be confused with 'nova'. Otherwise looks good.

thanks,

> 
> Signed-off-by: FUJITA Tomonori <[email protected]>
> ---
>  ryu/utils.py |   39 +++++++++++++++++++++++++++++++++++++++
>  setup.py     |    4 ++++
>  2 files changed, 43 insertions(+), 0 deletions(-)
> 
> diff --git a/ryu/utils.py b/ryu/utils.py
> index f2da670..df36db4 100644
> --- a/ryu/utils.py
> +++ b/ryu/utils.py
> @@ -19,6 +19,7 @@ import inspect
>  import logging
>  import os
>  import sys
> +import re
>  
>  LOG = logging.getLogger('ryu.utils')
>  
> @@ -69,3 +70,41 @@ def round_up(x, y):
>  
>  def hex_array(data):
>      return ' '.join(hex(ord(chr)) for chr in data)
> +
> +
> +# Get requirements from the first file that exists
> +def get_reqs_from_files(requirements_files):
> +    for requirements_file in requirements_files:
> +        if os.path.exists(requirements_file):
> +            with open(requirements_file, 'r') as fil:
> +                return fil.read().split('\n')
> +    return []
> +
> +
> +def parse_requirements(requirements_files=['requirements.txt',
> +                                           'tools/pip-requires']):
> +    requirements = []
> +    for line in get_reqs_from_files(requirements_files):
> +        # For the requirements list, we need to inject only the portion
> +        # after egg= so that distutils knows the package it's looking for
> +        # such as:
> +        # -e git://github.com/openstack/nova/master#egg=nova
> +        if re.match(r'\s*-e\s+', line):
> +            requirements.append(re.sub(r'\s*-e\s+.*#egg=(.*)$', r'\1',
> +                                line))
> +        # such as:
> +        # http://github.com/openstack/nova/zipball/master#egg=nova
> +        elif re.match(r'\s*https?:', line):
> +            requirements.append(re.sub(r'\s*https?:.*#egg=(.*)$', r'\1',
> +                                line))
> +        # -f lines are for index locations, and don't get used here
> +        elif re.match(r'\s*-f\s+', line):
> +            pass
> +        # argparse is part of the standard library starting with 2.7
> +        # adding it to the requirements list screws distro installs
> +        elif line == 'argparse' and sys.version_info >= (2, 7):
> +            pass
> +        else:
> +            requirements.append(line)
> +
> +    return requirements
> diff --git a/setup.py b/setup.py
> index 4b12fc3..f1915a7 100644
> --- a/setup.py
> +++ b/setup.py
> @@ -21,6 +21,9 @@ from setuptools import find_packages
>  from setuptools import setup
>  
>  from ryu import version
> +from ryu import utils
> +
> +requires = utils.parse_requirements()
>  
>  doing_bdist = any(arg.startswith('bdist') for arg in sys.argv[1:])
>  
> @@ -53,6 +56,7 @@ setup(name='ryu',
>        url='http://osrg.github.com/ryu/',
>        author='Ryu project team',
>        author_email='[email protected]',
> +      install_requires=requires,
>        license='Apache License 2.0',
>        packages=find_packages(),
>        scripts=['bin/ryu-manager',
> -- 
> 1.7.2.5
> 
> 
> ------------------------------------------------------------------------------
> Keep yourself connected to Go Parallel: 
> TUNE You got it built. Now make it sing. Tune shows you how.
> http://goparallel.sourceforge.net
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 

-- 
yamahata

------------------------------------------------------------------------------
Keep yourself connected to Go Parallel: 
TUNE You got it built. Now make it sing. Tune shows you how.
http://goparallel.sourceforge.net
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to