[initial-setup][master/f23-branch][PATCH] Switch Initial Setup to Python 3 (#1244558)

Samantha N. Bueno sbueno+anaconda at redhat.com
Wed Jul 29 18:47:32 UTC 2015


On Wed, Jul 29, 2015 at 05:36:01PM +0200, Martin Kolman wrote:
> Make Initial Setup use Python 3 by changing the startup script,
> dependencies and by changing a single piece of Python 3 incompatible code.
> 
> Also remove usage of the python-di module - it has not yet been ported
> to Python 3 and is not really needed. It has been apparently added for
> use by tests, but there are no tests. It can of course be added back
> once it is ported to Python 3 and once there are some tests that use it.

Looks good to me.

> 
> Signed-off-by: Martin Kolman <mkolman at redhat.com>
> ---
>  Makefile                                    |  6 +-----
>  initial-setup                               |  2 +-
>  initial-setup.spec                          | 18 ++++++++----------
>  initial_setup/gui/gui.py                    |  3 ---
>  initial_setup/gui/hubs/initial_setup_hub.py |  2 +-
>  initial_setup/tui/tui.py                    |  3 ---
>  6 files changed, 11 insertions(+), 23 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 347f7ea..7b23727 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -25,10 +25,6 @@ TAG=r$(VERSION)-$(RELEASE)
>  
>  PREFIX=/usr
>  
> -PYTHON2=python2
> -PYTHON3=python3
> -PYTHON=$(PYTHON2)
> -
>  ZANATA_PULL_ARGS = --transdir po/
>  ZANATA_PUSH_ARGS = --srcdir po/ --push-type source --force
>  
> @@ -37,7 +33,7 @@ default: all
>  all: po-files
>  
>  install:
> -	$(PYTHON) setup.py install --root=$(DESTDIR)
> +	$(python3) setup.py install --root=$(DESTDIR)
>  	$(MAKE) -C po install
>  
>  clean:
> diff --git a/initial-setup b/initial-setup
> index 462a515..34b1feb 100755
> --- a/initial-setup
> +++ b/initial-setup
> @@ -1,7 +1,7 @@
>  #!/bin/sh
>  
>  echo "Running initial_setup" | logger
> -if python -m initial_setup; then
> +if python3 -m initial_setup; then
>      echo "initial_setup finished successfully, disabling" | logger
>      /bin/systemctl disable initial-setup-graphical.service initial-setup-text.service &>/dev/null
>  else
> diff --git a/initial-setup.spec b/initial-setup.spec
> index 6a6f6f8..1c8b553 100644
> --- a/initial-setup.spec
> +++ b/initial-setup.spec
> @@ -18,23 +18,21 @@ Source0: %{name}-%{version}.tar.gz
>  License: GPLv2+
>  Group: System Environment/Base
>  BuildRequires: gettext
> -BuildRequires: python2-devel
> -BuildRequires: python-setuptools
> -BuildRequires: python-nose
> +BuildRequires: python3-devel
> +BuildRequires: python3-setuptools
> +BuildRequires: python3-nose
>  BuildRequires: systemd-units
>  BuildRequires: gtk3-devel
>  BuildRequires: glade-devel
>  BuildRequires: anaconda >= %{anacondaver}
> -BuildRequires: python-di
>  BuildRequires: intltool
>  
> -Requires: python
> +Requires: python3
>  Requires: anaconda-tui >= %{anacondaver}
>  Requires(post): systemd
>  Requires(preun): systemd
>  Requires(postun): systemd
> -Requires: libreport-python
> -Requires: python-di
> +Requires: libreport-python3
>  Requires: util-linux
>  Conflicts: firstboot < 19.2
>  
> @@ -102,8 +100,8 @@ fi
>  
>  %files -f %{name}.lang
>  %doc COPYING README.rst
> -%{python_sitelib}/initial_setup*
> -%exclude %{python_sitelib}/initial_setup/gui
> +%{python3_sitelib}/initial_setup*
> +%exclude %{python3_sitelib}/initial_setup/gui
>  %{_bindir}/initial-setup
>  %{_bindir}/firstboot-windowmanager
>  %{_unitdir}/initial-setup-text.service
> @@ -114,7 +112,7 @@ fi
>  %endif
>  
>  %files gui
> -%{python_sitelib}/initial_setup/gui/*
> +%{python3_sitelib}/initial_setup/gui/*
>  %{_unitdir}/initial-setup-graphical.service
>  
>  %changelog
> diff --git a/initial_setup/gui/gui.py b/initial_setup/gui/gui.py
> index e824e1f..64b114c 100644
> --- a/initial_setup/gui/gui.py
> +++ b/initial_setup/gui/gui.py
> @@ -4,7 +4,6 @@ from .hubs import InitialSetupMainHub
>  import os
>  from gi.repository import Gdk
>  import gettext
> -from di import inject, usesclassinject
>  
>  # localization
>  _ = lambda x: gettext.ldgettext("initial-setup", x)
> @@ -14,7 +13,6 @@ class InitialSetupQuitDialog(QuitDialog):
>      MESSAGE = N_("Are you sure you want to quit the configuration process?\n"
>                   "You might end up with unusable system if you do.")
>  
> - at inject(Gdk, product_title = product_title, is_final = is_final)
>  class InitialSetupGraphicalUserInterface(GraphicalUserInterface):
>      """This is the main Gtk based firstboot interface. It inherits from
>         anaconda to make the look & feel as similar as possible.
> @@ -22,7 +20,6 @@ class InitialSetupGraphicalUserInterface(GraphicalUserInterface):
>  
>      screenshots_directory = "/tmp/initial-setup-screenshots"
>  
> -    @usesclassinject
>      def __init__(self, storage, payload, instclass):
>          GraphicalUserInterface.__init__(self, storage, payload, instclass,
>                                          product_title, is_final,
> diff --git a/initial_setup/gui/hubs/initial_setup_hub.py b/initial_setup/gui/hubs/initial_setup_hub.py
> index 0fb6cb4..602aab1 100644
> --- a/initial_setup/gui/hubs/initial_setup_hub.py
> +++ b/initial_setup/gui/hubs/initial_setup_hub.py
> @@ -25,6 +25,6 @@ class InitialSetupMainHub(Hub):
>          Hub._createBox(self)
>  
>          # override spokes' distribution strings set by the pyanaconda module
> -        for spoke in self._spokes.itervalues():
> +        for spoke in self._spokes.values():
>              spoke.window.set_property("distribution",
>                                        product.product_title().upper())
> diff --git a/initial_setup/tui/tui.py b/initial_setup/tui/tui.py
> index 07b29a8..259ab13 100644
> --- a/initial_setup/tui/tui.py
> +++ b/initial_setup/tui/tui.py
> @@ -3,7 +3,6 @@ from initial_setup.product import product_title, is_final
>  from .hubs import InitialSetupMainHub
>  import os
>  import gettext
> -from di import inject, usesclassinject
>  
>  # localization
>  _ = lambda x: gettext.ldgettext("initial-setup", x)
> @@ -12,7 +11,6 @@ N_ = lambda x: x
>  QUIT_MESSAGE = N_("Are you sure you want to quit the configuration process?\n"
>                    "You might end up with unusable system if you do.")
>  
> - at inject(product_title = product_title, is_final = is_final)
>  class InitialSetupTextUserInterface(TextUserInterface):
>      """This is the main text based firstboot interface. It inherits from
>         anaconda to make the look & feel as similar as possible.
> @@ -20,7 +18,6 @@ class InitialSetupTextUserInterface(TextUserInterface):
>  
>      ENVIRONMENT = "firstboot"
>  
> -    @usesclassinject
>      def __init__(self, storage, payload, instclass):
>          TextUserInterface.__init__(self, storage, payload, instclass,
>                                           product_title, is_final, quitMessage = QUIT_MESSAGE)
> -- 
> 2.4.3
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches


More information about the anaconda-patches mailing list