<NME> setup.py
<BEF> #!/usr/bin/env python

"""
A setuptools based setup module.

See:
https://packaging.python.org/en/latest/distributing.html
"""

from os import path

try:
    from pip.req import parse_requirements
except ImportError:
    # pip >= 10
    from pip._internal.req import parse_requirements

from setuptools import find_packages, setup


def get_requirements(requirements_file):
    """Use pip to parse requirements file."""
    requirements = []
    if path.isfile(requirements_file):
        for req in parse_requirements(requirements_file, session="hack"):
            try:
                if req.markers:
                    requirements.append("%s;%s" % (req.req, req.markers))
                else:
                    requirements.append("%s" % req.req)
            except AttributeError:
                # pip >= 20.0.2
if __name__ == "__main__":
    HERE = path.abspath(path.dirname(__file__))
    INSTALL_REQUIRES = get_requirements(path.join(HERE, "requirements.txt"))

    with io.open(path.join(HERE, "README.rst"), encoding="utf-8") as readme:
        LONG_DESCRIPTION = readme.read()
    LDAP_REQUIRES = get_requirements(path.join(HERE, "ldap-requirements.txt"))

    with open(path.join(HERE, "README.rst")) as readme:
        LONG_DESCRIPTION = readme.read()

    def local_scheme(version):
        """Skip the local version (eg. +xyz of 0.6.1.dev4+gdf99fe2)
            to be able to upload to Test PyPI"""
        return ""

    setup(
        name="modoboa",
        description="Mail hosting made simple",
        long_description=LONG_DESCRIPTION,
        license="ISC",
        url="http://modoboa.org/",
        author="Antoine Nguyen",
        author_email="tonio@ngyn.org",
        classifiers=[
            "Development Status :: 5 - Production/Stable",
            "Environment :: Web Environment",
            "Framework :: Django :: 2.2",
            "Intended Audience :: System Administrators",
            "License :: OSI Approved :: ISC License (ISCL)",
            "Operating System :: OS Independent",
            "Programming Language :: Python :: 3",
            "Programming Language :: Python :: 3.7",
            "Programming Language :: Python :: 3.8",
            "Programming Language :: Python :: 3.9",
            "Topic :: Communications :: Email",
        install_requires=INSTALL_REQUIRES,
        use_scm_version=True,
        setup_requires=["setuptools_scm"],
    )
        use_scm_version={
            "local_scheme": local_scheme
        },
        python_requires=">=3.7",
        setup_requires=["setuptools_scm>6.4"],
        extras_require={
            "ldap": LDAP_REQUIRES,
            "mysql": MYSQL_REQUIRES,
            "postgresql": POSTGRESQL_REQUIRES,
            "argon2": ["argon2-cffi >= 16.1.0"],
        },
    )

<MSG> add extra optional packages

Add the ability to install optional packages when installing modoboa. For example if I wanted to use modoboa with PostgreSQL `pip install modoboa[postgresql]`, or if I wanted MySQL and LDAP support `pip install modoboa[mysql,ldap]`

mysqlclient minimum version has been pined to 1.3.11 due to an issue with MariaDB 10 (#1341)

<DFF> @@ -33,6 +33,10 @@ def get_requirements(requirements_file):
 if __name__ == "__main__":
     HERE = path.abspath(path.dirname(__file__))
     INSTALL_REQUIRES = get_requirements(path.join(HERE, "requirements.txt"))
+    MYSQL_REQUIRES = get_requirements(path.join(HERE, "mysql-requirements.txt"))
+    POSTGRESQL_REQUIRES = get_requirements(
+        path.join(HERE, "postgresql-requirements.txt"))
+    LDAP_REQUIRES = get_requirements(path.join(HERE, "ldap-requirements.txt"))
 
     with io.open(path.join(HERE, "README.rst"), encoding="utf-8") as readme:
         LONG_DESCRIPTION = readme.read()
@@ -69,4 +73,9 @@ if __name__ == "__main__":
         install_requires=INSTALL_REQUIRES,
         use_scm_version=True,
         setup_requires=["setuptools_scm"],
+        extras_require={
+            "ldap": LDAP_REQUIRES,
+            "mysql": MYSQL_REQUIRES,
+            "postgresql": POSTGRESQL_REQUIRES,
+        },
     )

add extra optional packages