diff --git a/README.rst b/README.rst index db4311b..b79110e 100644 --- a/README.rst +++ b/README.rst @@ -137,22 +137,26 @@ Example project To play with the example project, just clone the repository and run the dev server. +`Install poetry `_ if not already installed. + .. code:: bash $ git clone https://github.com/izimobil/django-rest-framework-datatables.git $ cd django-rest-framework-datatables - $ pip install -r requirements-dev.txt + $ poetry install --with dev $ python example/manage.py runserver $ firefox http://127.0.0.1:8000 Testing ------- +`Install poetry `_ if not already installed. + Install development requirements. .. code:: bash - $ pip install -r requirements-dev.txt + $ poetry install --with dev Run the tests. @@ -184,7 +188,7 @@ To build the documentation, you’ll need to install ``sphinx``. .. code:: bash - $ pip install -r requirements-docs.txt + $ poetry install --with docs To build the documentation: @@ -193,6 +197,15 @@ To build the documentation: $ cd docs $ make clean && make html +Publish to PyPI +--------------- + +`Build `_ package and `Publish `_ to PyPI with two commands. + +.. code:: bash + + $ poetry build + $ poetry publish .. _tox: http://tox.readthedocs.org/en/latest/ diff --git a/docs/tutorial.rst b/docs/tutorial.rst index db984d5..f150fb4 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -203,7 +203,7 @@ In the above example, the fields 'id' and 'rank' will always be serialized in th Alternatively, if you wish to choose which fields to preserve at runtime rather than hardcoding them into your serializer models, use the ``?keep=`` param along with the fields you wish to maintain (comma separated). For example, if you wished to preserve ``id`` and ``rank`` as before, you would simply use the following API call: - .. code:: html + .. code:: data-ajax="/api/albums/?format=datatables&keep=id,rank" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4adef5e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,62 @@ +[tool.poetry] +name = "djangorestframework-datatables" +version = "0.7.1" +description = "Seamless integration between Django REST framework and Datatables (https://datatables.net)" +authors = ["David Jean Louis "] +license = "MIT" +readme = ["README.rst", "docs/changelog.rst"] +packages = [ + { include = "rest_framework_datatables" }, + { include = "rest_framework_datatables/django_filters" }, +] +homepage = "https://github.com/izimobil/django-rest-framework-datatables" +repository = "https://github.com/izimobil/django-rest-framework-datatables" +keywords = ["django",] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Web Environment", + "Framework :: Django", + "Framework :: Django :: 3.2", + "Framework :: Django :: 4", + "Framework :: Django :: 4.0", + "Framework :: Django :: 4.1", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Internet :: WWW/HTTP", +] + +[tool.poetry.dependencies] +python = ">=3.7" +djangorestframework = ">=3.14.0" +pytz = ">=2019.1" + +[tool.poetry.group.dev] +optional = true + +[tool.poetry.group.dev.dependencies] +coverage = "==6.5.0" +Django = ">=3.2" +pycodestyle = ">=2.9.1" +django-filter = ">=22.1" + +[tool.poetry.group.docs] +optional = true + +[tool.poetry.group.docs.dependencies] +Sphinx = "==5.3.0" +sphinx-rtd-theme = "==1.1.1" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" + diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 2056ba6..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,6 +0,0 @@ -coverage==6.5.0 -Django>=3.2 -djangorestframework>=3.14 -pycodestyle>=2.9.1 -django-filter>=22.1 -pytz diff --git a/requirements-docs.txt b/requirements-docs.txt deleted file mode 100644 index 24bbc56..0000000 --- a/requirements-docs.txt +++ /dev/null @@ -1,2 +0,0 @@ -Sphinx==5.3.0 -sphinx-rtd-theme==1.1.1 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 78c4181..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -djangorestframework>=3.14 -pytz diff --git a/rest_framework_datatables/__init__.py b/rest_framework_datatables/__init__.py index a71c5c7..e69de29 100644 --- a/rest_framework_datatables/__init__.py +++ b/rest_framework_datatables/__init__.py @@ -1 +0,0 @@ -__version__ = '0.7.0' diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 5e40900..0000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[wheel] -universal = 1 diff --git a/setup.py b/setup.py deleted file mode 100644 index d5e28b0..0000000 --- a/setup.py +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import re -import os -import sys -from setuptools import setup - - -name = 'djangorestframework-datatables' -package = 'rest_framework_datatables' -description = ( - 'Seamless integration between Django REST framework and ' - 'Datatables (https://datatables.net)' -) -url = 'https://github.com/izimobil/django-rest-framework-datatables' -author = 'David Jean Louis' -author_email = 'izimobil@gmail.com' -license = 'MIT' - - -def get_version(package): - """ - Return package version as listed in `__version__` in `init.py`. - """ - with open(os.path.join(package, '__init__.py')) as fh: - return re.search( - "^__version__ = ['\"]([^'\"]+)['\"]", - fh.read(), - re.MULTILINE - ).group(1) - init_py = open(os.path.join(package, '__init__.py')).read() - - -def get_long_description(): - """ - Return rst formatted readme and changelog. - """ - ret = [] - with open('README.rst') as fh: - ret.append(fh.read()) - try: - with open('docs/changelog.rst') as fh: - ret.append(fh.read()) - except IOError: - pass - return '\n\n'.join(ret) - - -def get_package_data(package): - """ - Return all files under the root package, that are not in a - package themselves. - """ - walk = [(dirpath.replace(package + os.sep, '', 1), filenames) - for dirpath, dirnames, filenames in os.walk(package) - if not os.path.exists(os.path.join(dirpath, '__init__.py'))] - - filepaths = [] - for base, filenames in walk: - filepaths.extend([os.path.join(base, filename) - for filename in filenames]) - return {package: filepaths} - - -version = get_version(package) - -if sys.argv[-1] == 'publish': - os.system("python setup.py sdist upload") - os.system("python setup.py bdist_wheel upload") - print("You probably want to also tag the version now:") - print(" git tag -a {0} -m 'version {0}'".format(version)) - print(" git push --tags") - sys.exit() - - -setup( - name=name, - version=version, - url=url, - license=license, - description=description, - long_description=get_long_description(), - author=author, - author_email=author_email, - packages=[ - 'rest_framework_datatables', - 'rest_framework_datatables.django_filters' - ], - install_requires=[ - 'djangorestframework>=3.14.0', - 'pytz', - ], - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Web Environment', - 'Framework :: Django', - 'Framework :: Django :: 3.2', - 'Framework :: Django :: 4.0', - 'Framework :: Django :: 4.1', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - 'Natural Language :: English', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Topic :: Internet :: WWW/HTTP', - ] -)