Git Product home page Git Product logo

buildout.recipe.uwsgi's Introduction

buildout.recipe.uwsgi

This is a zc.buildout recipe for downloading, installing and configuring uWSGI inside a buildout. It compiles an uWSGI executable in bin/ and a configuration file (xml or ini) in parts/.

Forked from shaunsephton.recipe.uwsgi .

Changelog

0.1.2

  • Change download URL to https://.
  • Fixed incorrect working of is_uwsgi_installed() under Python 3 (issue #29)

0.1.1

  • Fixed encoding-related exception when building in an environment without the LANG, LC_* variables set (issue #25)

0.1.0

  • Merged some documentation fixes
  • Merged fixes for format strings (python 2.6)

0.0.25

  • Added a new configuration option output-format which can be used to specify what kind of configuration file to create (xml - default, or ini)
  • xml-* option have been deprecated in favor of config-*; using the former will cause a warning.

0.0.24

  • For the paranoid: Add option md5sum to force checksum validation of downloaded tarball.

0.0.23

  • Correctly splitting on '\n' when dealing with multiline options

0.0.22

  • Using subprocess.check_call for compatibility with Python 2.6

0.0.21

  • Check if you need to rebuild uwsgi when updating buildout (which didn't work before because update didn't return the list of installed paths).
  • Always delete the build directory (even in case of errors).
  • Call uwsgiconfig.py instead of make to install uWSGI. This let you choose which python you want to use.
  • Check the version of uwsgi if it is already installed.
  • Add an option to configure the path of the generated uWSGI configuration file.

0.0.20

  • Fixed download cache issue; if download-cache is present in the [buildout] section, it will be used for caching the source archive of uwsgi after download

0.0.19

  • Setting the PYTHON_BIN env variable to the current python interpreter (for building uwsgi with the right interpreter)

0.0.18

  • Fixed issue #11

0.0.17

  • Add option "pythonpath-eggs-directory" to tweak base directory of generated pythonpath configuration directives

0.0.16

  • Documentation enhancements

0.0.15

  • Add option download-url to configure non-vanilla download url

0.0.14

  • Extra-paths fixes

0.0.13

  • Minor code/documentation cleanups

0.0.12

  • Fixed a bug when using 'use-system-binary' (was working backwards)
  • Fixed build process when the part's name was something other than 'uwsgi'

0.0.11

  • New option, use-system-binary, to skip building uwsgi

0.0.10

  • Added the version option to allow downloading a specific version of uwsgi
  • Added the possibility of specifying a certain build profile
  • Options that should go in the generated .xml file should be xml- prefixed

Usage

Add a part to your buildout.cfg like this:

[buildout]
parts=uwsgi

[uwsgi]
recipe=buildout.recipe.uwsgi

Running the buildout will download and compile uWSGI and add an executable with the same name as your part in the bin/ directory (e.g. bin/uwsgi). It will also create a uwsgi.xml configuration file in a parts directory with the same name as your part (e.g. parts/uwsgi/uwsgi.xml).

uwsgi can then be started like:

$ ./bin/uwsgi --xml parts/uwsgi/uwsgi.xml

By configuring the output-format option, you can select other configuration file formats, such as ini.

Configuration options

You can specify a number of options for this recipe, for "fine-tuning" the build process. Below is an example of all possible options that can appear in the buildout file:

[buildout]
parts=uwsgi

[uwsgi]
recipe=buildout.recipe.uwsgi
download-url=http://projects.unbit.it/downloads/uwsgi-{0}.tar.gz
version=1.2.5
md5sum=d23ed461d1848aee4cfa16bde247b293
output=${buildout:directory}/parts/uwsgi/uwsgi.ini
output-format=ini
profile=default.ini
use-system-binary=1
config-socket=127.0.0.1:7001
config-module=my_uwsgi_package.wsgi
config-master=True
download-url
Specifies the url where uWSGI's source code should be downloaded from. {0} inside this url will be replaced by the value of the version option. The default value of download-url is http://projects.unbit.it/downloads/uwsgi-{0}.tar.gz
version
Version of uWSGI to download (default is latest).
md5sum
MD5 checksum for the source tarball. An error will be raised upon mismatch. If left unset no check is performed.
output
Path where the uWSGI configuration file is generated (defaults to a file called {name of the part}.{output-format} in the parts directory).
output-format
What kind of uWSGI configuration file to generate (xml or ini).
profile
uWSGI has profiles (build configurations) which can be used to configure which plugins will be built with uWSGI (see https://github.com/unbit/uwsgi/tree/master/buildconf). Default is default.ini. If the specified profile is an absolute path, then that is going to be used, otherwise the profile configuration is searched in uwsgi's source folder (buildconf/), finally falling back to the current directory (where buildout is invoked from).
use-system-binary
It is possible to use an "external" uwsgi binary (installed by the OS' package manager or compiled manually) and just let the recipe generate the xml configuration file only (no building uWsgi). Default is False.
pythonpath-eggs-directory

By default, the configuration generator will use absolute paths to python eggs, usually inside buildout:eggs-directory by calling zc.recipe.egg.Egg(...).working_set(). To support setups which require using the option relative-paths = true, this option allows to tweak the base directory of generated uwsgi pythonpath configuration directives, e.g.:

pythonpath-eggs-directory = /opt/vendor/product/python/eggs
config-*
Any option starting with config- will be stripped of this prefix and written to the configuration file specified by output, using output-format as format; for example, config-socket=127.0.0.1:7001 will be output as <socket>127.0.0.1:7001</socket> if output-format is xml.

Authors

Created By

  1. Shaun Sephton

Fork Maintainer

  1. Cosmin Luță lcosmin

Contributors

  1. mooball
  2. thefunny42
  3. rage2000
  4. Andreas Motl
  5. davidjb
  6. apoh
  7. Jeff Dairiki
  8. wiseteck
  9. Bernardo Torres

buildout.recipe.uwsgi's People

Contributors

amotl avatar apoh avatar bernardotorres avatar cykooz avatar dairiki avatar davidjb avatar lcosmin avatar mooball avatar sergeyv avatar thefunny42 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

buildout.recipe.uwsgi's Issues

0.0.14 can't be installed from pypi

Seems like the tar file uploaded to pypi is broken - pypi shows it as "dumb binary". I've downloaded the file and it looks like the problem is caused by the "absolute path" stored in the tarball - it contains nested directories - usr, local, lib, python2.7, dist-packages etc.

the new release is not seen by buildout, it only can download 0.0.13

Fix parsing of duplicate sections

When you specify multiple duplicate configurations like uWSGI env

[some_uwsgi]
recipe = buildout.recipe.uwsgi
config-env = VAR1=true
config-env = VAR2=SOME OTHER VALUE
config-env = VAR3=3333

Buildout only takes the last item of config-env = VAR3=333.

Looking around for some time found that we can override OrderedDict and provide it as a dict_type

class MultiOrderedDict(OrderedDict):
    def __setitem__(self, key, value):
        if isinstance(value, list) and key in self:
            self[key].extend(value)
        else:
            super(MultiOrderedDict, self).__setitem__(key, value)

Creating a uWSGI ini file rather than an XML file

This recipe is great, but I need to generate an ini configuration as output rather than an XML configuration. I've come across some form of conflict (unbit/uwsgi#779) between uWSGI's XML loader and the code I'm running, and hence I need the uWSGI config to be ini-based.

I'm happy to create a pull request, just want to code it in such a way it fits in (aka be acceptable). I could see this being a potential plan:

  • Checking the output option for its file extension
  • Using the above to run a specific function, either create_conf_xml or a new create_conf_ini to create the file
  • Genericise the xml- prefix for buildout options to be uwsgi- (since there are other config formats, such as YAML). Backwards compatibility would be maintained by checking xml- as a additional prefix.
  • Write the file out according to the output file path.

Thoughts?

UTF-8 Problem with Docker+Python3

Using ENV LANG/LC_ALL/LANGUAGE=en_US.UTF-8 didn't work either.

Getting distribution for 'buildout.recipe.uwsgi==0.1.0'.
Traceback (most recent call last):
File "/pony/build/lib/python3.4/site-packages/setuptools/sandbox.py", line 152, in save_modules
yield saved
File "/pony/build/lib/python3.4/site-packages/setuptools/sandbox.py", line 193, in setup_context
yield
File "/pony/build/lib/python3.4/site-packages/setuptools/sandbox.py", line 237, in run_setup
DirectorySandbox(setup_dir).run(runner)
File "/pony/build/lib/python3.4/site-packages/setuptools/sandbox.py", line 267, in run
return func()
File "/pony/build/lib/python3.4/site-packages/setuptools/sandbox.py", line 236, in runner
_execfile(setup_script, ns)
File "/pony/build/lib/python3.4/site-packages/setuptools/sandbox.py", line 46, in _execfile
exec(code, globals, locals)
File "/tmp/easy_install-qziqo4v7/buildout.recipe.uwsgi-0.1.0/setup.py", line 8, in
File "/pony/build/lib/python3.4/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc8 in position 6189: ordinal not in range(128)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/pony/build/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 2243, in main
distclass=DistributionWithoutHelpCommands, *_kw
File "/usr/lib/python3.4/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.4/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/pony/build/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 380, in run
self.easy_install(spec, not self.no_deps)
File "/pony/build/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 610, in easy_install
return self.install_item(None, spec, tmpdir, deps, True)
File "/pony/build/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 659, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/pony/build/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 842, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/pony/build/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 1070, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/pony/build/lib/python3.4/site-packages/setuptools/command/easy_install.py", line 1056, in run_setup
run_setup(setup_script, args)
File "/pony/build/lib/python3.4/site-packages/setuptools/sandbox.py", line 240, in run_setup
raise
File "/usr/lib/python3.4/contextlib.py", line 77, in exit
self.gen.throw(type, value, traceback)
File "/pony/build/lib/python3.4/site-packages/setuptools/sandbox.py", line 193, in setup_context
yield
File "/usr/lib/python3.4/contextlib.py", line 77, in exit
self.gen.throw(type, value, traceback)
File "/pony/build/lib/python3.4/site-packages/setuptools/sandbox.py", line 164, in save_modules
saved_exc.resume()
File "/pony/build/lib/python3.4/site-packages/setuptools/sandbox.py", line 139, in resume
compat.reraise(type, exc, self._tb)
File "/pony/build/lib/python3.4/site-packages/setuptools/compat.py", line 65, in reraise
raise value.with_traceback(tb)
File "/pony/build/lib/python3.4/site-packages/setuptools/sandbox.py", line 152, in save_modules
yield saved
File "/pony/build/lib/python3.4/site-packages/setuptools/sandbox.py", line 193, in setup_context
yield
File "/pony/build/lib/python3.4/site-packages/setuptools/sandbox.py", line 237, in run_setup
DirectorySandbox(setup_dir).run(runner)
File "/pony/build/lib/python3.4/site-packages/setuptools/sandbox.py", line 267, in run
return func()
File "/pony/build/lib/python3.4/site-packages/setuptools/sandbox.py", line 236, in runner
_execfile(setup_script, ns)
File "/pony/build/lib/python3.4/site-packages/setuptools/sandbox.py", line 46, in execfile
exec(code, globals, locals)
File "/tmp/easy_install-qziqo4v7/buildout.recipe.uwsgi-0.1.0/setup.py", line 8, in
File "/pony/build/lib/python3.4/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc8 in position 6189: ordinal not in range(128)
An error occurred when trying to install buildout.recipe.uwsgi 0.1.0. Look above this message for any errors that were output by easy_install.
While:
Installing.
Getting section uwsgi.
Initializing section uwsgi.
Installing recipe buildout.recipe.uwsgi==0.1.0.
Getting distribution for 'buildout.recipe.uwsgi==0.1.0'.
Error: Couldn't install: buildout.recipe.uwsgi 0.1.0
Makefile:52: recipe for target 'build/buildout.cfg' failed
make: *
* [build/buildout.cfg] Error 1
INFO[0218] The command [/bin/sh -c make] returned a non-zero code: 2

Compiling custom uWSGI / using existing CMMI recipe

I've come to needing to customise my environment ($PATH specifically) when installing uWSGI such that it is able to locate a custom installed version of libxml2 (installed via Buildout) and build against that. This is somewhat easily solved by setting the $PATH either before running Buildout (or using collective.recipe.environment) - thought not easily reproducible or necessarily easily managed.

This lead me to thinking about the potential of having this recipe leverage another that can offload the downloading, configuring and installing uWSGI. buildout.recipe.uwsgi is effectively doing cmmi, so my thinking behind this is to reduce code duplication (downloading/extraction/compilation/removal done already), and inline with my actual issue, allow full configuration of the build process. For instance, extending off https://pypi.python.org/pypi/hexagonit.recipe.cmmi#supported-options would give environment as an option, and many others, allowing for fine grained control over how uWSGI gets built. There are other cmmi recipes out there too, but that one seemed to be one of the most featureful/active at present.

Thoughts?

`instal' function does not install uwsgi

the return value of self.options.get("use-system-binary", False) is a string, not a boolean, so 'if not self.options.get("use-system-binary", False)' is always False unless set use-system-binary as a empty string in buildout.cfg

Make uwsgi python modules available

After the uWSGI binary is built, it would be nice to have an option to make the uwsgi python modules (uwsgi, uwsgidecorators) added to the python path, both for bin/python and the the XML configuration file.

recipe's uwsgi won't point to the proper interpreter - none of my libs get picked up

Here's my buildout:

[buildout]
show-picked-versions=true
eggs-directory = /home/vagrant/.buildout/eggs
download-cache = /home/vagrant/.buildout/dlcache
bin-directory = ${buildout:directory}/bin
parts =
depends
uwsgi
app
develop = ./src

[versions]

[depends]
recipe = minitage.recipe:egg
eggs =
zope.component
zope.interface
zope.site
zope.event
eye

[uwsgi]
interpreter = uwsgipy
recipe=buildout.recipe.uwsgi
pythonpath-eggs-directory=${buildout:directory}/eggs
xml-http=192.168.4.100:9090
xml-wsgi-file=./src/gis/init.py
xml-logto=./uwsgi.log
xml-pythonpath=./bin/uwsgipy

[app]
recipe = minitage.recipe:scripts
interpreter = uwsgipy
extra-paths = ${buildout:directory}/eggs
eggs =
${depends:eggs}

Custom plugins for uwsgi

Have you given any thought to allowing the selection of (or addition of) custom plugins for uWSGI to this buildout recipe? For instance, something like CGI support isn't available in the default configuration of uWSGI.

Adding such support in isn't overly complicated (eg involves calling python uwsgiconfig.py --plugin plugins/cgi (or similar, for other plugins or configurations) within the downloaded uWSGI distribution, but I'm unsure how to hook into that within how this recipe is configured at present. I'm unsure if zc.recipe.egg would support configuration like this.

Fix use-system-binary

use-system-binary doesn't check if there actually is an uwsgi binary installed in the system.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.