Skip to content

Commit

Permalink
Have all the scripts run in python 3 by default
Browse files Browse the repository at this point in the history
The Python 3 refactoring effort is finishing, it should be safe
to turn all scripts to run in Python 3 by default.

https://pagure.io/freeipa/issue/4985

Reviewed-By: Christian Heimes <[email protected]>
  • Loading branch information
stlaz authored and tiran committed Feb 15, 2018
1 parent 1b0c55a commit f31797c
Show file tree
Hide file tree
Showing 66 changed files with 70 additions and 133 deletions.
2 changes: 1 addition & 1 deletion client/ipa-certupdate
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2 -E
#!/usr/bin/python3 -E
# Authors: Jan Cholasta <[email protected]>
#
# Copyright (C) 2014 Red Hat
Expand Down
2 changes: 1 addition & 1 deletion client/ipa-client-automount
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2 -E
#!/usr/bin/python3 -E
#
# Authors:
# Rob Crittenden <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion client/ipa-client-install
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2 -E
#!/usr/bin/python3 -E
# Authors: Simo Sorce <[email protected]>
# Karl MacMillan <[email protected]>
#
Expand Down
2 changes: 1 addition & 1 deletion contrib/copy-schema-to-ca-RHEL6.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2
#!/usr/bin/python2

