etsy/skyline — pull request #93 by languitar (2014-06-17 16:23:11+00:00)
Title: Provide a setuptools-based build infrastructure

Included in this pull request is a complete build system based on setuptools, as I requested in #91. I suspect there will be a lot of questions or doubts about such a big change, but I am happy to answer them. So I'd really be glad if this would be accepted eventually.

# commit message

This rather longish commit provides a complete build infrastructure
based on setuptools that allows to install skyline like any other python
application.

For setuptools to work correctly, a few fundamental changes had to be
made apart from minor fixes. The most fundamental changes are:

* Inside the src directory a dedicated skyline folder / package has been
created to ensure that the skyline classes do not interfere with other
python packages.
* The python scripts called by the bash scripts that encapsulate the
real functionality of skyline are now generated by setuptools. For
this to work the scripts had to be converted to real modules, which
means that a dash in the name was not acceptable. In case anyone has used
these scripts directly, the name has now changed. It might be possible
to restore the behavior by adding symlinks or small bash wrapper
scripts inside the src tree, but this isn't done so far. The general
bash scripts in bin reflect the changed names.
* The settings.py.example has been renamed to settings.py so that
setuptools can directly execute the unit tests without requiring user
interaction. In the future, providing a settings.py with defaults that do
not require any user interaction, might make skyline completely usable
out of the box.

In detail, the following changes have been made:

* .gitignore: added stuff generated by setuptools, removed settings.py,
which is now part of the distribution so that unit tests can execute
without user interaction
* .travis.yml: updated to new build system. Unit tests now executed
through setup.py. Calling nose is still posible, though
* MANIFEST.in: added a setuptools manifest to package the static files
for the webapp
* bin/\*.d: updated to new script names for in-source use. Moreover, an
if-else branch was added to decided whether the scripts should call
the python files directly when called inside the source tree, or the
generated setuptools wrapper scripts in case of a real installation
* setup.cfg: contains settings for running the nose tests from within
setuptools by calling python setup.py test
* setup.py: The real build system logic. Some values are quite empty
still, since I do not know the correct contents. Please updated
accordingly.
* src: moved all files to skyline package, made every folder a python
package by adding an \_\_ini\_\_.py file to be discoverable by setuptools.
* src/\*/\*-agent.py: renamed to agent.py to have a python module name so
that setuptools can use these modules as entry point for console
scripts. Moreover, executed script contents were moved to a run
function which is then callable as a setuptools entry point. Module
main functionality has been preserved by calling the run function inside
the main block. Several smaller content changes had to be made to
preserve the functionality after these changes.
* src/\*.py, tests/\*.py: Manual changes to the pythonpath have been removed since
with a real package structure, everything is now done automatically by
python and for testing by the setuptools nose integration.
* webapp.py: added a route to server anomalies.json from any configured
location to /anomalies.json. This is necessary, since users should not
modify the contents of the installed python egg just to push the
updated anomaly detections to a path that is served by the webserver.
* skyline.js: Fetch anomalies from /anomalies.json as described above.
This enables the user to specify any location he wants for the
generated json file.
* horizon/listen.py: Explicitly added the StringIO import. No idea how
this could work before.
* utils/\*.py: Updated imports to reflect new package structure