From cc1e17304cc5faa6b896f64afd290bf92c9e3fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 26 Jun 2018 19:11:47 +0200 Subject: [PATCH] Remove support for Python 2.7 issue7497 review53261002 --- .drone.yml | 6 ------ CHANGELOG | 2 ++ INSTALL | 2 +- scripts/countries.py | 22 +++++++++++----------- scripts/trytond_import_zip | 7 +++---- setup.py | 17 +++++++---------- tox.ini | 6 +++--- 7 files changed, 27 insertions(+), 35 deletions(-) diff --git a/.drone.yml b/.drone.yml index e0bc2f7026..5da6083eb7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -25,12 +25,6 @@ services: matrix: include: - - IMAGE: python:2.7 - TOXENV: py27 - DATABASE: sqlite - - IMAGE: python:2.7 - TOXENV: py27 - DATABASE: postgresql - IMAGE: python:3.4 TOXENV: py34 DATABASE: sqlite diff --git a/CHANGELOG b/CHANGELOG index 30664538e2..7f7a774076 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Remove support for Python 2.7 + Version 4.8.0 - 2018-04-23 * Bug fixes (see mercurial logs for details) diff --git a/INSTALL b/INSTALL index e633e96781..c85275742f 100644 --- a/INSTALL +++ b/INSTALL @@ -4,7 +4,7 @@ Installing trytond_country Prerequisites ------------- - * Python 2.7 or later (http://www.python.org/) + * Python 3.4 or later (http://www.python.org/) * trytond (http://www.tryton.org/) Installation diff --git a/scripts/countries.py b/scripts/countries.py index bee33fd3d0..4765ff74da 100755 --- a/scripts/countries.py +++ b/scripts/countries.py @@ -5,12 +5,12 @@ import sys import pycountry -sys.stdout.write(u'\n') -sys.stdout.write(u'\n') -sys.stdout.write(u' \n') +sys.stdout.write('\n') +sys.stdout.write('\n') +sys.stdout.write(' \n') for country in pycountry.countries: - record = u''' + record = ''' %s %s @@ -19,12 +19,12 @@ for country in pycountry.countries: \n''' % (country.alpha_2.lower(), country.name, country.alpha_2, country.alpha_3, country.numeric) sys.stdout.write(record.encode('utf-8')) -sys.stdout.write(u' \n') +sys.stdout.write(' \n') subdivision_codes = {s.code.lower() for s in pycountry.subdivisions} existing_parents = set() while existing_parents < subdivision_codes: - sys.stdout.write(u' \n') + sys.stdout.write(' \n') new_parents = set() for subdivision in pycountry.subdivisions: if (subdivision.code.lower() in existing_parents @@ -33,7 +33,7 @@ while existing_parents < subdivision_codes: existing_parents)): continue new_parents.add(subdivision.code.lower()) - record = u''' + record = ''' %s %s @@ -41,15 +41,15 @@ while existing_parents < subdivision_codes: subdivision.name, subdivision.code, subdivision.type.lower()) if subdivision.parent_code: - record += u'''\ + record += '''\ \n''' % \ subdivision.parent.code.lower() - record += u'''\ + record += '''\ \n''' % subdivision.country.alpha_2.lower() sys.stdout.write(record.encode('utf-8')) - sys.stdout.write(u' \n') + sys.stdout.write(' \n') existing_parents |= new_parents -sys.stdout.write(u'\n') +sys.stdout.write('\n') diff --git a/scripts/trytond_import_zip b/scripts/trytond_import_zip index de379eda53..bd946d4ca3 100755 --- a/scripts/trytond_import_zip +++ b/scripts/trytond_import_zip @@ -76,10 +76,7 @@ def import_(data): widgets=[SimpleProgress(), Bar(), ETA()]) else: pbar = iter - if sys.version_info < (3,): - f = BytesIO(data) - else: - f = StringIO(data.decode('utf-8')) + f = StringIO(data.decode('utf-8')) for row in pbar(list(csv.DictReader( f, fieldnames=_fieldnames, delimiter='\t'))): country = get_country(row['country']) @@ -87,6 +84,7 @@ def import_(data): Zip(country=country, subdivision=subdivision, zip=row['postal'], city=row['place']).save() + _fieldnames = ['country', 'postal', 'place', 'name1', 'code1', 'name2', 'code2', 'name3', 'code3', 'latitude', 'longitude', 'accuracy'] @@ -100,6 +98,7 @@ def main(database, codes, config_file=None): clean(code) import_(fetch(code)) + if __name__ == '__main__': parser = ArgumentParser() parser.add_argument('-d', '--database', dest='database') diff --git a/setup.py b/setup.py index 482398d99a..853e83b3c7 100644 --- a/setup.py +++ b/setup.py @@ -1,15 +1,12 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. -from setuptools import setup -import re -import os import io -try: - from configparser import ConfigParser -except ImportError: - from ConfigParser import ConfigParser +import os +import re +from configparser import ConfigParser +from setuptools import setup def read(fname): @@ -27,6 +24,7 @@ def get_require_version(name): major_version, minor_version + 1) return require + config = ConfigParser() config.readfp(open('tryton.cfg')) info = dict(config.items('tryton')) @@ -102,7 +100,6 @@ setup(name=name, 'Natural Language :: Slovenian', 'Natural Language :: Spanish', 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', @@ -111,6 +108,7 @@ setup(name=name, 'Topic :: Office/Business', ], license='GPL-3', + python_requires='>=3.4', install_requires=requires, extras_require={ 'GeoNames': [get_require_version('proteus')], @@ -123,5 +121,4 @@ setup(name=name, """, test_suite='tests', test_loader='trytond.test_loader:Loader', - use_2to3=True, ) diff --git a/tox.ini b/tox.ini index 2082ab4f4d..adbcbf8431 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,11 @@ [tox] -envlist = {py27,py34,py35,py36}-{sqlite,postgresql},pypy-{sqlite,postgresql} +envlist = {py34,py35,py36}-{sqlite,postgresql},pypy3-{sqlite,postgresql} [testenv] commands = {envpython} setup.py test deps = - {py27,py34,py35,py36}-postgresql: psycopg2 >= 2.5 - pypy-postgresql: psycopg2cffi >= 2.5 + {py34,py35,py36}-postgresql: psycopg2 >= 2.5 + pypy3-postgresql: psycopg2cffi >= 2.5 sqlite: sqlitebck setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://}