Browse Source

Package software.

* Add setup.py
* Integrate with pytest-runner
* Remove requirements_dev.txt
* Rework console scripts to produce binaries with distro
* Adapt travis.yml
Stefano Cossu 6 years ago
parent
commit
f0248dee52
11 changed files with 177 additions and 53 deletions
  1. 2 3
      .travis.yml
  2. 0 32
      etc.defaults/gunicorn.py
  3. 24 0
      etc.defaults/gunicorn.yml
  4. 0 5
      fcrepo
  5. 0 1
      lsup_admin.py
  6. 3 3
      profiler.py
  7. 11 1
      requirements.txt
  8. 0 6
      requirements_dev.txt
  9. 0 2
      server.py
  10. 6 0
      setup.cfg
  11. 131 0
      setup.py

+ 2 - 3
.travis.yml

@@ -3,7 +3,6 @@ python:
   - "3.5"
   - "3.6"
 install:
-  - pip install -r requirements.txt
-  - coilmq&
+  - pip -e .
 script:
-- pytest tests
+  - python setup.py test

+ 0 - 32
etc.defaults/gunicorn.py

@@ -1,32 +0,0 @@
-# See: http://docs.gunicorn.org/en/stable/settings.html
-
-# Directory where to store logs, PIDfile, etc.
-_data_dir = 'data/'
-
-# Set app_mode to either 'prod', 'test' or 'dev'.
-# 'prod' is normal running mode. 'test' is used for running test suites.
-# 'dev' is similar to normal mode but with reload and debug enabled.
-_app_mode = 'dev'
-
-
-bind = "0.0.0.0:8000"
-workers = 4
-worker_class = 'gevent'
-max_requests = 512
-
-#user = "user"
-#group = "group"
-
-raw_env = 'APP_MODE={}'.format(_app_mode)
-
-# Set this to the directory containing logs, etc.
-# The path must end with a slash.
-#chdir = "/usr/local/lakesuperior/"
-
-daemon = _app_mode=='prod'
-pidfile = _data_dir + "run/fcrepo.pid"
-reload = _app_mode=='dev'
-
-accesslog = _data_dir + "log/gunicorn-access.log"
-errorlog = _data_dir + "log/gunicorn-error.log"
-

+ 24 - 0
etc.defaults/gunicorn.yml

@@ -0,0 +1,24 @@
+# Set up main GUnicorn options.
+# See: http://docs.gunicorn.org/en/stable/settings.html
+
+# Commented values are the application defaults.
+
+# Directory where the WSGI server data are stored.
+data_dir: 'data'
+
+# Set app_mode to either 'prod', 'test' or 'dev'.
+# 'prod' is normal running mode. 'test' is used for running test suites.
+# 'dev' is similar to normal mode but with reload and debug enabled.
+app_mode: 'dev'
+
+#listen_addr: '0.0.0.0'
+#listen_port: 8000
+#workers: 4
+#worker_class: 'gevent'
+#max_requests: 512
+
+#user: ''
+#group: ''
+
+#preload_app: True
+

+ 0 - 5
fcrepo

@@ -1,5 +0,0 @@
-#!/bin/bash
-default_conf_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/etc.defaults"
-conf_dir=${FCREPO_CONFIG_DIR:-$default_conf_dir}
-
-gunicorn -c "${conf_dir}/gunicorn.py" server:fcrepo --preload

+ 0 - 1
lsup-admin → lsup_admin.py

@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 import click
 import click_log
 import json

+ 3 - 3
profiler.py

@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
 import logging
 from logging.config import dictConfig
 from werkzeug.contrib.profiler import ProfilerMiddleware
