1# -*- coding: utf-8 -*-
2# docs/COPYING 2a + DRY: https://github.com/getmail6/getmail6
3# Please refer to the git history regarding who changed what and when in this file.
4
5import sys
6
7import os.path
8from setuptools import setup
9import distutils.sysconfig
10import site
11
12from getmailcore import __version__, __license__
13
14#
15# distutils doesn't seem to handle documentation files specially; they're
16# just "data" files.  The problem is, there's no easy way to say "install
17# the doc files under <prefix>/doc/<package>-<version>/ (obeying any
18# --home=<althome> or --prefix=<altprefix>, which would be "normal".
19# This hacks around this limitation.
20#
21prefix = distutils.sysconfig.get_config_var('prefix')
22datadir = None
23args = sys.argv[1:]
24for (pos, arg) in enumerate(args):
25    # hack hack hack
26    if arg.startswith('--prefix='):
27        # hack hack hack hack hack
28        prefix = arg.split('=', 1)[1]
29    elif arg == '--prefix':
30        # hack hack hack hack hack hack hack
31        prefix = args[pos + 1]
32    elif arg.startswith('--install-data='):
33        # hack hack hack hack hack
34        datadir = arg.split('=', 1)[1]
35    elif arg == '--install-data':
36        # hack hack hack hack hack hack hack
37        datadir = args[pos + 1]
38
39DOCDIR = os.path.join('share','doc','getmail-%s' % __version__)
40GETMAILDOCDIR = os.path.join(datadir or prefix, DOCDIR)
41
42MANDIR = os.path.join('share','man','man1')
43GETMAILMANDIR = os.path.join( datadir or prefix, MANDIR)
44
45if '--show-default-install-dirs' in args:
46    print('Default installation directories:')
47    print('  scripts :        %s' % distutils.sysconfig.get_config_var('BINDIR'))
48    print('  Python modules : %s' % distutils.sysconfig.get_python_lib())
49    print('  documentation :  %s' % GETMAILDOCDIR)
50    print('  man(1) pages :   %s' % GETMAILMANDIR)
51    raise SystemExit()
52
53setup(
54    name='getmail6',
55    version=__version__,
56    description='a mail retrieval, sorting, and delivering system',
57    long_description=open('README').read(),
58    author='Charles Cazabon, Roland Puntaier, and others',
59    author_email='charlesc-getmail@pyropus.ca',
60    maintainer_email='roland.puntaier@gmail.com',
61    license=__license__,
62    url='https://www.getmail6.org/',
63    download_url='https://github.com/getmail6/getmail6/releases',
64    classifiers=[
65        'Development Status :: 4 - Beta',
66        'Environment :: Console',
67        'Intended Audience :: End Users/Desktop',
68        'Intended Audience :: System Administrators',
69        'License :: OSI Approved :: GNU General Public License (GPL)',
70        'Natural Language :: English',
71        'Operating System :: OS Independent',
72        'Operating System :: POSIX',
73        'Programming Language :: Python',
74        'Topic :: Communications :: Email',
75        'Topic :: Communications :: Email :: Filters',
76        'Topic :: Communications :: Email :: Post-Office :: IMAP',
77        'Topic :: Communications :: Email :: Post-Office :: POP3',
78        'Topic :: Software Development :: Libraries :: Python Modules',
79        'Topic :: Utilities',
80    ],
81    packages=[
82        'getmailcore'
83    ],
84    scripts=[
85        'getmail',
86        'getmails',
87        'getmail_fetch',
88        'getmail_maildir',
89        'getmail_mbox',
90        'getmail-gmail-xoauth-tokens',
91    ],
92    data_files=[
93        (MANDIR, [
94            'docs/getmails.1',
95            'docs/getmail.1',
96            'docs/getmail_fetch.1',
97            'docs/getmail_maildir.1',
98            'docs/getmail_mbox.1',
99        ]),
100    ],
101)
102