~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Robert Collins
  • Date: 2005-10-06 22:15:52 UTC
  • mfrom: (1185.13.2)
  • mto: This revision was merged to the branch mainline in revision 1420.
  • Revision ID: robertc@robertcollins.net-20051006221552-9b15c96fa504e0ad
mergeĀ fromĀ upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
# './setup.py install', or
5
5
# './setup.py --help' for more options
6
6
 
7
 
# Reinvocation stolen from bzr, we need python2.4 by virtue of bzr_man
8
 
# including bzrlib.help
9
 
 
10
 
import os, sys
11
 
 
12
 
try:
13
 
    version_info = sys.version_info
14
 
except AttributeError:
15
 
    version_info = 1, 5 # 1.5 or older
16
 
 
17
 
REINVOKE = "__BZR_REINVOKE"
18
 
NEED_VERS = (2, 4)
19
 
KNOWN_PYTHONS = ('python2.4',)
20
 
 
21
 
if version_info < NEED_VERS:
22
 
    if not os.environ.has_key(REINVOKE):
23
 
        # mutating os.environ doesn't work in old Pythons
24
 
        os.putenv(REINVOKE, "1")
25
 
        for python in KNOWN_PYTHONS:
26
 
            try:
27
 
                os.execvp(python, [python] + sys.argv)
28
 
            except OSError:
29
 
                pass
30
 
    print >>sys.stderr, "bzr: error: cannot find a suitable python interpreter"
31
 
    print >>sys.stderr, "  (need %d.%d or later)" % NEED_VERS
32
 
    sys.exit(1)
33
 
if hasattr(os, "unsetenv"):
34
 
    os.unsetenv(REINVOKE)
35
 
 
36
 
 
37
7
from distutils.core import setup
38
 
from distutils.command.install_scripts import install_scripts
39
 
from distutils.command.build import build
 
8
 
 
9
# more sophisticated setup script, based on pychecker setup.py
 
10
import sys, os
 
11
from distutils.command.build_scripts import build_scripts
 
12
 
40
13
 
41
14
###############################
42
15
# Overridden distutils actions
43
16
###############################
44
17
 
45
 
class my_install_scripts(install_scripts):
46
 
    """ Customized install_scripts distutils action.
 
18
class my_build_scripts(build_scripts):
 
19
    """Customized build_scripts distutils action.
 
20
 
47
21
    Create bzr.bat for win32.
48
22
    """
 
23
 
49
24
    def run(self):
50
 
        import os
51
 
        import sys
52
 
 
53
 
        install_scripts.run(self)   # standard action
54
 
 
55
25
        if sys.platform == "win32":
56
 
            try:
57
 
                scripts_dir = self.install_dir
58
 
                script_path = os.path.join(scripts_dir, "bzr")
59
 
                batch_str = "@%s %s %%*\n" % (sys.executable, script_path)
60
 
                batch_path = script_path + ".bat"
61
 
                f = file(batch_path, "w")
62
 
                f.write(batch_str)
63
 
                f.close()
64
 
                print "Created:", batch_path
65
 
            except Exception, e:
66
 
                print "ERROR: Unable to create %s: %s" % (batch_path, e)
67
 
 
68
 
 
69
 
class bzr_build(build):
70
 
    """Customized build distutils action.
71
 
    Generate bzr.1.
72
 
    """
73
 
    def run(self):
74
 
        build.run(self)
75
 
 
76
 
        import bzr_man
77
 
        bzr_man.main()
 
26
            bat_path = os.path.join(self.build_dir, "bzr.bat")
 
27
            self.scripts.append(bat_path)
 
28
            self.mkpath(self.build_dir)
 
29
            scripts_dir = self.distribution.get_command_obj("install").\
 
30
                                                            install_scripts
 
31
            self.execute(func=self._create_bat,
 
32
                         args=[bat_path, scripts_dir],
 
33
                         msg="Create %s" % bat_path)
 
34
        build_scripts.run(self) # invoke "standard" action
 
35
 
 
36
    def _create_bat(self, bat_path, scripts_dir):
 
37
        """ Creates the batch file for bzr on win32.
 
38
        """
 
39
        try:
 
40
            script_path = os.path.join(scripts_dir, "bzr")
 
41
            bat_str = "@%s %s %%*\n" % (sys.executable, script_path)
 
42
            file(bat_path, "w").write(bat_str)
 
43
            print "file written"
 
44
        except Exception, e:
 
45
            print "ERROR: Unable to create %s: %s" % (bat_path, e)
 
46
            raise e
 
47
 
78
48
 
79
49
########################
80
50
## Setup
81
51
########################
82
52
 
83
53
setup(name='bzr',
84
 
      version='0.7pre',
 
54
      version='0.1',
85
55
      author='Martin Pool',
86
56
      author_email='mbp@sourcefrog.net',
87
57
      url='http://www.bazaar-ng.org/',
88
58
      description='Friendly distributed version control system',
89
59
      license='GNU GPL v2',
90
60
      packages=['bzrlib',
91
 
                'bzrlib.export',
92
61
                'bzrlib.plugins',
 
62
                'bzrlib.selftest',
 
63
                'bzrlib.util',
 
64
                'bzrlib.transport',
93
65
                'bzrlib.store',
94
 
                'bzrlib.tests',
95
 
                'bzrlib.tests.blackbox',
96
 
                'bzrlib.transport',
97
 
                'bzrlib.ui',
98
 
                'bzrlib.util',
99
66
                'bzrlib.util.elementtree',
100
67
                'bzrlib.util.effbot.org',
101
 
                'bzrlib.util.configobj',
102
68
                ],
103
 
      scripts=['bzr'],
104
 
      cmdclass={'install_scripts': my_install_scripts, 'build': bzr_build},
105
 
      data_files=[('man/man1', ['bzr.1'])],
106
 
     )
 
69
      scripts=['bzr'])