diff --git a/bidon/settings.py b/bidon/settings.py index 8066dab..66f4771 100644 --- a/bidon/settings.py +++ b/bidon/settings.py @@ -107,4 +107,5 @@ local_settings_file = os.environ.get( 'BIDON_SETTINGS_FILE', os.path.join(os.path.dirname(__file__), 'local_settings.py')) if os.path.exists(local_settings_file): - execfile(local_settings_file) + with open(local_settings_file) as f: + exec(f.read()) diff --git a/debian/compat b/debian/compat deleted file mode 100644 index ec63514..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/debian/control b/debian/control index 44b170b..a732b47 100644 --- a/debian/control +++ b/debian/control @@ -2,21 +2,20 @@ Source: eo-bidon Section: python Priority: optional Maintainer: Emmanuel Cazenave -Build-Depends: debhelper (>= 9), - python-django, - python-setuptools (>= 0.6b3), - python-all (>= 2.6.6-3), +Build-Depends: debhelper-compat (= 12), + python3-django, + python3-setuptools, + python3-all, dh-python, dh-systemd Standards-Version: 3.9.6 Homepage: https://dev.entrouvert.org/projects/bidon -X-Python-Version: >= 2.7 Package: python-eo-bidon Architecture: all Depends: ${python:Depends}, ${misc:Depends}, - python-django (>= 1.7), - python-setuptools, + python3-django (>= 1:1.11), + python3-setuptools, Description: Entr'ouvert sandox package (python module) diff --git a/debian/rules b/debian/rules index 83aef84..729afc3 100755 --- a/debian/rules +++ b/debian/rules @@ -5,4 +5,4 @@ #export DH_VERBOSE=1 %: - dh $@ --with python2,systemd + dh $@ --with python3 --buildsystem=pybuild diff --git a/setup.py b/setup.py index 3660274..53e5284 100644 --- a/setup.py +++ b/setup.py @@ -25,19 +25,30 @@ class eo_sdist(sdist): def get_version(): + """Use the VERSION, if absent generates a version with git describe, if not + tag exists, take 0.0- and add the length of the commit log. + """ if os.path.exists('VERSION'): - version_file = open('VERSION', 'r') - version = version_file.read() - version_file.close() - return version + with open('VERSION') as v: + return v.read() if os.path.exists('.git'): - p = subprocess.Popen(['git', 'describe', '--dirty', '--match=v*'], stdout=subprocess.PIPE) + p = subprocess.Popen( + ['git', 'describe', '--dirty=.dirty', '--match=v*'], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) result = p.communicate()[0] if p.returncode == 0: - version = result.split()[0][1:] - version = version.replace('-', '.') + result = result.decode('ascii').strip()[1:] # strip spaces/newlines and initial v + if '-' in result: # not a tagged version + real_number, commit_count, commit_hash = result.split('-', 2) + version = '%s.post%s+%s' % (real_number, commit_count, commit_hash) + else: + version = result return version - return '0' + else: + return '0.0.post%s' % len(subprocess.check_output(['git', 'rev-list', 'HEAD']).splitlines()) + return '0.0' class compile_translations(Command): diff --git a/tox.ini b/tox.ini index 5825e80..e4fa390 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/bidon/{env:BRANCH_NAME:} -envlist = py2-django111-coverage-junit +envlist = py3-django22-coverage-junit [testenv] usedevelop = True @@ -11,7 +11,7 @@ setenv = coverage: COVERAGE=--cov-report xml --cov-report html --cov=bidon/ junit: JUNIT=--junitxml=junit-{envname}.xml deps = - django111: django>=1.11,<1.12 + django22: django>=2.2,<2.3 psycopg2<2.9 pytest-cov pytest-django