← Back to team overview

cloud-init team mailing list archive

Re: python3 and argparse

 

Hi,
Thanks for the suggestion. I don't think it should be necessary though.
argparse should not need to be listed in requirements as it is part of the
python3 standard library. Its even part of standard library in
python2 > 2.6.
Centos/RHEL 5 also had some strangeness around this as I recall, but it
really should not require any external packages to use argparse. We
dont *want* to require an external package for this either as it should be
functional in the stand library.

Here is some evidence to that from Ubuntu.
Here is python3 (3.2.3, the oldest i could reasonably get a hold of)

$ python3 --version
Python 3.2.3
$ python3 -c 'import argparse; print(argparse)'
$ dpkg -S /usr/lib/python3.2/argparse.py
python3.2-minimal: /usr/lib/python3.2/argparse.py

And here is python2:
$ python2 -c 'import argparse; print(argparse)'
$ python --version
Python 2.7.3
$ dpkg -S /usr/lib/python2.7/argparse.py
python2.7: /usr/lib/python2.7/argparse.py


And here is some from opensuse (42.3)
$ python3 -c 'import argparse; print(argparse)'
<module 'argparse' from '/usr/lib/python2.7/argparse.pyc'>

$ rpm -qf /usr/lib64/python3.4/argparse.py
python3-base-3.4.6-11.1.x86_64

That make sense?

On Wed, Sep 20, 2017 at 8:19 AM, Richard Brown <rbrown@xxxxxxx> wrote:

> On Wed, 2017-09-20 at 13:10 +0200, Richard Brown wrote:
>
> > We're working around the problem with the below patch, which we'd like
> to have considered for inclusion in
> > cloud-init, or a better solution proposed
>
> ahem, apologies, we probably should have done a little more testing before
> I got in touch..below is a much
> better patch that still builds on Python2, and achieves what we need for
> Python3
>
> --- requirements.txt
> +++ requirements.txt
> @@ -27,9 +27,6 @@
>  # All new style configurations are in the yaml format
>  pyyaml
>
> -# The new main entrypoint uses argparse instead of optparse
> -argparse
> -
>  # Requests handles ssl correctly!
>  requests
>
> --- setup.py
> +++ setup.py
> @@ -198,7 +198,7 @@
>
>  requirements = read_requires()
>  if sys.version_info < (3,):
> -    requirements.append('cheetah')
> +    requirements.extend(('cheetah', 'argparse'))
>
>  setuptools.setup(
>      name='cloud-init',
>
> --
> Richard Brown
> Linux Distribution Engineer - Future Technology Team
> Chairman - openSUSE
>
> Phone +4991174053-361
> SUSE Linux GmbH,  Maxfeldstr. 5,  D-90409 Nuernberg
> GF: Felix Imendörffer, Jane Smithard, Graham Norton,
> HRB 21284 (AG Nürnberg)
>
>
>
>
>
>
>
>
>
> --
> Mailing list: https://launchpad.net/~cloud-init
> Post to     : cloud-init@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~cloud-init
> More help   : https://help.launchpad.net/ListHelp
>

References