src/ldt/setup.py
author ymh <ymh.work@gmail.com>
Wed, 09 May 2012 19:28:51 +0200
changeset 629 04c71ec19b80
parent 627 f5c55582565d
child 632 e85856bfd59b
permissions -rw-r--r--
debug setup
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
629
04c71ec19b80 debug setup
ymh <ymh.work@gmail.com>
parents: 627
diff changeset
     7
print("hello 1")
627
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
     8
189
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
     9
class osx_install_data(install_data):
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    10
    # 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
    11
    # 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
    12
    # 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
    13
    # 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
    14
    
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    15
    def finalize_options(self):
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    16
        # 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
    17
        # fixed directory, so we set the installdir to install_lib. The
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    18
        # install_data class uses ('install_data', 'install_dir') instead.
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    19
        self.set_undefined_options('install', ('install_lib', 'install_dir'))
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    20
        install_data.finalize_options(self)
629
04c71ec19b80 debug setup
ymh <ymh.work@gmail.com>
parents: 627
diff changeset
    21
print("hello 2")
0
bdf22b140727 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
189
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    23
def fullsplit(path, result=None):
3
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    24
    """
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    25
    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
    26
    platform-neutral way.
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    27
    """
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    28
    if result is None:
30
83f4abc7568f correct setup for ldt
ymh <ymh.work@gmail.com>
parents: 13
diff changeset
    29
        result = []
3
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    30
    head, tail = os.path.split(path)
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    31
    if head == '':
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    32
        return [tail] + result
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    33
    if head == path:
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    34
        return result
189
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
    35
    return fullsplit(head, [tail] + result)
3
03918bc7b9f1 small corrections on install
ymh <ymh.work@gmail.com>
parents: 2
diff changeset
    36
629
04c71ec19b80 debug setup
ymh <ymh.work@gmail.com>
parents: 627
diff changeset
    37
print("hello 3")
627
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    38
def launch_setup(script_name, script_args):
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    39
    if sys.platform == "darwin": 
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    40
        cmdclasses = {'install_data': osx_install_data} 
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    41
    else: 
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    42
        cmdclasses = {'install_data': install_data} 
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    43
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    44
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    45
    root_dir = os.path.dirname(__file__)
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    46
    if root_dir != '':
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    47
        os.chdir(root_dir)
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    48
    source_dir = 'ldt'
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    49
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    50
    version_variables = {}
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    51
    try:
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    52
        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
    53
    except:
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    54
        pass
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
    version = version_variables['__version__']
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
    packages, data_files = [], []
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    59
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    60
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    61
    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
    62
        # Ignore dirnames that start with '.'
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    63
        for i, dirname in enumerate(dirnames):
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    64
            if dirname.startswith('.'): del dirnames[i]
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    65
        if '__init__.py' in filenames:
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    66
            packages.append('.'.join(fullsplit(dirpath)))
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    67
        elif filenames:
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    68
            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
    69
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    70
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    71
    # 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
    72
    # locations. See here for an explanation:
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    73
    # 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
    74
    for scheme in INSTALL_SCHEMES.values():
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    75
        scheme['data'] = scheme['purelib']
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    76
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    77
    # Small hack for working with bdist_wininst.
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    78
    # 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
    79
    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
    80
        for file_info in data_files:
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    81
            file_info[0] = '\\PURELIB\\%s' % file_info[0]
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
    #write MANIFEST.in
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    84
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    85
    with open("MANIFEST.in", "w") as m:    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    86
        m.write("include CHANGES\n")
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    87
        m.write("include LICENSE\n")
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    88
        m.write("include README\n")
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    89
        m.write("include MANIFEST.in\n")
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    90
        for entry in data_files:
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    91
            file_list = entry[1]
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    92
            for filename in file_list:
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    93
                m.write("include %s\n" % (filename))
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    94
    
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    95
    setup(
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    96
        script_name = script_name,
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    97
        script_args = script_args,
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    98
        name='ldt',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
    99
        version=version,
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   100
        author='IRI',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   101
        author_email='contact@iri.centrepompidou.fr',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   102
        packages=packages,
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   103
        data_files=data_files,
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   104
        cmdclass = cmdclasses,
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   105
        scripts=[],
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   106
        url='http://www.iri.centrepompidou.fr/dev/hg/platform',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   107
        license='LICENSE.txt',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   108
        description='Platform ldt',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   109
        long_description=open('README').read(),
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   110
        classifiers=['Development Status :: 5 - Production/Stable',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   111
                       'Environment :: Web Environment',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   112
                       'Framework :: Django',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   113
                       'Intended Audience :: Developers',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   114
                       'License :: Ceccil-C',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   115
                       'Operating System :: OS Independent',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   116
                       'Programming Language :: Python',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   117
                       'Topic :: Utilities',
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   118
        ],
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   119
    )
189
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
   120
08e6b5dbfc93 Improve distutils script
ymh <ymh.work@gmail.com>
parents: 167
diff changeset
   121
627
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   122
if __name__ == "__main__":
629
04c71ec19b80 debug setup
ymh <ymh.work@gmail.com>
parents: 627
diff changeset
   123
   
04c71ec19b80 debug setup
ymh <ymh.work@gmail.com>
parents: 627
diff changeset
   124
    print("hello 4")    
627
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   125
    script_name = os.path.basename(sys.argv[0])
f5c55582565d temporary commit to test build script
ymh <ymh.work@gmail.com>
parents: 189
diff changeset
   126
    script_args = sys.argv[1:]
629
04c71ec19b80 debug setup
ymh <ymh.work@gmail.com>
parents: 627
diff changeset
   127
    print("hello 5")
04c71ec19b80 debug setup
ymh <ymh.work@gmail.com>
parents: 627
diff changeset
   128
    launch_setup(script_name, script_args)
04c71ec19b80 debug setup
ymh <ymh.work@gmail.com>
parents: 627
diff changeset
   129
    print("hello 6")