@@ -18,9 +16,11 @@ options = {
 
 from lakesuperior.app import create_app
 
-if __name__ == '__main__':
+def run():
     fcrepo = create_app(config['application'])
     fcrepo.wsgi_app = ProfilerMiddleware(fcrepo.wsgi_app, **options)
     fcrepo.config['PROFILE'] = True
     fcrepo.run(debug = True)
 
+if __name__ == '__main__':
+    run()

+ 11 - 1
requirements.txt

@@ -1,14 +1,24 @@
 CoilMQ==1.0.1
 Flask==0.12.2
 HiYaPyCo==0.4.11
+Pillow==4.3.0
 PyYAML==3.12
 arrow==0.10.0
-click==6.7
 click-log==0.2.1
+click==6.7
 gevent==1.2.2
 gunicorn==19.7.1
 lmdb==0.93
+numpy==1.14.1
+pytest-flask==0.10.0
+pytest==3.2.2
 rdflib==4.2.2
 requests-toolbelt==0.8.0
 requests==2.18.4
+sphinx-rtd-theme==0.2.4
 stomp.py==4.1.20
+wheel==0.30.0a0
+
+# Uncomment this and remove all above when the project will be in PyPI.
+#--index-url https://pypi.python.org/lakesuperior/
+#-e .

+ 0 - 6
requirements_dev.txt

@@ -1,6 +0,0 @@
-Pillow==4.3.0
-numpy==1.14.1
-pytest==3.2.2
-pytest-flask==0.10.0
-sphinx-rtd-theme==0.2.4
-wheel==0.30.0a0

+ 0 - 2
server.py

@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
 import logging
 from logging.config import dictConfig
 

+ 6 - 0
setup.cfg

@@ -0,0 +1,6 @@
+[aliases]
+test = pytest
+
+[tool:pytest]
+addopts = --verbose
+#python_files = tests

+ 131 - 0
setup.py

@@ -0,0 +1,131 @@
+"""
+LAKEsuperior setup script.
+
+Proudly ripped from https://github.com/pypa/sampleproject/blob/master/setup.py
+"""
+
+import sys
+
+# Always prefer setuptools over distutils
+from setuptools import setup, find_packages
+# To use a consistent encoding
+from codecs import open
+from os import path
+
+here = path.abspath(path.dirname(__file__))
+
+# ``pytest_runner`` is referenced in ``setup_requires``.
+# See https://github.com/pytest-dev/pytest-runner#conditional-requirement
+needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
+pytest_runner = ['pytest-runner'] if needs_pytest else []
+
+
+# Get the long description from the README file
+with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
+    long_description = f.read()
+
+setup(
+    name='lakesuperior',
+    version='1.0.0a9pre1',
+
+    description='A Linked Data Platform repository sever.',
+    long_description=long_description,
+    long_description_content_type='text/x-rst; charset=UTF-8',
+
+    url='https://lakesuperior.readthedocs.io',
+
+    author='Stefano Cossu <@scossu>',
+    #author_email='',  # Optional
+    license='Apache License Version 2.0',
+
+    # https://pypi.python.org/pypi?%3Aaction=list_classifiers
+    classifiers=[
+        'Development Status :: 3 - Alpha',
+
+        'Environment :: Console',
+        'Environment :: Web Environment',
+
+        'Framework :: Flask',
+
+        'Intended Audience :: Developers',
+        'Intended Audience :: Information Technology',
+        'Intended Audience :: Science/Research',
+
+        'License :: OSI Approved :: Apache Software License',
+
+        'Natural Language :: English',
+
+        'Operating System :: MacOS',
+        'Operating System :: Microsoft :: Windows',
+        'Operating System :: POSIX :: Linux',
+
+        'Programming Language :: Python :: 3',
+        'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python :: 3.6',
+
+        'Topic :: Database :: Database Engines/Servers',
+    ],
+
+    keywords='repository linked-data',
+
+    python_requires='~=3.5',
+
+    packages=find_packages(exclude=['contrib', 'docs', 'tests']),
+
+    # Great reference read about dependency management:
+    # https://caremad.io/posts/2013/07/setup-vs-requirement/
+    install_requires=[
+        'CoilMQ',
+        'Flask',
+        'HiYaPyCo',
+        'PyYAML',
+        'arrow',
+        'click',
+        'click-log',
+        'gevent',
+        'gunicorn',
+        'lmdb',
+        'rdflib',
+        'requests',
+        'requests-toolbelt',
+        'sphinx-rtd-theme',
+        'stomp.py',
+    ],
+
+    setup_requires=[] + pytest_runner,
+    tests_require=[
+        'Pillow',
+        'numpy',
+        'pytest',
+        'pytest-flask',
+    ],
+
+    #extras_require={},
+    #package_data={},
+    #data_files=[],
+
+    entry_points={
+        'console_scripts': [
+            'lsup-admin=lsup_admin:admin',
+            'profiler=profiler:run',
+            'fcrepo=wsgi:run',
+        ],
+    },
+
+    # List additional URLs that are relevant to your project as a dict.
+    #
+    # This field corresponds to the "Project-URL" metadata fields:
+    # https://packaging.python.org/specifications/core-metadata/#project-url-multiple-use
+    #
+    # Examples listed include a pattern for specifying where the package tracks
+    # issues, where the source is hosted, where to say thanks to the package
+    # maintainers, and where to support the project financially. The key is
+    # what's used to render the link text on PyPI.
+    project_urls={  # Optional
+        'Source Code': 'https://github.com/scossu/lakesuperior/',
+        'Documentation': 'https://lakesuperior.readthedocs.io',
+        'Discussion': 'https://groups.google.com/forum/#!forum/lakesuperior',
+        'Bug Reports': 'https://github.com/scossu/lakesuperior/issues',
+    }
+)
+