Port Python scripts to Python 3, remove python 2 modules. (Closes: #938740, LP: #1099537)

This commit is contained in:
Stefano Rivera 2019-09-04 19:21:48 -03:00
parent 3d345113cc
commit bb765237db
7 changed files with 47 additions and 106 deletions

2
debian/changelog vendored
View File

@ -5,6 +5,8 @@ ubuntu-dev-tools (0.173) UNRELEASED; urgency=medium
use the same directory as the newer one, and break. use the same directory as the newer one, and break.
* Drop 404main, it's been totally broken for years. * Drop 404main, it's been totally broken for years.
* Use python3-debian's Version class in merge-changelog, to support Python 3. * Use python3-debian's Version class in merge-changelog, to support Python 3.
* Port Python scripts to Python 3, remove python 2 modules.
(Closes: #938740, LP: #1099537)
[ Scott Kitterman ] [ Scott Kitterman ]
* Update requestsync to python3 (Closes: #927147) * Update requestsync to python3 (Closes: #927147)

40
debian/control vendored
View File

@ -15,16 +15,6 @@ Build-Depends:
libwww-perl, libwww-perl,
lsb-release, lsb-release,
pylint (>= 2), pylint (>= 2),
python-all (>= 2.6.5-13~),
python-apt (>= 0.7.93~),
python-debian (>= 0.1.20~),
python-distro-info (>= 0.4~),
python-flake8,
python-httplib2,
python-launchpadlib (>= 1.5.7),
python-mock,
python-setuptools,
python-unittest2,
python3-all, python3-all,
python3-apt, python3-apt,
python3-debian, python3-debian,
@ -54,14 +44,6 @@ Depends:
distro-info (>= 0.2~), distro-info (>= 0.2~),
dpkg-dev, dpkg-dev,
lsb-release, lsb-release,
python,
python-apt (>= 0.7.93~),
python-debian (>= 0.1.20~),
python-distro-info (>= 0.4~),
python-httplib2,
python-launchpadlib (>= 1.5.7),
python-lazr.restfulclient,
python-ubuntutools,
python3, python3,
python3-apt, python3-apt,
python3-debian, python3-debian,
@ -93,7 +75,6 @@ Recommends:
reportbug (>= 3.39ubuntu1), reportbug (>= 3.39ubuntu1),
ubuntu-keyring | ubuntu-archive-keyring, ubuntu-keyring | ubuntu-archive-keyring,
Suggests: Suggests:
python-simplejson | python (>= 2.7),
qemu-user-static, qemu-user-static,
Description: useful tools for Ubuntu developers Description: useful tools for Ubuntu developers
This is a collection of useful tools that Ubuntu developers use to make their This is a collection of useful tools that Ubuntu developers use to make their
@ -142,27 +123,6 @@ Description: useful tools for Ubuntu developers
package. package.
- update-maintainer - script to update maintainer field in ubuntu packages. - update-maintainer - script to update maintainer field in ubuntu packages.
Package: python-ubuntutools
Architecture: all
Section: python
Depends:
python-debian,
python-distro-info,
python-httplib2,
python-launchpadlib,
sensible-utils,
${misc:Depends},
${python:Depends},
Breaks:
ubuntu-dev-tools (<< 0.154),
Replaces:
ubuntu-dev-tools (<< 0.154),
Description: useful APIs for Ubuntu developer tools — Python 2 library
This package ships a collection of APIs, helpers and wrappers used to
develop useful utilities for Ubuntu developers.
.
This package installs the library for Python 2.
Package: python3-ubuntutools Package: python3-ubuntutools
Architecture: all Architecture: all
Section: python Section: python

View File

@ -1 +0,0 @@
/usr/lib/python2.7

2
debian/rules vendored
View File

@ -1,4 +1,4 @@
#!/usr/bin/make -f #!/usr/bin/make -f
%: %:
dh $@ --with python2,python3 --buildsystem=pybuild dh $@ --with python3 --buildsystem=pybuild

View File

@ -4,7 +4,6 @@ from setuptools import setup
import glob import glob
import os import os
import re import re
import sys
import codecs import codecs
# look/set what version we have # look/set what version we have
@ -15,8 +14,7 @@ if os.path.exists(changelog):
if match: if match:
version = match.group(1) version = match.group(1)
if sys.version_info[0] >= 3: scripts = [
scripts = [
'backportpackage', 'backportpackage',
'bitesize', 'bitesize',
'check-mir', 'check-mir',
@ -48,16 +46,13 @@ if sys.version_info[0] >= 3:
'ubuntu-iso', 'ubuntu-iso',
'ubuntu-upload-permission', 'ubuntu-upload-permission',
'update-maintainer', 'update-maintainer',
] ]
data_files = [ data_files = [
('share/bash-completion/completions', glob.glob("bash_completion/*")), ('share/bash-completion/completions', glob.glob("bash_completion/*")),
('share/man/man1', glob.glob("doc/*.1")), ('share/man/man1', glob.glob("doc/*.1")),
('share/man/man5', glob.glob("doc/*.5")), ('share/man/man5', glob.glob("doc/*.5")),
('share/ubuntu-dev-tools', ['enforced-editing-wrapper']), ('share/ubuntu-dev-tools', ['enforced-editing-wrapper']),
] ]
else:
scripts = []
data_files = []
if __name__ == '__main__': if __name__ == '__main__':
setup( setup(

View File

@ -27,18 +27,13 @@ Approach:
3. Verify checksums. 3. Verify checksums.
""" """
from __future__ import with_statement, print_function from urllib.error import URLError, HTTPError
from urllib.parse import urlparse
from urllib.request import ProxyHandler, build_opener, urlopen
import codecs import codecs
import hashlib import hashlib
import json
import os.path import os.path
try:
from urllib.request import ProxyHandler, build_opener, urlopen
from urllib.parse import urlparse
from urllib.error import URLError, HTTPError
except ImportError:
from urllib2 import ProxyHandler, build_opener, urlopen, URLError, HTTPError
from urlparse import urlparse
import re import re
import sys import sys
@ -496,15 +491,6 @@ class DebianSourcePackage(SourcePackage):
def snapshot_list(self): def snapshot_list(self):
"Return a filename -> hash dictionary from snapshot.debian.org" "Return a filename -> hash dictionary from snapshot.debian.org"
if self._snapshot_list is None: if self._snapshot_list is None:
try:
import json
except ImportError:
import simplejson as json
except ImportError:
Logger.error("Please install python-simplejson.")
raise DownloadError("Unable to dowload from "
"snapshot.debian.org without "
"python-simplejson")
try: try:
data = self.url_opener.open( data = self.url_opener.open(

View File

@ -49,8 +49,7 @@ def get_source_files():
if is_script: if is_script:
with open(code_file, "rb") as script_file: with open(code_file, "rb") as script_file:
shebang = script_file.readline().decode("utf-8") shebang = script_file.readline().decode("utf-8")
if ((sys.version_info[0] == 3 and "python3" in shebang) if "python3" in shebang:
or ("python" in shebang and "python3" not in shebang)):
files.append(code_file) files.append(code_file)
else: else:
files.append(code_file) files.append(code_file)