"""Copy the IPA schema to the CA directory server instance
Expand Down
2 changes: 1 addition & 1 deletion daemons/dnssec/ipa-dnskeysync-replica
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
#
# Copyright (C) 2014 FreeIPA Contributors see COPYING for license
#
Expand Down
2 changes: 1 addition & 1 deletion daemons/dnssec/ipa-dnskeysyncd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
#
# Copyright (C) 2014 FreeIPA Contributors see COPYING for license
#
Expand Down
2 changes: 1 addition & 1 deletion daemons/dnssec/ipa-ods-exporter
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
#
# Copyright (C) 2014 FreeIPA Contributors see COPYING for license
#
Expand Down
2 changes: 1 addition & 1 deletion daemons/ipa-otpd/test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
#
# FreeIPA 2FA companion daemon
#
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/python-api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
# Authors:
# Jason Gerard DeRose <[email protected]>
#
Expand Down
73 changes: 5 additions & 68 deletions freeipa.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,8 @@ export JAVA_STACK_SIZE="8m"
# PATH is workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1005235
export PATH=/usr/bin:/usr/sbin:$PATH
export PYTHON=%{__python2}

%if ! 0%{?with_python3}
# Workaround: make sure all shebangs are pointing to Python 2
# This should be solved properly using setuptools
# and this hack should be removed.
Expand All @@ -937,64 +939,7 @@ find \
! -name '*.pyo' -a \
-type f -exec grep -qsm1 '^#!.*\bpython' {} \; \
-exec sed -i -e '1 s|^#!.*\bpython[^ ]*|#!%{__python2}|' {} \;

%if 0%{?with_python3}
# TODO: temporary solution until all scripts are ported to python3,
# TODO: workaround: some scripts are copied over, so the are always py2.
# We have to explicitly set python3 here for ported files here
PY3_SUBST_PATHS='
client/ipa-certupdate
client/ipa-client-automount
client/ipa-client-install
daemons/dnssec/ipa-dnskeysyncd
daemons/dnssec/ipa-dnskeysync-replica
daemons/dnssec/ipa-ods-exporter
daemons/ipa-otpd/test.py
install/certmonger/ipa-server-guard
install/certmonger/dogtag-ipa-ca-renew-agent-submit
install/oddjob/com.redhat.idm.trust-fetch-domains
install/restart_scripts/renew_ra_cert_pre
install/restart_scripts/renew_ca_cert
install/restart_scripts/renew_ra_cert
install/restart_scripts/restart_httpd
install/restart_scripts/renew_kdc_cert
install/restart_scripts/stop_pkicad
install/restart_scripts/restart_dirsrv
install/tools/ipa-advise
install/tools/ipa-adtrust-install
install/tools/ipa-backup
install/tools/ipa-ca-install
install/tools/ipa-cacert-manage
install/tools/ipa-compat-manage
install/tools/ipa-csreplica-manage
install/tools/ipa-custodia
install/tools/ipa-custodia-check
install/tools/ipa-dns-install
install/tools/ipa-httpd-kdcproxy
install/tools/ipa-kra-install
install/tools/ipa-ldap-updater
install/tools/ipa-managed-entries
install/tools/ipa-nis-manage
install/tools/ipa-otptoken-import
install/tools/ipa-pkinit-manage
install/tools/ipa-pki-retrieve-key
install/tools/ipa-replica-conncheck
install/tools/ipa-replica-install
install/tools/ipa-replica-manage
install/tools/ipa-replica-prepare
install/tools/ipa-restore
install/tools/ipa-server-certinstall
install/tools/ipa-server-install
install/tools/ipa-server-upgrade
install/tools/ipa-winsync-migrate
install/tools/ipactl
ipa
'
for P in $PY3_SUBST_PATHS; do
sed -i -e '1 s|^#!\s\?.*\bpython[0-9]*|#!%{__python3}|' $P
done;

%endif # with_python3
%endif # ! with_python3

%configure --with-vendor-suffix=-%{release} \
%{enable_server_option} \
Expand All @@ -1005,22 +950,14 @@ done;
%make_build -Onone

%if 0%{?with_python3}
pushd %{_builddir}/freeipa-%{version}-python3
export PYTHON=%{__python3}
# Workaround: make sure all shebangs are pointing to Python 3
# This should be solved properly using setuptools
# and this hack should be removed.
find \
! -name '*.pyc' -a \
! -name '*.pyo' -a \
-type f -exec grep -qsm1 '^#!.*\bpython' {} \; \
-exec sed -i -e '1 s|^#!.*\bpython[^ ]*|#!%{__python3}|' {} \;
pushd %{_builddir}/freeipa-%{version}-python3
%configure --with-vendor-suffix=-%{release} \
%{enable_server_option} \
%{with_ipatests_option} \
%{linter_options}
popd
%endif # with_python3
%endif # with_python3

%check
make %{?_smp_mflags} check VERBOSE=yes LIBDIR=%{_libdir}
Expand Down
2 changes: 1 addition & 1 deletion install/certmonger/dogtag-ipa-ca-renew-agent-submit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2 -E
#!/usr/bin/python3 -E
#
# Authors:
# Jan Cholasta <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion install/certmonger/ipa-server-guard
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2 -E
#!/usr/bin/python3 -E
#
# Authors:
# Jan Cholasta <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion install/oddjob/com.redhat.idm.trust-fetch-domains
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3

from ipaserver import dcerpc
from ipaserver.install.installutils import is_ipa_configured, ScriptError
Expand Down
2 changes: 1 addition & 1 deletion install/restart_scripts/renew_ca_cert
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2 -E
#!/usr/bin/python3 -E
#
# Authors:
# Rob Crittenden <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion install/restart_scripts/renew_kdc_cert
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2 -E
#!/usr/bin/python3 -E
#
# Copyright (C) 2017 FreeIPA Contributors see COPYING for license
#
Expand Down
2 changes: 1 addition & 1 deletion install/restart_scripts/renew_ra_cert
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2 -E
#!/usr/bin/python3 -E
#
# Authors:
# Rob Crittenden <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion install/restart_scripts/renew_ra_cert_pre
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2 -E
#!/usr/bin/python3 -E
#
# Copyright (C) 2015 FreeIPA Contributors see COPYING for license
#
Expand Down
2 changes: 1 addition & 1 deletion install/restart_scripts/restart_dirsrv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2 -E
#!/usr/bin/python3 -E
#
# Authors:
# Rob Crittenden <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion install/restart_scripts/restart_httpd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2 -E
#!/usr/bin/python3 -E
#
# Authors:
# Rob Crittenden <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion install/restart_scripts/stop_pkicad
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2 -E
#!/usr/bin/python3 -E
#
# Authors:
# Rob Crittenden <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-adtrust-install
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2
#!/usr/bin/python3
#
# Authors: Sumit Bose <[email protected]>
# Based on ipa-server-install by Karl MacMillan <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-advise
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2 -E
#!/usr/bin/python3 -E
# Authors: Tomas Babej <[email protected]>
#
# Copyright (C) 2013 Red Hat
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-backup
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2 -E
#!/usr/bin/python3 -E
# Authors: Rob Crittenden <[email protected]>
#
# Copyright (C) 2013 Red Hat
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-ca-install
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2 -E
#!/usr/bin/python3 -E
# Authors: Rob Crittenden <[email protected]>
#
# Copyright (C) 2011 Red Hat
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-cacert-manage
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2 -E
#!/usr/bin/python3 -E
# Authors: Jan Cholasta <[email protected]>
#
# Copyright (C) 2014 Red Hat
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-compat-manage
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
# Authors: Rob Crittenden <[email protected]>
# Authors: Simo Sorce <[email protected]>
#
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-csreplica-manage
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2 -E
#!/usr/bin/python3 -E
# Authors: Rob Crittenden <[email protected]>
#
# Based on ipa-replica-manage by Karl MacMillan <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-custodia
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
# Copyright (C) 2017 IPA Project Contributors, see COPYING for license
from ipaserver.secrets.service import main

Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-dns-install
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2 -E
#!/usr/bin/python3 -E
# Authors: Martin Nagy <[email protected]>
# Based on ipa-server-install by Karl MacMillan <[email protected]>
#
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-httpd-kdcproxy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
# Authors:
# Christian Heimes <[email protected]>
#
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-kra-install
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2 -E
#!/usr/bin/python3 -E
# Authors: Ade Lee <[email protected]>
#
# Copyright (C) 2014 Red Hat
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-ldap-updater
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
# Authors: Rob Crittenden <[email protected]>
#
# Copyright (C) 2008 Red Hat
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-managed-entries
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
# Authors: Jr Aquino <[email protected]>
#
# Copyright (C) 2011 Red Hat
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-nis-manage
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
# Authors: Rob Crittenden <[email protected]>
# Authors: Simo Sorce <[email protected]>
#
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-otptoken-import
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2 -E
#!/usr/bin/python3 -E
# Authors: Nathaniel McCallum <[email protected]>
#
# Copyright (C) 2014 Red Hat
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-pki-retrieve-key
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3

from __future__ import print_function

Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-pkinit-manage
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2 -E
#!/usr/bin/python3 -E
#
# Copyright (C) 2017 FreeIPA Contributors see COPYING for license
#
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-replica-conncheck
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2 -E
#!/usr/bin/python3 -E
# Authors: Martin Kosek <[email protected]>
#
# Copyright (C) 2011 Red Hat
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-replica-install
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2 -E
#!/usr/bin/python3 -E
# Authors: Karl MacMillan <[email protected]>
#
# Copyright (C) 2007 Red Hat
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-replica-manage
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2 -E
#!/usr/bin/python3 -E
# Authors: Karl MacMillan <[email protected]>
#
# Copyright (C) 2007 Red Hat
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-replica-prepare
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2 -E
#!/usr/bin/python3 -E
# Authors: Petr Viktorin <[email protected]>
#
# Copyright (C) 2012 Red Hat
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-restore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2 -E
#!/usr/bin/python3 -E
# Authors: Rob Crittenden <[email protected]>
#
# Copyright (C) 2013 Red Hat
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-server-certinstall
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2 -E
#!/usr/bin/python3 -E
# Authors: Jan Cholasta <[email protected]>
#
# Copyright (C) 2013 Red Hat
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-server-install
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2 -E
#!/usr/bin/python3 -E
# Authors: Karl MacMillan <[email protected]>
# Simo Sorce <[email protected]>
# Rob Crittenden <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-server-upgrade
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
#
# Copyright (C) 2015 FreeIPA Contributors see COPYING for license
#
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipa-winsync-migrate
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python2 -E
#!/usr/bin/python3 -E
# Authors: Tomas Babej <[email protected]>
#
# Copyright (C) 2015 Red Hat
Expand Down
2 changes: 1 addition & 1 deletion install/tools/ipactl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
# Authors: Simo Sorce <[email protected]>
#
# Copyright (C) 2008-2010 Red Hat
Expand Down
2 changes: 1 addition & 1 deletion ipa
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3

# Authors:
# Jason Gerard DeRose <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion ipaclient/csrgen_ffi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3

from cffi import FFI
import ctypes.util
Expand Down
2 changes: 1 addition & 1 deletion ipaclient/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
# Copyright (C) 2007 Red Hat
# see file 'COPYING' for use and warranty information
#
Expand Down
2 changes: 1 addition & 1 deletion ipalib/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
# Copyright (C) 2007 Red Hat
# see file 'COPYING' for use and warranty information
#
Expand Down
Loading

0 comments on commit f31797c

Please sign in to comment.