Back to index

moin  1.9.0~rc2
Public Member Functions | Static Public Attributes
setup.build_scripts_create Class Reference

Build script files. More...

Inheritance diagram for setup.build_scripts_create:
Inheritance graph
[legend]
Collaboration diagram for setup.build_scripts_create:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def copy_scripts

Static Public Attributes

 package_name = None

Detailed Description

Build script files.

Overload the build_scripts command and create the scripts
    from scratch, depending on the target platform.

    You have to define the name of your package in an inherited
    class (due to the delayed instantiation of command classes
    in distutils, this cannot be passed to __init__).

    The scripts are created in an uniform scheme: they start the
    run() function in the module

        <packagename>.script.<mangled_scriptname>

    The mangling of script names replaces '-' and '/' characters
    with '-' and '.', so that they are valid module paths.

Definition at line 116 of file setup.py.


Member Function Documentation

Create each script listed in 'self.scripts'

Definition at line 134 of file setup.py.

00134 
00135     def copy_scripts(self):
00136         """ Create each script listed in 'self.scripts'
00137         """
00138         if not self.package_name:
00139             raise Exception("You have to inherit build_scripts_create and"
00140                 " provide a package name")
00141 
00142         self.mkpath(self.build_dir)
00143         for script in self.scripts:
00144             outfile = os.path.join(self.build_dir, os.path.basename(script))
00145 
00146             #if not self.force and not newer(script, outfile):
00147             #    self.announce("not copying %s (up-to-date)" % script)
00148             #    continue
00149 
00150             if self.dry_run:
00151                 self.announce("would create %s" % outfile)
00152                 continue
00153 
00154             module = os.path.splitext(os.path.basename(script))[0]
00155             module = module.replace('-', '_').replace('/', '.')
00156             script_vars = {
00157                 'python': os.path.normpath(sys.executable),
00158                 'package': self.package_name,
00159                 'module': module,
00160                 'package_location': '/usr/lib/python/site-packages', # FIXME: we need to know the correct path
00161             }
00162 
00163             self.announce("creating %s" % outfile)
00164             file = open(outfile, 'w')
00165 
00166             try:
00167                 if sys.platform == "win32":
00168                     file.write('@echo off\n'
00169                         'if NOT "%%_4ver%%" == "" %(python)s -c "from %(package)s.script.%(module)s import run; run()" %%$\n'
00170                         'if     "%%_4ver%%" == "" %(python)s -c "from %(package)s.script.%(module)s import run; run()" %%*\n'
00171                         % script_vars)
00172                 else:
00173                     file.write("#! %(python)s\n"
00174                         "#Fix and uncomment those 2 lines if your moin command doesn't find the MoinMoin package:\n"
00175                         "#import sys\n"
00176                         "#sys.path.insert(0, '%(package_location)s')\n"
00177                         "from %(package)s.script.%(module)s import run\n"
00178                         "run()\n"
00179                         % script_vars)
00180             finally:
00181                 file.close()
00182                 os.chmod(outfile, 0755)
00183 


Member Data Documentation

Reimplemented in setup.build_scripts_moin.

Definition at line 132 of file setup.py.


The documentation for this class was generated from the following file: