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 a83f43fa5d
3 changed files with 23 additions and 11 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())

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