Normalize version (#4949)

* Change wheel date to UTC ISO format

* Normalize Kivy version to X.Y.Z[.dev0+hash]

* Move version back to __init__

* Add date, print all, use __init__

* Print only if available
This commit is contained in:
Peter Badida 2017-01-28 00:11:12 +01:00 committed by GitHub
parent c6965414f2
commit da56a2577b
3 changed files with 55 additions and 7 deletions

View File

@ -81,7 +81,7 @@ build_script:
$env:PATH = $PYTHON_ROOT+"\share\glew\bin;"+$PYTHON_ROOT+"\share\sdl2\bin;"+$PYTHON_ROOT+"\share\gstreamer\bin;"+$env:PATH
$WHEEL_DATE = python -c "from time import strftime;print(strftime('%d%m%Y'))"
$WHEEL_DATE = python -c "from datetime import datetime;print(datetime.utcnow().strftime('%Y%m%d'))"
Check-Error

View File

@ -28,8 +28,6 @@ __all__ = (
'kivy_config_fn', 'kivy_usermodules_dir',
)
__version__ = '1.9.2-dev0'
import sys
import shutil
from getopt import getopt, GetoptError
@ -40,6 +38,22 @@ from kivy.compat import PY2
from kivy.logger import Logger, LOG_LEVELS
from kivy.utils import platform
MAJOR = 1
MINOR = 9
MICRO = 2
RELEASE = False
__version__ = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
if not RELEASE and '.dev0' not in __version__:
__version__ += '.dev0'
try:
from kivy.version import __hash__, __date__
__hash__ = __hash__[:7]
except ImportError:
__hash__ = __date__ = ''
# internals for post-configuration
__kivy_post_configuration = []
@ -102,7 +116,10 @@ def require(version):
# check x y z
v = version.split('.')
if len(v) != 3:
raise Exception('Revision format must be X.Y.Z[-tag]')
if 'dev0' in v:
tag = v.pop()
else:
raise Exception('Revision format must be X.Y.Z[-tag]')
return [int(x) for x in v], tag, tagrev
# user version
@ -435,5 +452,8 @@ if not environ.get('KIVY_DOC_INCLUDE'):
if platform == 'android':
Config.set('input', 'androidtouch', 'android')
Logger.info('Kivy: v%s' % (__version__))
if RELEASE:
Logger.info('Kivy: v%s' % (__version__))
elif not RELEASE and __hash__ and __date__:
Logger.info('Kivy: v%s, git-%s, %s' % (__version__, __hash__, __date__))
Logger.info('Python: v{}'.format(sys.version))

View File

@ -13,6 +13,8 @@ from os import walk, environ
from distutils.version import LooseVersion
from collections import OrderedDict
from time import sleep
from subprocess import check_output, CalledProcessError
from datetime import datetime
if environ.get('KIVY_USE_SETUPTOOLS'):
from setuptools import setup, Extension
@ -32,6 +34,32 @@ if PY3: # fix error with py3's LooseVersion comparisons
LooseVersion.__eq__ = ver_equal
def get_version(filename='kivy/version.py'):
VERSION = kivy.__version__
DATE = datetime.utcnow().strftime('%Y%m%d')
try:
GIT_REVISION = check_output(
['git', 'rev-parse', 'HEAD']
).strip().decode('ascii')
except CalledProcessError:
GIT_REVISION = "Unknown"
cnt = (
"# THIS FILE IS GENERATED FROM KIVY SETUP.PY\n"
"__version__ = '%(version)s'\n"
"__hash__ = '%(hash)s'\n"
"__date__ = '%(date)s'\n"
)
with open(filename, 'w') as f:
f.write(cnt % {
'version': VERSION,
'hash': GIT_REVISION,
'date': DATE
})
return VERSION
MIN_CYTHON_STRING = '0.23'
MIN_CYTHON_VERSION = LooseVersion(MIN_CYTHON_STRING)
MAX_CYTHON_STRING = '0.23'
@ -288,7 +316,7 @@ class KivyBuildExt(build_ext):
def _check_and_fix_sdl2_mixer(f_path):
print("Check if SDL2_mixer smpeg2 have an @executable_path")
rpath_from = ("@executable_path/../Frameworks/SDL2.framework"
"/Versions/A/SDL2")
"/Versions/A/SDL2")
rpath_to = "@rpath/../../../../SDL2.framework/Versions/A/SDL2"
smpeg2_path = ("{}/Versions/A/Frameworks/smpeg2.framework"
"/Versions/A/smpeg2").format(f_path)
@ -887,7 +915,7 @@ if isdir(binary_deps_path):
# setup !
setup(
name='Kivy',
version=kivy.__version__,
version=get_version(),
author='Kivy Team and other contributors',
author_email='kivy-dev@googlegroups.com',
url='http://kivy.org',