src/ldt/setup.py
author veltr
Fri, 01 Mar 2013 18:05:02 +0100
changeset 1121 d56201bf1446
parent 1012 09d29a596d49
permissions -rw-r--r--
New metadataplayer + default "Multi segments" widget
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
import os
189
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
     2
from distutils.core import setup
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
     3
from distutils.command.install_data import install_data
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
     4
from distutils.command.install import INSTALL_SCHEMES
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
     5
import sys
48
ef3a8cfef2bc correct setup.py to integrate templsters
ymh <ymh.work@gmail.com>
parents: 30
diff changeset
     6
627
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
     7
189
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
     8
class osx_install_data(install_data):
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
     9
    # On MacOS, the platform-specific lib dir is /System/Library/Framework/Python/.../
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    10
    # which is wrong. Python 2.5 supplied with MacOS 10.5 has an Apple-specific fix
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    11
    # for this in distutils.command.install_data#306. It fixes install_lib but not
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    12
    # install_data, which is why we roll our own install_data class.
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    13
    
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    14
    def finalize_options(self):
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    15
        # By the time finalize_options is called, install.install_lib is set to the
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    16
        # fixed directory, so we set the installdir to install_lib. The
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    17
        # install_data class uses ('install_data', 'install_dir') instead.
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    18
        self.set_undefined_options('install', ('install_lib', 'install_dir'))
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    19
        install_data.finalize_options(self)
0
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
189
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    21
def fullsplit(path, result=None):
3
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    22
    """
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    23
    Split a pathname into components (the opposite of os.path.join) in a
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    24
    platform-neutral way.
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    25
    """
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    26
    if result is None:
30
83f4abc7568f correct setup for ldt
ymh <ymh.work@gmail.com>
parents: 13
diff changeset
    27
        result = []
3
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    28
    head, tail = os.path.split(path)
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    29
    if head == '':
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    30
        return [tail] + result
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    31
    if head == path:
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    32
        return result
189
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    33
    return fullsplit(head, [tail] + result)
3
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    34
632
e85856bfd59b new sync script using fabric
ymh <ymh.work@gmail.com>
parents: 629
diff changeset
    35
627
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    36
def launch_setup(script_name, script_args):
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    37
    if sys.platform == "darwin": 
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    38
        cmdclasses = {'install_data': osx_install_data} 
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    39
    else: 
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    40
        cmdclasses = {'install_data': install_data} 
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    41
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    42
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    43
    root_dir = os.path.dirname(__file__)
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    44
    if root_dir != '':
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    45
        os.chdir(root_dir)
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    46
    source_dir = 'ldt'
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    47
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    48
    version_variables = {}
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    49
    try:
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    50
        execfile(os.path.join(source_dir, "__init__.py"), version_variables)
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    51
    except:
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    52
        pass
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    53
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    54
    version = version_variables['__version__']
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    55
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    56
    packages, data_files = [], []
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    57
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    58
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    59
    for dirpath, dirnames, filenames in os.walk(source_dir):
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    60
        # Ignore dirnames that start with '.'
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    61
        for i, dirname in enumerate(dirnames):
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    62
            if dirname.startswith('.'): del dirnames[i]
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    63
        if '__init__.py' in filenames:
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    64
            packages.append('.'.join(fullsplit(dirpath)))
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    65
        elif filenames:
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    66
            data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]])
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    67
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    68
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    69
    # Tell distutils to put the data_files in platform-specific installation
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    70
    # locations. See here for an explanation:
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    71
    # http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    72
    for scheme in INSTALL_SCHEMES.values():
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    73
        scheme['data'] = scheme['purelib']
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    74
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    75
    # Small hack for working with bdist_wininst.
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    76
    # See http://mail.python.org/pipermail/distutils-sig/2004-August/004134.html
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    77
    if len(sys.argv) > 1 and sys.argv[1] == 'bdist_wininst':
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    78
        for file_info in data_files:
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    79
            file_info[0] = '\\PURELIB\\%s' % file_info[0]
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    80
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    81
    #write MANIFEST.in
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    82
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    83
    with open("MANIFEST.in", "w") as m:    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    84
        m.write("include CHANGES\n")
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    85
        m.write("include LICENSE\n")
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    86
        m.write("include README\n")
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    87
        m.write("include MANIFEST.in\n")
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    88
        for entry in data_files:
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    89
            file_list = entry[1]
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    90
            for filename in file_list:
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    91
                m.write("include %s\n" % (filename))
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    92
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    93
    setup(
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    94
        script_name = script_name,
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    95
        script_args = script_args,
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    96
        name='ldt',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    97
        version=version,
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    98
        author='IRI',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    99
        author_email='contact@iri.centrepompidou.fr',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   100
        packages=packages,
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   101
        data_files=data_files,
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   102
        cmdclass = cmdclasses,
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   103
        scripts=[],
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   104
        url='http://www.iri.centrepompidou.fr/dev/hg/platform',
1012
09d29a596d49 remove unnecessary file + small update on setup
ymh <ymh.work@gmail.com>
parents: 632
diff changeset
   105
        license='LICENSE',
627
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   106
        description='Platform ldt',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   107
        long_description=open('README').read(),
1012
09d29a596d49 remove unnecessary file + small update on setup
ymh <ymh.work@gmail.com>
parents: 632
diff changeset
   108
        classifiers=['Development Status :: 4 - Beta',
627
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   109
                       'Environment :: Web Environment',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   110
                       'Framework :: Django',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   111
                       'Intended Audience :: Developers',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   112
                       'License :: Ceccil-C',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   113
                       'Operating System :: OS Independent',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   114
                       'Programming Language :: Python',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   115
                       'Topic :: Utilities',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   116
        ],
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   117
    )
189
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
   118
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
   119
627
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   120
if __name__ == "__main__":
632
e85856bfd59b new sync script using fabric
ymh <ymh.work@gmail.com>
parents: 629
diff changeset
   121
    
627
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   122
    script_name = os.path.basename(sys.argv[0])
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   123
    script_args = sys.argv[1:]
632
e85856bfd59b new sync script using fabric
ymh <ymh.work@gmail.com>
parents: 629
diff changeset
   124
    
e85856bfd59b new sync script using fabric
ymh <ymh.work@gmail.com>
parents: 629
diff changeset
   125
    launch_setup(script_name, script_args)