]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Added an "optional" directive, that will include a module if it is available
authorJack Jansen <jack.jansen@cwi.nl>
Fri, 4 Jun 1999 15:56:33 +0000 (15:56 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Fri, 4 Jun 1999 15:56:33 +0000 (15:56 +0000)
but not complain if it isn't (giving an ImportError when the frozen code is run).

Mac/Tools/macfreeze/directives.py
Mac/Tools/macfreeze/macmodulefinder.py

index e23374589ae28939bd74d7dc188e3ac53f8c0882..16b7879e5b9eb95f47e63255ebf2c0ff546b3dc6 100644 (file)
@@ -18,6 +18,7 @@ REPROG=re.compile(DIRECTIVE_RE)
 def findfreezedirectives(program):
        extra_modules = []
        exclude_modules = []
+       optional_modules = []
        extra_path = []
        progdir, filename = os.path.split(program)
        fp = open(program)
@@ -30,10 +31,12 @@ def findfreezedirectives(program):
                                extra_modules.append(argument)
                        elif directive == 'exclude':
                                exclude_modules.append(argument)
+                       elif directive == 'optional':
+                               optional_modules.append(argument)
                        elif directive == 'path':
                                argument = os.path.join(progdir, argument)
                                extra_path.append(argument)
                        else:
                                print '** Unknown directive', line
-       return extra_modules, exclude_modules, extra_path
+       return extra_modules, exclude_modules, optional_modules, extra_path
        
index 0af04258a1a3a08fe819a761382dc13520fca720..b19c86dcab5484794cac00d7796d922cdf5892c1 100644 (file)
@@ -57,7 +57,7 @@ def process(program, modules=[], module_files = [], debug=0):
        #
        # search the main source for directives
        #
-       extra_modules, exclude_modules, extra_path = \
+       extra_modules, exclude_modules, optional_modules, extra_path = \
                        directives.findfreezedirectives(program)
        for m in extra_modules:
                if os.sep in m:
@@ -84,7 +84,7 @@ def process(program, modules=[], module_files = [], debug=0):
        #
        # Tell the user about missing modules
        #
-       maymiss = exclude_modules + MAC_MAYMISS_MODULES
+       maymiss = exclude_modules + optional_modules + MAC_MAYMISS_MODULES
        for m in modfinder.badmodules.keys():
                if not m in maymiss:
                        if debug > 0: