-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(package) upgrade to modern packaging (#6)
** FEATURE DETAILS ** - Introduce the following recent packaging good practices: - move package metadata to setup.cfg - move requirements to setup.cfg - check setup.cfg quality with pyroma - Add PyPI configuration to upload Fonzie package upon tagging - Update installation documentation ** TODO ** Document the Fun-platform way to install a third-party Django application (using Docker).
- Loading branch information
Showing
22 changed files
with
161 additions
and
392 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,30 @@ | ||
# Config file for automatic testing at travis-ci.org | ||
sudo: required | ||
|
||
language: python | ||
|
||
cache: | ||
directories: | ||
- $HOME/.cache/db | ||
- node_modules | ||
|
||
- "$HOME/.cache/db" | ||
- node_modules | ||
env: | ||
- TOXENV=quality | ||
- TOXENV=docs | ||
- TOXENV=django18 | ||
- API_SPEC=1 OPENEDX_RELEASE=ginkgo.1 | ||
|
||
- TOXENV=quality | ||
- TOXENV=docs | ||
- TOXENV=django18 | ||
- API_SPEC=1 OPENEDX_RELEASE=ginkgo.1 | ||
before_install: | ||
# Upgrade docker-compose | ||
- bin/ci before-install | ||
|
||
- bin/ci before-install | ||
install: | ||
- bin/ci install | ||
|
||
- bin/ci install | ||
script: | ||
- bin/ci script | ||
|
||
- bin/ci script | ||
after_success: | ||
- bin/ci after-success | ||
|
||
# Set password via "travis encrypt --add deploy.password"; for details, see | ||
# https://docs.travis-ci.com/user/deployment/pypi | ||
- bin/ci after-success | ||
deploy: | ||
provider: pypi | ||
user: edx | ||
user: openfun | ||
distributions: sdist bdist_wheel | ||
on: | ||
tags: true | ||
condition: '$TOXENV = quality' | ||
condition: "$TOXENV = quality" | ||
# Encrypted password set via "travis encrypt --add deploy.password"; for | ||
# details, see https://docs.travis-ci.com/user/deployment/pypi | ||
password: | ||
secure: Oa6dtKi4mbJfMkduQmwZRwPH9Nu8FRJKas1xdaTfhrKlj0wr4+4IfEp0Vn9egyeamS94r06KlwSWN3c8PVIlPV7noUeewA5jAPYSdGbFCmOxNGgr3BQh1GL4mF/kxoQmG9GdeEoNOuBhbMtHOIbHIB8fH+ct8zCsNxW0xMjSRbioCEiQTD8FdDIPjXIg4W/cqJ08A1nFNhrVVSRV5gUa9LAH1S5eA9+GmyAB9kwSZXcbqF3imyRUpGPTLMGlb0qgrPLnCgtbh+GgyN5SFpL4USqrgjpNddCv9EYKgJ3ulALqPIuwbVgjt5KdYt/4cDpaHtc53lHpVpYsZmGCwcdizTvJgOZzaN9FAmJjdNdFBHBO0whb7QVrDE4rRmKqlMf5vTqFH15jkRZtRkyvHowjbBMUtJ2qsmNBVUWax20l/2RH3lwk2MW1goC1XrOg/eymjLSMAM97voIu1EO1RSql94avg/xXLRzfftjvqB4VvdJOPuXoZkJlKimiFPJP3O+yYubpBGBotabSRSGGBhRpOLD5vbRGdx4qI+gvCyiLlD0T4+pFQ+LXucD8Y/GrxT8CFWAM5lUMFGQQNikNizKQOxCnGZhRtyTzhwCZ84PmFr0XIrOYrxCvELCZlA1sUDptdx8W6gQbFF+znKrhLbffomd3dtpPRq/qo+CO7UVmxtg= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,85 @@ | ||
Getting Started | ||
=============== | ||
|
||
If you have not already done so, create/activate a `virtualenv`_. Unless otherwise stated, assume all terminal code | ||
below is executed within the virtualenv. | ||
Fonzie is supposed to be installed as a Django application running in an Open | ||
edX platform instance. Fonzie has been designed to be integrated with the | ||
current Open edX release (Ginkgo at the time of writing). We plan to support the | ||
next Open edX release (Hawthorn) in a near future. | ||
|
||
.. _virtualenv: https://virtualenvwrapper.readthedocs.org/en/latest/ | ||
Pre-requisites for Fonzie contributors | ||
-------------------------------------- | ||
|
||
|
||
Pre-requisites | ||
-------------- | ||
|
||
We are using `Dredd <http://dredd.readthedocs.io/en/latest/>`_ to test our API | ||
implementation. It requires `Node.js <https://nodejs.org/en/>`_ to run and we | ||
are using `Yarn <https://yarnpkg.com/en/>`_ to install it. So make sure both | ||
``node`` and ``yarn`` are installed and functionnal before pursuing this | ||
installation. | ||
We extensively use `Docker <https://docs.docker.com/install/>`_ (17.12+) and | ||
`Docker compose <https://docs.docker.com/compose/install/>`_ (1.18+) in our | ||
development workflow. So, if you intend to work on Fonzie, please, make sure they | ||
are both installed and functionnal before pursuing this installation. | ||
|
||
Install dependencies | ||
-------------------- | ||
|
||
Dependencies can be installed via `pip` in your project's virtual environment: | ||
|
||
.. code-block:: bash | ||
To install Fonzie in an Open edX project, two choices are offered depending on | ||
the way you are running your instance. If Open edX runs as a suite of Docker | ||
containers, Fonzie's development environment can serve as an example of how to | ||
integrate a Django application in `fun-platform | ||
<https://github.com/openfun/fun-platform>`_'s docker stack. Alternatively, if | ||
you are running Open edX on a bare metal server (or virtual machine), the | ||
installation protocol follows a standard Django procedure that will be described | ||
below. | ||
|
||
# Create a python 2.7 virtual environment | ||
$ virtualenv venv | ||
Standard procedure | ||
^^^^^^^^^^^^^^^^^^ | ||
|
||
# Activate your virtual environment | ||
$ source venv/bin/activate | ||
Install fonzie and its dependencies in your Open edX installation with ``pip``: | ||
|
||
# Install fonzie and its dependencies in your virtualenv | ||
(venv) $ pip install fonzie | ||
.. code-block:: bash | ||
Alternatively, if you intend to work on this project, clone the repository first and then | ||
install requirements _via_ the command below: | ||
$ (sudo) pip install fonzie | ||
.. code-block:: bash | ||
Docker procedure | ||
^^^^^^^^^^^^^^^^ | ||
|
||
$ git clone git@github.com:openfun/fonzie.git | ||
(venv) $ make requirements | ||
TODO | ||
|
||
Configure Fonzie | ||
---------------- | ||
|
||
Edit the settings of your project (_e.g._ ``my_project/settings.py``) by adding | ||
Once installed, Fonzie needs to be configured as a standard Django application, | ||
_i.e._ adding ``fonzie`` to your ``INSTALLED_APPS`` and Fonzie's URLs to your | ||
project's URLs. Achieving those two steps depends on the way you are running | ||
Open edX. | ||
|
||
Standard procedure | ||
^^^^^^^^^^^^^^^^^^ | ||
|
||
Edit the LMS settings of your Open edX instance (_e.g._ ``lms/envs/private.py``) by adding | ||
``fonzie`` to your ``INSTALLED_APPS`` and configure Django Rest Framework (_aka_ | ||
DRF) API versioning support as follows: | ||
|
||
.. code-block:: python | ||
# my_project/settings.py | ||
INSTALLED_APPS = ( | ||
# [...] | ||
# lms/env/private.py | ||
INSTALLED_APPS += ( | ||
'fonzie', | ||
) | ||
# Django Rest Framework (aka DRF) | ||
REST_FRAMEWORK = { | ||
REST_FRAMEWORK.update({ | ||
'ALLOWED_VERSIONS': ('1.0', ), | ||
'DEFAULT_VERSION': '1.0', | ||
'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.URLPathVersioning', | ||
} | ||
}) | ||
And finally, configure Fonzie urls for your project: | ||
And finally, add Fonzie urls in Open edX LMS's URLs: | ||
|
||
.. code-block:: python | ||
# my_project/urls.py | ||
# lms/urls.py | ||
urlpatterns = [ | ||
# [...] | ||
url(r'^api/', include('fonzie.urls')), | ||
] | ||
Docker procedure | ||
^^^^^^^^^^^^^^^^ | ||
|
||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,29 @@ | ||
""" | ||
Fonzie, A FUN API for Open edX. | ||
""" | ||
|
||
from __future__ import absolute_import, unicode_literals | ||
|
||
__version__ = '0.1.0' | ||
from os import path | ||
from setuptools.config import read_configuration | ||
|
||
import pkg_resources | ||
|
||
|
||
def _extract_version(package_name): | ||
""" | ||
Extract fonzie version. | ||
Get package version from installed distribution or configuration file if not installed | ||
""" | ||
try: | ||
return pkg_resources.get_distribution(package_name).version | ||
except pkg_resources.DistributionNotFound: | ||
_conf = read_configuration( | ||
path.join(path.dirname(path.dirname(__file__)), 'setup.cfg') | ||
) | ||
return _conf['metadata']['version'] | ||
|
||
|
||
__version__ = _extract_version('fonzie') | ||
|
||
default_app_config = 'fonzie.apps.FonzieConfig' # pylint: disable=invalid-name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-e .[dev,doc,quality,test,travis] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.