diff --git a/Makefile b/Makefile index 8a1b693e..d51bf425 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,2 @@ -CC=gcc - -PYTHON_CFLAGS=`python-config --cflags` -PYTHON_LIBS=`python-config --libs` - -UWSGI_CFLAGS=`python uwsgiconfig.py --cflags` -UWSGI_LDFLAGS=`python uwsgiconfig.py --ldflags` - -CFLAGS=$(PYTHON_CFLAGS) $(UWSGI_CFLAGS) -LD_FLAGS=$(PYTHON_LIBS) $(UWSGI_LDFLAGS) -export-dynamic - -PROGRAM=uwsgi - -include base.mk +all: + python uwsgiconfig.py --build diff --git a/Makefile.Py25 b/Makefile.Py25 index 49d68fb7..333305ea 100644 --- a/Makefile.Py25 +++ b/Makefile.Py25 @@ -1,14 +1,2 @@ -CC=gcc - -PYTHON_CFLAGS=`python2.5-config --cflags` -PYTHON_LIBS=`python2.5-config --libs` - -UWSGI_CFLAGS=`python2.5 uwsgiconfig.py --cflags` -UWSGI_LDFLAGS=`python2.5 uwsgiconfig.py --ldflags` - -CFLAGS=$(PYTHON_CFLAGS) $(UWSGI_CFLAGS) -LD_FLAGS=$(PYTHON_LIBS) $(UWSGI_LDFLAGS) - -PROGRAM=uwsgi25 - -include base.mk +all: + python2.5 uwsgiconfig.py --build diff --git a/plugins/lua/lua_plugin.c b/plugins/lua/lua_plugin.c index ab13aaf1..cfd955a1 100644 --- a/plugins/lua/lua_plugin.c +++ b/plugins/lua/lua_plugin.c @@ -267,3 +267,14 @@ int uwsgi_request(struct uwsgi_server *uwsgi, struct wsgi_request *wsgi_req) { void uwsgi_after_request(struct uwsgi_server *uwsgi, struct wsgi_request *wsgi_req) { return; } + + +struct uwsgi_plugin lua_plugin { + + .name = "lua", + .modifier1 = 6, + .init = uwsgi_init, + .request = uwsgi_request, + .after_request = uwsgi_after_request, + .async = 0, +}; diff --git a/setup.py b/setup.py index 496c1c50..48dddb7f 100644 --- a/setup.py +++ b/setup.py @@ -1,33 +1,21 @@ import os import sys +import uwsgiconfig as uc import shutil -version = sys.version_info - -if version[0] > 2: - print("python 3.x is not supported") - sys.exit() - -print("detected python version %d.%d" % (version[0], version[1])) - -uver = "%d%d" % (version[0], version[1]) -bin_name = "uwsgi" -make_cmd = "make" - -if uver != "25": - bin_name = "%s%s" % (bin_name, uver) - make_cmd = "%s -f Makefile.Py%s" % (make_cmd, uver) +print sys.argv from distutils.core import setup -os.system(make_cmd) -shutil.copy(bin_name, sys.prefix + '/bin') +uc.build_uwsgi(uc.UWSGI_BIN_NAME, uc.uver, uc.cflags, uc.ldflags) + +shutil.copy(uc.UWSGI_BIN_NAME, sys.prefix + '/bin') setup(name='uWSGI', - version='0.9.4.2', + version='0.9.5', description='The uWSGI server', - author='Roberto De Ioris', - author_email='roberto@unbit.it', + author='Unbit', + author_email='info@unbit.it', url='http://projects.unbit.it/uwsgi/', license='GPL2', ) diff --git a/utils.c b/utils.c index e85291cf..8e9f3ef3 100644 --- a/utils.c +++ b/utils.c @@ -1,5 +1,6 @@ #include "uwsgi.h" + extern struct uwsgi_server uwsgi; #ifdef __BIG_ENDIAN__ diff --git a/uwsgi.c b/uwsgi.c index 564b9405..dacfcfe1 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -2224,7 +2224,7 @@ void uwsgi_wsgi_config () { applications = PyDict_GetItemString (uwsgi_dict, "applications"); if (!PyDict_Check (applications)) { - fprintf (stderr, "uwsgi.applications dictionary is not defined, trying with the (deprecated) \"applications\" one...\n"); + fprintf (stderr, "uwsgi.applications dictionary is not defined, trying with the \"applications\" one...\n"); #endif applications = PyDict_GetItemString (wsgi_dict, "applications"); if (!applications) { @@ -2698,20 +2698,20 @@ void manage_opt(int i, char *optarg) { \t-z|--socket-timeout \tset socket timeout to seconds (default 4 seconds)\n\ \t-b|--buffer-size \t\tset buffer size to bytes\n\ \t-L|--disable-logging\t\tdisable request logging (only errors or server messages will be logged)\n\ -\t-x|--xmlconfig \t\tpath of xml config file (no ROCK_SOLID)\n\ -\t-w|--module \t\tname of python config module (no ROCK_SOLID)\n\ +\t-x|--xmlconfig \t\tpath of xml config file\n\ +\t-w|--module \t\tname of python config module\n\ \t-t|--harakiri \t\tset harakiri timeout to seconds\n\ \t-p|--processes \t\tspawn uwsgi worker processes\n\ -\t-O|--optimize \t\tset python optimization level to (no ROCK_SOLID)\n\ +\t-O|--optimize \t\tset python optimization level to \n\ \t-v|--max-vars \t\tset maximum number of vars/headers to \n\ \t-A|--sharedarea \t\tcreate a shared memory area of pages\n\ -\t-c|--cgi-mode\t\t\tset cgi mode (no ROCK_SOLID) \n\ +\t-c|--cgi-mode\t\t\tset cgi mode\n\ \t-C|--chmod-socket\t\tchmod socket to 666\n\ -\t-P|--profiler\t\t\tenable profiler (no ROCK_SOLID)\n\ +\t-P|--profiler\t\t\tenable profiler\n\ \t-m|--memory-report\t\tenable memory usage report\n\ -\t-i|--single-interpreter\t\tsingle interpreter mode (no ROCK_SOLID)\n\ +\t-i|--single-interpreter\t\tsingle interpreter mode\n\ \t-a|--abstract-socket\t\tset socket in the abstract namespace (Linux only)\n\ -\t-T|--enable-threads\t\tenable threads support (no ROCK_SOLID)\n\ +\t-T|--enable-threads\t\tenable threads support\n\ \t-M|--master\t\t\tenable master process manager\n\ \t-H|--home \t\tset python home/virtualenv\n\ \t-h|--help\t\t\tthis help\n\ diff --git a/uwsgiconfig.py b/uwsgiconfig.py index 49d9b6fe..81a68d81 100644 --- a/uwsgiconfig.py +++ b/uwsgiconfig.py @@ -1,17 +1,20 @@ # uWSGI configuration XML=True -SNMP=False -SCTP=False -ERLANG=False +SNMP=True +SCTP=True +ERLANG=True SPOOLER=True EMBEDDED=True -UDP=False +UDP=True THREADING=True SENDFILE=True PROFILER=True NAGIOS=True PROXY=True +PLUGINS = ['example', 'lua', 'psgi'] +UWSGI_BIN_NAME = 'uwsgi' +GCC='gcc' @@ -23,59 +26,111 @@ uwsgi_os = os.uname()[0] import sys +gcc_list = ['utils', 'protocol', 'socket', 'logging', 'wsgi_handlers', 'uwsgi_handlers', 'uwsgi'] + +cflags = [] +ldflags = [] + +def add_o(x): + if x == 'uwsgi': + x = 'main' + x = x + '.o' + return x + + +def build_uwsgi(bin_name, version, cflags, ldflags): + cflags.insert(0, os.popen("python%s-config --cflags" % version).read().rstrip()) + ldflags.insert(0, os.popen("python%s-config --libs" % version).read().rstrip()) + print("*** uWSGI compiling ***") + for file in gcc_list: + objfile = file + if objfile == 'uwsgi': + objfile = 'main' + cmdline = "%s -c %s -o %s %s" % (GCC, ' '.join(cflags), objfile + '.o', file + '.c') + print(cmdline) + ret = os.system(cmdline) + if ret != 0: + sys.exit(1) + + if len(PLUGINS) > 0: + print("*** uWSGI embedding plugin ***") + for plugin in PLUGINS: + print plugin + + print("*** uWSGI linking ***") + ldline = "%s -o %s -lpthread -export-dynamic %s %s" % (GCC, bin_name, ' '.join(map(add_o, gcc_list)), ' '.join(ldflags)) + print(ldline) + ret = os.system(ldline) + if ret != 0: + print("*** error linking uWSGI ***") + sys.exit(1) + + print("*** uWSGI is ready, launch it with ./%s ***" % bin_name) + -cflags = '' -ldflags = '' kvm_list = ['SunOS', 'FreeBSD', 'OpenBSD', 'NetBSD', 'DragonFly'] if uwsgi_os == 'SunOS': - ldflags = ldflags + ' -lsendfile ' + ldflags.append('-lsendfile') if uwsgi_os in kvm_list: - ldflags = ldflags + ' -lkvm ' + ldflags.append('-lkvm') if EMBEDDED: - cflags = cflags + ' -DUWSGI_EMBEDDED ' + cflags.append('-DUWSGI_EMBEDDED') + gcc_list.append('uwsgi_pymodule') if UDP: - cflags = cflags + ' -DUWSGI_UDP ' + cflags.append("-DUWSGI_UDP") if NAGIOS: - cflags = cflags + ' -DUWSGI_NAGIOS ' + cflags.append("-DUWSGI_NAGIOS") if PROXY: - cflags = cflags + ' -DUWSGI_PROXY ' + cflags.append("-DUWSGI_PROXY") + gcc_list.append('proxy') if SNMP: - cflags = cflags + ' -DUWSGI_SNMP ' + cflags.append("-DUWSGI_SNMP") + gcc_list.append('snmp') if THREADING: - cflags = cflags + ' -DUWSGI_THREADING ' + cflags.append("-DUWSGI_THREADING") if PROFILER: - cflags = cflags + ' -DUWSGI_PROFILER ' + cflags.append("-DUWSGI_PROFILER") if SENDFILE: - cflags = cflags + ' -DUWSGI_SENDFILE ' + cflags.append("-DUWSGI_SENDFILE") if XML: - ldflags = ldflags + os.popen('xml2-config --libs').read().rstrip() - cflags = cflags + ' -DUWSGI_XML ' + os.popen('xml2-config --cflags').read().rstrip() + ldflags.append(os.popen('xml2-config --libs').read().rstrip()) + cflags.append("-DUWSGI_XML") + cflags.append(os.popen('xml2-config --cflags').read().rstrip()) + gcc_list.append('xmlconf') if ERLANG: - cflags = cflags + ' -DUWSGI_ERLANG ' - ldflags = ldflags + ' -lerl_interface -lei ' + cflags.append("-DUWSGI_ERLANG") + ldflags.append("-lerl_interface -lei") + gcc_list.append('erlang') if SCTP: - ldflags = ldflags + ' -lsctp ' - cflags = cflags + ' -DUWSGI_SCTP ' + ldflags.append("-lsctp") + cflags.append("-DUWSGI_SCTP") if SPOOLER: - cflags = cflags + ' -DUWSGI_SPOOLER ' + cflags.append("-DUWSGI_SPOOLER") + gcc_list.append('spooler') + +version = sys.version_info +uver = "%d.%d" % (version[0], version[1]) -if sys.argv[1] == '--cflags': - print(cflags) -else: - print(ldflags) +if __name__ == "__main__": + if sys.argv[1] == '--cflags': + print(' '.join(cflags)) + if sys.argv[1] == '--ldflags': + print(' '.join(ldflags)) + elif sys.argv[1] == '--build': + build_uwsgi(UWSGI_BIN_NAME, uver, cflags, ldflags)