mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Merge pull request #1353 from fyfe/feature/refactor-setup.py
refactor setup.py
This commit is contained in:
@@ -1 +1,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Modoboa - Mail hosting made simple."""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from pkg_resources import get_distribution, DistributionNotFound
|
||||
|
||||
|
||||
try:
|
||||
__version__ = get_distribution(__name__).version
|
||||
except DistributionNotFound:
|
||||
# package is not installed
|
||||
pass
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
from pkg_resources import parse_version
|
||||
|
||||
from versionfield.constants import DEFAULT_NUMBER_BITS
|
||||
from versionfield.version import Version
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from modoboa.core.extensions import exts_pool
|
||||
from modoboa.lib.api_client import ModoAPIClient
|
||||
@@ -38,15 +37,15 @@ def check_for_updates(request):
|
||||
}] + extensions
|
||||
update_avail = False
|
||||
for extension in extensions:
|
||||
local_version = Version(extension["version"], DEFAULT_NUMBER_BITS)
|
||||
pkgname = extension["name"].replace("_", "-")
|
||||
for api_extension in local_config.api_versions:
|
||||
if api_extension["name"] != pkgname:
|
||||
continue
|
||||
last_version = Version(
|
||||
api_extension["version"], DEFAULT_NUMBER_BITS)
|
||||
extension["last_version"] = api_extension["version"]
|
||||
if last_version > local_version:
|
||||
if (
|
||||
parse_version(api_extension["version"])
|
||||
> parse_version(extension["version"])
|
||||
):
|
||||
extension["update"] = True
|
||||
extension["changelog_url"] = api_extension["url"]
|
||||
update_avail = True
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
mysqlclient>=1.3.11
|
||||
@@ -0,0 +1 @@
|
||||
psycopg2>=2.5.4
|
||||
@@ -3,7 +3,6 @@ django-braces==1.11.0
|
||||
django-ckeditor==5.2.2
|
||||
django-reversion==2.0.12
|
||||
django-subcommand2==0.1.1
|
||||
django-versionfield2>=0.5.0
|
||||
django-xforwardedfor-middleware==2.0
|
||||
|
||||
dj-database-url
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
[bdist_wheel]
|
||||
universal = 1
|
||||
[pep8]
|
||||
max-line-length = 80
|
||||
exclude = migrations
|
||||
|
||||
@@ -1,78 +1,81 @@
|
||||
#!/usr/bin/env python
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import re
|
||||
"""
|
||||
A setuptools based setup module.
|
||||
|
||||
See:
|
||||
https://packaging.python.org/en/latest/distributing.html
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import io
|
||||
from os import path
|
||||
from pip.req import parse_requirements
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
ROOT = os.path.dirname(__file__)
|
||||
PIP_REQUIRES = os.path.join(ROOT, "requirements.txt")
|
||||
|
||||
|
||||
def parse_requirements(*filenames):
|
||||
"""
|
||||
We generate our install_requires from the pip-requires and test-requires
|
||||
files so that we don't have to maintain the dependency definitions in
|
||||
two places.
|
||||
"""
|
||||
def get_requirements(requirements_file):
|
||||
"""Use pip to parse requirements file."""
|
||||
requirements = []
|
||||
for f in filenames:
|
||||
for line in open(f, 'r').read().split('\n'):
|
||||
# Comment lines. Skip.
|
||||
if re.match(r'(\s*#)|(\s*$)', line):
|
||||
continue
|
||||
# Editable matches. Put the egg name into our reqs list.
|
||||
if re.match(r'\s*-e\s+', line):
|
||||
pkg = re.sub(r'\s*-e\s+.*#egg=(.*)$', r'\1', line)
|
||||
requirements.append("%s" % pkg)
|
||||
# File-based installs not supported/needed. Skip.
|
||||
elif re.match(r'\s*-f\s+', line):
|
||||
pass
|
||||
else:
|
||||
requirements.append(line)
|
||||
if path.isfile(requirements_file):
|
||||
for req in parse_requirements(requirements_file, session="hack"):
|
||||
# check markers, such as
|
||||
#
|
||||
# rope_py3k ; python_version >= '3.0'
|
||||
#
|
||||
if req.match_markers():
|
||||
requirements.append(str(req.req))
|
||||
return requirements
|
||||
|
||||
|
||||
def parse_dependency_links(*filenames):
|
||||
"""
|
||||
We generate our dependency_links from the pip-requires and test-requires
|
||||
files for the dependencies pulled from github (prepended with -e).
|
||||
"""
|
||||
dependency_links = []
|
||||
for f in filenames:
|
||||
for line in open(f, 'r').read().split('\n'):
|
||||
if re.match(r'\s*-[ef]\s+', line):
|
||||
line = re.sub(r'\s*-[ef]\s+', '', line)
|
||||
line = re.sub(r'\s*git\+https', 'http', line)
|
||||
line = re.sub(r'\.git#', '/tarball/master#', line)
|
||||
dependency_links.append(line)
|
||||
return dependency_links
|
||||
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()
|
||||
|
||||
def read(fname):
|
||||
return open(os.path.join(ROOT, fname)).read()
|
||||
|
||||
|
||||
setup(
|
||||
name="modoboa",
|
||||
version="1.9.1",
|
||||
url="http://modoboa.org/",
|
||||
license="ISC",
|
||||
description="Mail hosting made simple",
|
||||
long_description=read("README.rst"),
|
||||
author="Antoine Nguyen",
|
||||
author_email="tonio@ngyn.org",
|
||||
packages=find_packages(),
|
||||
include_package_data=True,
|
||||
scripts=["bin/modoboa-admin.py"],
|
||||
zip_safe=False,
|
||||
install_requires=parse_requirements(PIP_REQUIRES),
|
||||
dependency_links=parse_dependency_links(PIP_REQUIRES),
|
||||
classifiers=["Development Status :: 5 - Production/Stable",
|
||||
"Framework :: Django",
|
||||
"Intended Audience :: System Administrators",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python",
|
||||
"Topic :: Internet :: WWW/HTTP"]
|
||||
)
|
||||
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 :: 1.11",
|
||||
"Intended Audience :: System Administrators",
|
||||
"License :: OSI Approved :: ISC License (ISCL)",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python :: 2",
|
||||
"Programming Language :: Python :: 2.7",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.4",
|
||||
"Programming Language :: Python :: 3.5",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Topic :: Communications :: Email",
|
||||
"Topic :: Internet :: WWW/HTTP",
|
||||
],
|
||||
keywords="email",
|
||||
packages=find_packages(exclude=["doc", "test_data", "test_project"]),
|
||||
include_package_data=True,
|
||||
zip_safe=False,
|
||||
scripts=["bin/modoboa-admin.py"],
|
||||
install_requires=INSTALL_REQUIRES,
|
||||
use_scm_version=True,
|
||||
setup_requires=["setuptools_scm"],
|
||||
extras_require={
|
||||
"ldap": LDAP_REQUIRES,
|
||||
"mysql": MYSQL_REQUIRES,
|
||||
"postgresql": POSTGRESQL_REQUIRES,
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user