[python-bugzilla] [PATCH] Handle requirements in setup.py

Cole Robinson crobinso at redhat.com
Tue Sep 16 10:34:01 UTC 2014


On 09/15/2014 06:17 PM, abn at redhat.com wrote:
> From: Arun Babu Neelicattu <abn at redhat.com>
> 
> ---
>  setup.py | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 

Applying the patch, then running the test suite, I get this:

$ python setup.py test
/usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution
option: 'install_requires'
  warnings.warn(msg)
/usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution
option: 'tests_require'
  warnings.warn(msg)
running test

> diff --git a/setup.py b/setup.py
> index c548fb5..be0ba59 100755
> --- a/setup.py
> +++ b/setup.py
> @@ -166,6 +166,25 @@ class RPMCommand(Command):
>              os.system("mv /tmp/python-bugzilla.spec .")
>  
>  
> +requirements = {}
> +
> +try:
> +    from pip.req import parse_requirements
> +
> +    requirement_files = {
> +        'install_requires': 'requirements.txt',
> +        'tests_require': 'test-requirements.txt',
> +    }
> +
> +    for name, fname in requirement_files.items():
> +        requirements[name] = [
> +            str(ir.req) for ir in parse_requirements(fname)
> +        ]
> +except ImportError:
> +    # ignore as this is not useful without pip anyway
> +    pass
> +
> +
>  setup(name='python-bugzilla',
>        version=get_version(),
>        description='Bugzilla XMLRPC access module',
> @@ -181,5 +200,6 @@ setup(name='python-bugzilla',
>          "pylint" : PylintCommand,
>          "rpm" : RPMCommand,
>          "test" : TestCommand,
> -      }
> +      },
> +      **requirements
>  )
> 



More information about the python-bugzilla mailing list