<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Weird rocketry &#187; patching</title>
	<atom:link href="http://webapp.org.ua/tag/patching/feed" rel="self" type="application/rss+xml" />
	<link>https://webapp.org.ua</link>
	<description>Flights to outer code</description>
	<lastBuildDate>Sat, 16 Jul 2016 11:12:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Compiling uWSGI from sources</title>
		<link>https://webapp.org.ua/dev/compiling-uwsgi-from-sources/</link>
		<comments>https://webapp.org.ua/dev/compiling-uwsgi-from-sources/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 08:33:47 +0000</pubDate>
		<dc:creator>bananos</dc:creator>
				<category><![CDATA[dev]]></category>
		<category><![CDATA[compile]]></category>
		<category><![CDATA[libxml2]]></category>
		<category><![CDATA[patching]]></category>
		<category><![CDATA[uwsgi]]></category>

		<guid isPermaLink="false">http://webapp.org.ua/?p=86</guid>
		<description><![CDATA[&#160; As you probably know, uWSGI is a fast application container for serving your webapps. It is often used with Django against nginx webserver. Written in pure C &#38; having a lot of other cool features. It seems that installation of uWSGI is pretty simple according to official docs but it isn&#8217;t. If you want [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-88" src="http://webapp.org.ua/wp-content/uploads/2011/06/logo_uWSGI.png" title="logo_uWSGI"  alt="uWSGI" width="236" height="73" /></p>
<p>&nbsp;</p>
<p>As you probably know,  uWSGI is a fast application container for serving your webapps. It is often used with <a href="www.djangoproject.com/">Django</a> against <a href="nginx.org">nginx</a> webserver. Written in pure C &amp; having a lot of other <a href="http://projects.unbit.it/uwsgi/wiki">cool features</a>.</p>
<p>It seems that installation of uWSGI is pretty simple according to <a href="http://projects.unbit.it/uwsgi/wiki/Install">official docs</a> but it isn&#8217;t.<br />
<span id="more-86"></span></p>
<p>If you want to deploy your Django app on a brand new linux box (VPS/Amazon EC2), using buildout without a lot of dependencies things become more complicated.</p>
<p>Here is how you can tune up your uWSGI:</p>
<pre><code class="no-highlight">wget http://projects.unbit.it/downloads/uwsgi-0.9.7.2.tar.gz
tar -xvvf  uwsgi-0.9.7.2.tar.gz
cd uwsgi-0.9.7.2</code></pre>
<p>If  you&#8217;ll simply run <code>make</code> as this point, you&#8217;ll experience  something like this:</p>
<pre><code> *** libxml2 headers unavailable. uWSGI build is interrupted. You have to install libxml2 development package or use libexpat or disable XML </code></pre>
<p>Since uWSGI needs libxml2 for reading XML configs, which is only one of the available configuration options (<a href="http://projects.unbit.it/uwsgi/wiki/Doc">command line</a>, <a href="http://projects.unbit.it/uwsgi/wiki/UseEnv">environment variables</a>, <a href="http://projects.unbit.it/uwsgi/wiki/Example">XML</a>, <a href="http://projects.unbit.it/uwsgi/wiki/INIFiles">.ini</a>, yaml files and via <a href="http://projects.unbit.it/uwsgi/wiki/useLDAP">LDAP</a>.), we&#8217;re going to drop this dependency (I&#8217;m more comfortable with command-line style)</p>
<p>It&#8217;s not obvious how to drop libxml2 dependency, because there&#8217;s no configure &amp; usual C-style make. Instead, build is fully controlled by <code>uwsgiconfig.py</code> script, which you can grok for a while to get a grasp on how the whole process works.</p>
<p>Build options are stored in <code>buildconf/ folder</code>:</p>
<pre><code class="no-highlight">root@devbox:~/server/thirdparty/uwsgi-0.9.7.2# ls -l buildconf/
total 64
-rw-r--r-- 1 root root  50 Apr  6 10:50 core.ini
-rw-r--r-- 1 root root 497 Apr  6 10:50 default.ini
-rw-r--r-- 1 root root  54 Apr  6 10:50 erlang.ini
-rw-r--r-- 1 root root  49 Apr  6 10:50 lua.ini
-rw-r--r-- 1 root root  40 Apr  6 10:50 luap.ini
-rw-r--r-- 1 root root 485 Apr  6 10:50 modular.ini
-rw-r--r-- 1 root root  78 Apr  6 10:50 package.ini
-rw-r--r-- 1 root root  50 Apr  6 10:50 psgi.ini
-rw-r--r-- 1 root root  60 Apr  6 10:50 pyerl.ini
-rw-r--r-- 1 root root  86 Apr  6 10:50 pylua.ini
-rw-r--r-- 1 root root 462 Apr  6 10:50 pyrb.ini
-rw-r--r-- 1 root root  69 Apr  6 10:50 rack.ini
-rw-r--r-- 1 root root 449 Apr  6 10:50 rackp.ini
-rw-r--r-- 1 root root 377 Apr  6 10:50 unbit.ini
-rw-r--r-- 1 root root 108 Apr  6 10:50 unbitstaff.ini</code></pre>
<p>For our customized build we&#8217;ll create a new build config, called <code>myproject.ini</code>:</p>
<pre><code class="no-highlight">root@devbox:~/server/thirdparty/uwsgi-0.9.7.2/buildconf# cp default.ini myproject.ini </code></pre>
<p>He&#8217;re how internals should look like if you want to turn off libxml2 support:</p>
<pre><code class="ini">
[uwsgi]
xml = false
ini = true
yaml = true
snmp = true
sctp = false
spooler = true
embedded = true
udp = true
multicast = true
threading = true
sendfile = true
minterpreters = true
async = true
evdis = false
ldap = auto
pcre = auto
debug = false
unbit = false
; xml_implementation = libxml2
plugins =
bin_name = uwsgi
plugin_dir = .
embedded_plugins = python, ping, nagios, rpc, fastrouter, http, ugreen

locking = auto
event = auto
timer = auto
filemonitor = auto

[python]
paste = true
web3 = true
</code></pre>
<p>At this point you&#8217;re ready to type</p>
<pre><code class="no-highlight"> python uwsgiconfig.py --build myproject </code></pre>
<p>In theory this should build you a brand-new uWSGI, but only in theory. Probably, what you&#8217;ll get by doing above command will be:</p>
<pre><code class="no-highlight">using profile: buildconf/myproject.ini
*** uWSGI compiling server core ***
gcc -pthread -c utils.c -o utils.o -O2 -Wall -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -fno-strict-aliasing -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -DUWSGI_BUILD_DATE="\"03 June 2011 09:10:42\"" -DUWSGI_LOCK_USE_MUTEX -DUWSGI_EVENT_USE_EPOLL -DUWSGI_EVENT_TIMER_USE_TIMERFD -DUWSGI_EVENT_FILEMONITOR_USE_INOTIFY
gcc -pthread -c protocol.c -o protocol.o -O2 -Wall -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -fno-strict-aliasing -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -DUWSGI_BUILD_DATE="\"03 June 2011 09:10:42\"" -DUWSGI_LOCK_USE_MUTEX -DUWSGI_EVENT_USE_EPOLL -DUWSGI_EVENT_TIMER_USE_TIMERFD -DUWSGI_EVENT_FILEMONITOR_USE_INOTIFY
gcc -pthread -c socket.c -o socket.o -O2 -Wall -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -fno-strict-aliasing -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -DUWSGI_BUILD_DATE="\"03 June 2011 09:10:42\"" -DUWSGI_LOCK_USE_MUTEX -DUWSGI_EVENT_USE_EPOLL -DUWSGI_EVENT_TIMER_USE_TIMERFD -DUWSGI_EVENT_FILEMONITOR_USE_INOTIFY
gcc -pthread -c logging.c -o logging.o -O2 -Wall -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -fno-strict-aliasing -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -DUWSGI_BUILD_DATE="\"03 June 2011 09:10:42\"" -DUWSGI_LOCK_USE_MUTEX -DUWSGI_EVENT_USE_EPOLL -DUWSGI_EVENT_TIMER_USE_TIMERFD -DUWSGI_EVENT_FILEMONITOR_USE_INOTIFY
gcc -pthread -c master.c -o master.o -O2 -Wall -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -fno-strict-aliasing -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -DUWSGI_BUILD_DATE="\"03 June 2011 09:10:42\"" -DUWSGI_LOCK_USE_MUTEX -DUWSGI_EVENT_USE_EPOLL -DUWSGI_EVENT_TIMER_USE_TIMERFD -DUWSGI_EVENT_FILEMONITOR_USE_INOTIFY
cc1: warnings being treated as errors
master.c: In function ‘uwsgi_subscribe’:
master.c:74: error: implicit declaration of function ‘send_udp_message’</code></pre>
<p>and your build will miserably fail</p>
<p>To fix that, you need to edit  <code>uwsgiconfig.py</code>, find following line:</p>
<pre><code class="python">self.cflags = ['-O2', '-Wall', '-Werror', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64'] + os.environ.get("CFLAGS", "").split()</code></pre>
<p>and remove <code> -Werror </code></p>
<p>In case you want to do it automatically by your deployment scripts, here is a small sed snippet:</p>
<pre><code class="no-highlight">sed  -ie "s#'-Werror',##g" uwsgiconfig.py</code></pre>
<p>After patching <code>uwsgiconfig.py </code> you&#8217;re ready to rock&amp;roll:</p>
<pre> <code class="no-highlight"> python uwsgiconfig.py --build myproject</code></pre>
]]></content:encoded>
			<wfw:commentRss>https://webapp.org.ua/dev/compiling-uwsgi-from-sources/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
