diff --git a/buildconf/default.ini b/buildconf/default.ini index 44bc5249..f36b4d1f 100644 --- a/buildconf/default.ini +++ b/buildconf/default.ini @@ -25,6 +25,7 @@ yaml_implementation = auto malloc_implementation = libc plugins = bin_name = uwsgi +append_version = plugin_dir = . embedded_plugins = python, ping, cache, nagios, rpc, fastrouter, http, ugreen diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index 05df46d8..081eab9f 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -428,6 +428,20 @@ void init_uwsgi_embedded_module() { exit(1); } + PyObject *uwsgi_py_version_info = PyTuple_New(5); + + PyTuple_SetItem(uwsgi_py_version_info, 0, PyString_FromString(UWSGI_VERSION_BASE)); + PyTuple_SetItem(uwsgi_py_version_info, 1, PyString_FromString(UWSGI_VERSION_MAJOR)); + PyTuple_SetItem(uwsgi_py_version_info, 2, PyString_FromString(UWSGI_VERSION_MINOR)); + PyTuple_SetItem(uwsgi_py_version_info, 3, PyString_FromString(UWSGI_VERSION_REVISION)); + PyTuple_SetItem(uwsgi_py_version_info, 4, PyString_FromString(UWSGI_VERSION_CUSTOM)); + + if (PyDict_SetItemString(up.embedded_dict, "version_info", uwsgi_py_version_info)) { + PyErr_Print(); + exit(1); + } + + if (PyDict_SetItemString(up.embedded_dict, "hostname", PyString_FromStringAndSize(uwsgi.hostname, uwsgi.hostname_len))) { PyErr_Print(); exit(1); diff --git a/uwsgiconfig.py b/uwsgiconfig.py index 03edcb0c..9a9f7dfb 100644 --- a/uwsgiconfig.py +++ b/uwsgiconfig.py @@ -1,6 +1,6 @@ # uWSGI build system -uwsgi_version = '0.9.8-dev' +uwsgi_version = '0.9.8' import os import re @@ -176,7 +176,7 @@ class uConf(object): if uwsgi_os == 'Linux': self.gcc_list.append('lib/linux_ns') self.gcc_list.append('lib/netlink') - self.cflags = ['-DUWSGI_VERSION="\\"' + uwsgi_version + '\\""', '-O2', '-Wall', '-Werror', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64'] + os.environ.get("CFLAGS", "").split() + self.cflags = ['-O2', '-Wall', '-Werror', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64'] + os.environ.get("CFLAGS", "").split() try: gcc_version = str(spcall("%s -dumpversion" % GCC)) except: @@ -237,6 +237,8 @@ class uConf(object): def get_gcll(self): + global uwsgi_version + self.cflags.append('-DUWSGI_BUILD_DATE="\\"%s\\""' % time.strftime("%d %B %Y %H:%M:%S")) kvm_list = ['FreeBSD', 'OpenBSD', 'NetBSD', 'DragonFly'] @@ -407,6 +409,41 @@ class uConf(object): if os.path.exists('/usr/lib/libuuid.so') or os.path.exists('/usr/local/lib/libuuid.so'): self.libs.append('-luuid') + if self.get('append_version'): + if not self.get('append_version').startswith('-'): + uwsgi_version += '-' + uwsgi_version += self.get('append_version') + + self.cflags.append('-DUWSGI_VERSION="\\"' + uwsgi_version + '\\""') + + uver_whole = uwsgi_version.split('-', 1) + if len(uver_whole) == 1: + uver_custom = '' + else: + uver_custom = uver_whole[1] + + uver_dots = uver_whole[0].split('.') + + uver_base = uver_dots[0] + uver_maj = uver_dots[1] + uver_min = '0' + uver_rev = '0' + + if len(uver_dots) > 2: + uver_min = uver_dots[2] + + if len(uver_dots) > 3: + uver_rev = uver_dots[3] + + + self.cflags.append('-DUWSGI_VERSION_BASE="\\"' + uver_base + '\\""') + self.cflags.append('-DUWSGI_VERSION_MAJOR="\\"' + uver_maj + '\\""') + self.cflags.append('-DUWSGI_VERSION_MINOR="\\"' + uver_min + '\\""') + self.cflags.append('-DUWSGI_VERSION_REVISION="\\"' + uver_rev + '\\""') + self.cflags.append('-DUWSGI_VERSION_CUSTOM="\\"' + uver_custom + '\\""') + + + if self.get('async'): self.cflags.append("-DUWSGI_ASYNC") self.gcc_list.append('async')