add python 3 compatibility (#60502)

And use django 2.1.
This commit is contained in:
Emmanuel Cazenave 2022-01-11 14:49:26 +01:00
parent ae13ffea07
commit ee71b4bd13
6 changed files with 30 additions and 20 deletions

View File

@ -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())

1
debian/compat vendored
View File

@ -1 +0,0 @@
9

13
debian/control vendored
View File

@ -2,21 +2,20 @@ Source: eo-bidon
Section: python
Priority: optional
Maintainer: Emmanuel Cazenave <ecazenave@entrouvert.com>
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)

2
debian/rules vendored
View File

@ -5,4 +5,4 @@
#export DH_VERBOSE=1
%:
dh $@ --with python2,systemd
dh $@ --with python3 --buildsystem=pybuild

View File

@ -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):

View File

@ -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