mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
refactor setup.py
- use setuptools_scm to generate version number, normal releases will use the tagged version (ie 1.9.1), versions installed from source will append the git commit number to the version number (ie 1.9.1.dev61+g4584c93) - use io.open() to read text files to correctly handle utf-8 characters - use pip to parse requirements.txt - update classifiers to specify python and django versions supported - fix classifier for license - wheel distributions can now be built using `python setup.py bdist_wheel`
This commit is contained in:
@@ -1 +1,14 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""Modoboa - Mail hosting made simple."""
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
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
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
[bdist_wheel]
|
||||||
|
universal = 1
|
||||||
[pep8]
|
[pep8]
|
||||||
max-line-length = 80
|
max-line-length = 80
|
||||||
exclude = migrations
|
exclude = migrations
|
||||||
|
|||||||
@@ -1,78 +1,72 @@
|
|||||||
#!/usr/bin/env python
|
#!/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
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
ROOT = os.path.dirname(__file__)
|
|
||||||
PIP_REQUIRES = os.path.join(ROOT, "requirements.txt")
|
|
||||||
|
|
||||||
|
def get_requirements(requirements_file):
|
||||||
def parse_requirements(*filenames):
|
"""Use pip to parse requirements file."""
|
||||||
"""
|
|
||||||
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.
|
|
||||||
"""
|
|
||||||
requirements = []
|
requirements = []
|
||||||
for f in filenames:
|
if path.isfile(requirements_file):
|
||||||
for line in open(f, 'r').read().split('\n'):
|
for req in parse_requirements(requirements_file, session="hack"):
|
||||||
# Comment lines. Skip.
|
# check markers, such as
|
||||||
if re.match(r'(\s*#)|(\s*$)', line):
|
#
|
||||||
continue
|
# rope_py3k ; python_version >= '3.0'
|
||||||
# Editable matches. Put the egg name into our reqs list.
|
#
|
||||||
if re.match(r'\s*-e\s+', line):
|
if req.match_markers():
|
||||||
pkg = re.sub(r'\s*-e\s+.*#egg=(.*)$', r'\1', line)
|
requirements.append(str(req.req))
|
||||||
requirements.append("%s" % pkg)
|
|
||||||
# File-based installs not supported/needed. Skip.
|
|
||||||
elif re.match(r'\s*-f\s+', line):
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
requirements.append(line)
|
|
||||||
return requirements
|
return requirements
|
||||||
|
|
||||||
|
|
||||||
def parse_dependency_links(*filenames):
|
if __name__ == "__main__":
|
||||||
"""
|
HERE = path.abspath(path.dirname(__file__))
|
||||||
We generate our dependency_links from the pip-requires and test-requires
|
INSTALL_REQUIRES = get_requirements(path.join(HERE, "requirements.txt"))
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
def read(fname):
|
|
||||||
return open(os.path.join(ROOT, fname)).read()
|
|
||||||
|
|
||||||
|
with io.open(path.join(HERE, "README.rst"), encoding="utf-8") as readme:
|
||||||
|
LONG_DESCRIPTION = readme.read()
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="modoboa",
|
name="modoboa",
|
||||||
version="1.9.1",
|
|
||||||
url="http://modoboa.org/",
|
|
||||||
license="ISC",
|
|
||||||
description="Mail hosting made simple",
|
description="Mail hosting made simple",
|
||||||
long_description=read("README.rst"),
|
long_description=LONG_DESCRIPTION,
|
||||||
|
license="ISC",
|
||||||
|
url="http://modoboa.org/",
|
||||||
author="Antoine Nguyen",
|
author="Antoine Nguyen",
|
||||||
author_email="tonio@ngyn.org",
|
author_email="tonio@ngyn.org",
|
||||||
packages=find_packages(),
|
classifiers=[
|
||||||
include_package_data=True,
|
"Development Status :: 5 - Production/Stable",
|
||||||
scripts=["bin/modoboa-admin.py"],
|
"Environment :: Web Environment",
|
||||||
zip_safe=False,
|
"Framework :: Django :: 1.11",
|
||||||
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",
|
"Intended Audience :: System Administrators",
|
||||||
"License :: OSI Approved :: MIT License",
|
"License :: OSI Approved :: ISC License (ISCL)",
|
||||||
"Operating System :: OS Independent",
|
"Operating System :: OS Independent",
|
||||||
"Programming Language :: Python",
|
"Programming Language :: Python :: 2",
|
||||||
"Topic :: Internet :: WWW/HTTP"]
|
"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"],
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user