7c43a681b4a34eb80d1df6008dc301d01f840a75
[OpenColorIO-Configs.git] / aces_1.0.0 / python / aces_ocio / create_aces_config.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 """
5 Defines objects creating the *ACES* configuration.
6 """
7
8 from __future__ import division
9
10 import os
11 import sys
12
13 import PyOpenColorIO as ocio
14
15 import aces_ocio.create_aces_colorspaces as aces
16 import aces_ocio.create_arri_colorspaces as arri
17 import aces_ocio.create_canon_colorspaces as canon
18 import aces_ocio.create_red_colorspaces as red
19 import aces_ocio.create_sony_colorspaces as sony
20 import aces_ocio.create_general_colorspaces as general
21
22 from aces_ocio.process import Process
23
24 __author__ = 'ACES Developers'
25 __copyright__ = 'Copyright (C) 2014 - 2015 - ACES Developers'
26 __license__ = ''
27 __maintainer__ = 'ACES Developers'
28 __email__ = 'aces@oscars.org'
29 __status__ = 'Production'
30
31 __all__ = ['ACES_OCIO_CTL_DIRECTORY_ENVIRON',
32            'ACES_OCIO_CONFIGURATION_DIRECTORY_ENVIRON',
33            'set_config_default_roles',
34            'write_config',
35            'generate_OCIO_transform',
36            'add_colorspace_alias',
37            'create_config',
38            'generate_LUTs',
39            'generate_baked_LUTs',
40            'create_config_dir',
41            'create_ACES_config',
42            'main']
43
44 ACES_OCIO_CTL_DIRECTORY_ENVIRON = 'ACES_OCIO_CTL_DIRECTORY'
45 ACES_OCIO_CONFIGURATION_DIRECTORY_ENVIRON = 'ACES_OCIO_CONFIGURATION_DIRECTORY'
46
47
48 def set_config_default_roles(config,
49                              color_picking='',
50                              color_timing='',
51                              compositing_log='',
52                              data='',
53                              default='',
54                              matte_paint='',
55                              reference='',
56                              scene_linear='',
57                              texture_paint=''):
58     """
59     Sets given *OCIO* configuration default roles.
60
61     Parameters
62     ----------
63     config : config
64         *OCIO* configuration.
65     color_picking : str or unicode
66         Color picking role title.
67     color_timing : str or unicode
68         Color timing role title.
69     compositing_log : str or unicode
70         Compositing log role title.
71     data : str or unicode
72         Data role title.
73     default : str or unicode
74         Default role title.
75     matte_paint : str or unicode
76         Matte painting role title.
77     reference : str or unicode
78         Reference role title.
79     scene_linear : str or unicode
80         Scene linear role title.
81     texture_paint : str or unicode
82         Texture painting role title.
83
84     Returns
85     -------
86     bool
87          Definition success.
88     """
89
90     if color_picking:
91         config.setRole(ocio.Constants.ROLE_COLOR_PICKING, color_picking)
92     if color_timing:
93         config.setRole(ocio.Constants.ROLE_COLOR_TIMING, color_timing)
94     if compositing_log:
95         config.setRole(ocio.Constants.ROLE_COMPOSITING_LOG, compositing_log)
96     if data:
97         config.setRole(ocio.Constants.ROLE_DATA, data)
98     if default:
99         config.setRole(ocio.Constants.ROLE_DEFAULT, default)
100     if matte_paint:
101         config.setRole(ocio.Constants.ROLE_MATTE_PAINT, matte_paint)
102     if reference:
103         config.setRole(ocio.Constants.ROLE_REFERENCE, reference)
104     if scene_linear:
105         config.setRole(ocio.Constants.ROLE_SCENE_LINEAR, scene_linear)
106     if texture_paint:
107         config.setRole(ocio.Constants.ROLE_TEXTURE_PAINT, texture_paint)
108
109     return True
110
111
112 def write_config(config, config_path, sanity_check=True):
113     """
114     Writes the configuration to given path.
115
116     Parameters
117     ----------
118     parameter : type
119         Parameter description.
120
121     Returns
122     -------
123     type
124          Return value description.
125     """
126
127     if sanity_check:
128         try:
129             config.sanityCheck()
130         except Exception, e:
131             print e
132             print 'Configuration was not written due to a failed Sanity Check'
133             return
134
135     with open(config_path, mode='w') as fp:
136         fp.write(config.serialize())
137
138
139 def generate_OCIO_transform(transforms):
140     """
141     Object description.
142
143     Parameters
144     ----------
145     parameter : type
146         Parameter description.
147
148     Returns
149     -------
150     type
151          Return value description.
152     """
153
154     interpolation_options = {
155         'linear': ocio.Constants.INTERP_LINEAR,
156         'nearest': ocio.Constants.INTERP_NEAREST,
157         'tetrahedral': ocio.Constants.INTERP_TETRAHEDRAL}
158
159     direction_options = {
160         'forward': ocio.Constants.TRANSFORM_DIR_FORWARD,
161         'inverse': ocio.Constants.TRANSFORM_DIR_INVERSE}
162
163     ocio_transforms = []
164
165     for transform in transforms:
166
167         # lutFile transform
168         if transform['type'] == 'lutFile':
169             ocio_transform = ocio.FileTransform(
170                 src=transform['path'],
171                 interpolation=interpolation_options[
172                     transform['interpolation']],
173                 direction=direction_options[transform['direction']])
174             ocio_transforms.append(ocio_transform)
175
176         # matrix transform
177         elif transform['type'] == 'matrix':
178             ocio_transform = ocio.MatrixTransform()
179             # MatrixTransform member variables can't be initialized directly.
180             # Each must be set individually.
181             ocio_transform.setMatrix(transform['matrix'])
182
183             if 'offset' in transform:
184                 ocio_transform.setOffset(transform['offset'])
185
186             if 'direction' in transform:
187                 ocio_transform.setDirection(
188                     direction_options[transform['direction']])
189
190             ocio_transforms.append(ocio_transform)
191
192         # exponent transform
193         elif transform['type'] == 'exponent':
194             ocio_transform = ocio.ExponentTransform()
195             ocio_transform.setValue(transform['value'])
196             ocio_transforms.append(ocio_transform)
197
198         # log transform
199         elif transform['type'] == 'log':
200             ocio_transform = ocio.LogTransform(
201                 base=transform['base'],
202                 direction=direction_options[transform['direction']])
203
204             ocio_transforms.append(ocio_transform)
205
206         # color space transform
207         elif transform['type'] == 'colorspace':
208             ocio_transform = ocio.ColorSpaceTransform(src=transform['src'],
209                                                       dst=transform['dst'],
210                                                       direction=
211                                                       direction_options[
212                                                           'forward'])
213             ocio_transforms.append(ocio_transform)
214         # unknown type
215         else:
216             print("Ignoring unknown transform type : %s" % transform['type'])
217
218     if len(ocio_transforms) > 1:
219         group_transform = ocio.GroupTransform()
220         for transform in ocio_transforms:
221             group_transform.push_back(transform)
222         transform = group_transform
223     else:
224         transform = ocio_transforms[0]
225
226     return transform
227
228
229 def add_colorspace_alias(config,
230                          reference_colorspace,
231                          colorspace,
232                          colorspace_alias_names):
233     """
234     Object description.
235
236     Parameters
237     ----------
238     parameter : type
239         Parameter description.
240
241     Returns
242     -------
243     type
244          Return value description.
245     """
246
247     for alias_name in colorspace_alias_names:
248         if alias_name == colorspace.name.lower():
249             return
250
251         print('Adding alias colorspace space %s, alias to %s' % (
252             alias_name, colorspace.name))
253
254         compact_family_name = 'Aliases'
255
256         ocio_colorspace_alias = ocio.ColorSpace(
257             name=alias_name,
258             bitDepth=colorspace.bit_depth,
259             description=colorspace.description,
260             equalityGroup=colorspace.equality_group,
261             family=compact_family_name,
262             isData=colorspace.is_data,
263             allocation=colorspace.allocation_type,
264             allocationVars=colorspace.allocation_vars)
265
266         if not colorspace.to_reference_transforms:
267             print('Generating To-Reference transforms')
268             ocio_transform = generate_OCIO_transform(
269                 [{'type': 'colorspace',
270                   'src': colorspace.name,
271                   'dst': reference_colorspace.name,
272                   'direction': 'forward'}])
273             ocio_colorspace_alias.setTransform(
274                 ocio_transform,
275                 ocio.Constants.COLORSPACE_DIR_TO_REFERENCE)
276
277         if not colorspace.from_reference_transforms:
278             print('Generating From-Reference transforms')
279             ocio_transform = generate_OCIO_transform(
280                 [{'type': 'colorspace',
281                   'src': reference_colorspace.name,
282                   'dst': colorspace.name,
283                   'direction': 'forward'}])
284             ocio_colorspace_alias.setTransform(
285                 ocio_transform,
286                 ocio.Constants.COLORSPACE_DIR_FROM_REFERENCE)
287
288         config.addColorSpace(ocio_colorspace_alias)
289
290
291 def create_config(config_data, nuke=False):
292     """
293     Object description.
294
295     Parameters
296     ----------
297     parameter : type
298         Parameter description.
299
300     Returns
301     -------
302     type
303          Return value description.
304     """
305
306     # Creating the *OCIO* configuration.
307     config = ocio.Config()
308
309     # Setting configuration overall values.
310     config.setDescription('An ACES config generated from python')
311     config.setSearchPath('luts')
312
313     # Defining the reference colorspace.
314     reference_data = config_data['referenceColorSpace']
315     print('Adding the reference color space : %s' % reference_data.name)
316
317     reference = ocio.ColorSpace(
318         name=reference_data.name,
319         bitDepth=reference_data.bit_depth,
320         description=reference_data.description,
321         equalityGroup=reference_data.equality_group,
322         family=reference_data.family,
323         isData=reference_data.is_data,
324         allocation=reference_data.allocation_type,
325         allocationVars=reference_data.allocation_vars)
326
327     config.addColorSpace(reference)
328
329     # Add alias
330     if reference_data.aliases != []:
331         add_colorspace_alias(config, reference_data,
332                              reference_data, reference_data.aliases)
333
334     print("")
335
336     # Creating the remaining colorspaces.
337     for colorspace in sorted(config_data['colorSpaces']):
338         print('Creating new color space : %s' % colorspace.name)
339
340         ocio_colorspace = ocio.ColorSpace(
341             name=colorspace.name,
342             bitDepth=colorspace.bit_depth,
343             description=colorspace.description,
344             equalityGroup=colorspace.equality_group,
345             family=colorspace.family,
346             isData=colorspace.is_data,
347             allocation=colorspace.allocation_type,
348             allocationVars=colorspace.allocation_vars)
349
350         if colorspace.to_reference_transforms:
351             print('Generating To-Reference transforms')
352             ocio_transform = generate_OCIO_transform(
353                 colorspace.to_reference_transforms)
354             ocio_colorspace.setTransform(
355                 ocio_transform,
356                 ocio.Constants.COLORSPACE_DIR_TO_REFERENCE)
357
358         if colorspace.from_reference_transforms:
359             print('Generating From-Reference transforms')
360             ocio_transform = generate_OCIO_transform(
361                 colorspace.from_reference_transforms)
362             ocio_colorspace.setTransform(
363                 ocio_transform,
364                 ocio.Constants.COLORSPACE_DIR_FROM_REFERENCE)
365
366         config.addColorSpace(ocio_colorspace)
367
368         #
369         # Add alias to normal colorspace, using compact name
370         #
371         if colorspace.aliases != []:
372             add_colorspace_alias(config, reference_data,
373                                  colorspace, colorspace.aliases)
374
375         print('')
376
377     # Defining the *views* and *displays*.
378     displays = []
379     views = []
380
381     # Defining a *generic* *display* and *view* setup.
382     if not nuke:
383         for display, view_list in config_data['displays'].iteritems():
384             for view_name, colorspace in view_list.iteritems():
385                 config.addDisplay(display, view_name, colorspace.name)
386                 if not (view_name in views):
387                     views.append(view_name)
388             displays.append(display)
389
390     # Defining the *Nuke* specific set of *views* and *displays*.
391     else:
392         for display, view_list in config_data['displays'].iteritems():
393             for view_name, colorspace in view_list.iteritems():
394                 if view_name == 'Output Transform':
395                     view_name = 'View'
396                     config.addDisplay(display, view_name, colorspace.name)
397                     if not (view_name in views):
398                         views.append(view_name)
399             displays.append(display)
400
401         linear_display_space_name = config_data['linearDisplaySpace'].name
402         log_display_space_name = config_data['logDisplaySpace'].name
403
404         config.addDisplay('linear', 'View', linear_display_space_name)
405         displays.append('linear')
406         config.addDisplay('log', 'View', log_display_space_name)
407         displays.append('log')
408
409     # Setting the active *displays* and *views*.
410     config.setActiveDisplays(','.join(sorted(displays)))
411     config.setActiveViews(','.join(views))
412
413     set_config_default_roles(
414         config,
415         color_picking=reference.getName(),
416         color_timing=reference.getName(),
417         compositing_log=reference.getName(),
418         data=reference.getName(),
419         default=reference.getName(),
420         matte_paint=reference.getName(),
421         reference=reference.getName(),
422         scene_linear=reference.getName(),
423         texture_paint=reference.getName())
424
425     config.sanityCheck()
426
427     return config
428
429
430 def generate_LUTs(odt_info,
431                   lmt_info,
432                   shaper_name,
433                   aces_ctl_directory,
434                   lut_directory,
435                   lut_resolution_1d=4096,
436                   lut_resolution_3d=64,
437                   cleanup=True):
438     """
439     Object description.
440
441     Parameters
442     ----------
443     parameter : type
444         Parameter description.
445
446     Returns
447     -------
448     dict
449          Colorspaces and transforms converting between those colorspaces and
450          the reference colorspace, *ACES*.
451     """
452
453     print('generateLUTs - begin')
454     config_data = {}
455
456     # Initialize a few variables
457     config_data['displays'] = {}
458     config_data['colorSpaces'] = []
459
460     # -------------------------------------------------------------------------
461     # *ACES Color Spaces*
462     # -------------------------------------------------------------------------
463
464     # *ACES* colorspaces
465     (aces_reference,
466      aces_colorspaces,
467      aces_displays,
468      aces_log_display_space) = aces.create_colorspaces(aces_ctl_directory,
469                                                        lut_directory,
470                                                        lut_resolution_1d,
471                                                        lut_resolution_3d,
472                                                        lmt_info,
473                                                        odt_info,
474                                                        shaper_name,
475                                                        cleanup)
476
477     config_data['referenceColorSpace'] = aces_reference
478
479     for cs in aces_colorspaces:
480         config_data['colorSpaces'].append(cs)
481
482     for name, data in aces_displays.iteritems():
483         config_data['displays'][name] = data
484
485     config_data['linearDisplaySpace'] = aces_reference
486     config_data['logDisplaySpace'] = aces_log_display_space
487
488     # -------------------------------------------------------------------------
489     # *Camera Input Transforms*
490     # -------------------------------------------------------------------------
491
492     # *Log-C* to *ACES*.
493     arri_colorSpaces = arri.create_colorspaces(lut_directory,
494                                                lut_resolution_1d)
495     for cs in arri_colorSpaces:
496         config_data['colorSpaces'].append(cs)
497
498     # *Canon-Log* to *ACES*.
499     canon_colorspaces = canon.create_colorspaces(lut_directory,
500                                                  lut_resolution_1d)
501     for cs in canon_colorspaces:
502         config_data['colorSpaces'].append(cs)
503
504     # *RED* colorspaces to *ACES*.
505     red_colorspaces = red.create_colorspaces(lut_directory,
506                                              lut_resolution_1d)
507     for cs in red_colorspaces:
508         config_data['colorSpaces'].append(cs)
509
510     # *S-Log* to *ACES*.
511     sony_colorSpaces = sony.create_colorspaces(lut_directory,
512                                                lut_resolution_1d)
513     for cs in sony_colorSpaces:
514         config_data['colorSpaces'].append(cs)
515
516     # -------------------------------------------------------------------------
517     # General Color Spaces
518     # -------------------------------------------------------------------------
519     general_colorSpaces = general.create_colorspaces(lut_directory,
520                                                      lut_resolution_1d,
521                                                      lut_resolution_3d)
522     for cs in general_colorSpaces:
523         config_data['colorSpaces'].append(cs)
524
525     print('generateLUTs - end')
526     return config_data
527
528
529 def generate_baked_LUTs(odt_info,
530                         shaper_name,
531                         baked_directory,
532                         config_path,
533                         lut_resolution_1d,
534                         lut_resolution_3d,
535                         lut_resolution_shaper=1024):
536     """
537     Object description.
538
539     Parameters
540     ----------
541     parameter : type
542         Parameter description.
543
544     Returns
545     -------
546     type
547          Return value description.
548     """
549
550     # Create two entries for ODTs that have full and legal range support
551     odt_info_C = dict(odt_info)
552     for odt_ctl_name, odt_values in odt_info.iteritems():
553         if odt_values['transformHasFullLegalSwitch']:
554             odt_name = odt_values['transformUserName']
555
556             odt_values_legal = dict(odt_values)
557             odt_values_legal['transformUserName'] = '%s - Legal' % odt_name
558             odt_info_C['%s - Legal' % odt_ctl_name] = odt_values_legal
559
560             odt_values_full = dict(odt_values)
561             odt_values_full['transformUserName'] = '%s - Full' % odt_name
562             odt_info_C['%s - Full' % odt_ctl_name] = odt_values_full
563
564             del (odt_info_C[odt_ctl_name])
565
566     # Generate appropriate LUTs for each ODT
567     for odt_ctl_name, odt_values in odt_info_C.iteritems():
568         odt_prefix = odt_values['transformUserNamePrefix']
569         odt_name = odt_values['transformUserName']
570
571         # *Photoshop*
572         for input_space in ['ACEScc', 'ACESproxy']:
573             args = ['--iconfig', config_path,
574                     '-v',
575                     '--inputspace', input_space]
576             args += ['--outputspace', '%s' % odt_name]
577             args += ['--description',
578                      '%s - %s for %s data' % (odt_prefix,
579                                               odt_name,
580                                               input_space)]
581             args += ['--shaperspace', shaper_name,
582                      '--shapersize', str(lut_resolution_shaper)]
583             args += ['--cubesize', str(lut_resolution_3d)]
584             args += ['--format',
585                      'icc',
586                      os.path.join(baked_directory,
587                                   'photoshop',
588                                   '%s for %s.icc' % (odt_name, input_space))]
589
590             bake_lut = Process(description='bake a LUT',
591                                cmd='ociobakelut',
592                                args=args)
593             bake_lut.execute()
594
595         # *Flame*, *Lustre*
596         for input_space in ['ACEScc', 'ACESproxy']:
597             args = ['--iconfig', config_path,
598                     '-v',
599                     '--inputspace', input_space]
600             args += ['--outputspace', '%s' % odt_name]
601             args += ['--description',
602                      '%s - %s for %s data' % (
603                          odt_prefix, odt_name, input_space)]
604             args += ['--shaperspace', shaper_name,
605                      '--shapersize', str(lut_resolution_shaper)]
606             args += ['--cubesize', str(lut_resolution_3d)]
607
608             fargs = ['--format',
609                      'flame',
610                      os.path.join(
611                          baked_directory,
612                          'flame',
613                          '%s for %s Flame.3dl' % (odt_name, input_space))]
614             bake_lut = Process(description='bake a LUT',
615                                cmd='ociobakelut',
616                                args=(args + fargs))
617             bake_lut.execute()
618
619             largs = ['--format',
620                      'lustre',
621                      os.path.join(
622                          baked_directory,
623                          'lustre',
624                          '%s for %s Lustre.3dl' % (odt_name, input_space))]
625             bake_lut = Process(description='bake a LUT',
626                                cmd='ociobakelut',
627                                args=(args + largs))
628             bake_lut.execute()
629
630         # *Maya*, *Houdini*
631         for input_space in ['ACEScg', 'ACES2065-1']:
632             args = ['--iconfig', config_path,
633                     '-v',
634                     '--inputspace', input_space]
635             args += ['--outputspace', '%s' % odt_name]
636             args += ['--description',
637                      '%s - %s for %s data' % (
638                          odt_prefix, odt_name, input_space)]
639             if input_space == 'ACEScg':
640                 lin_shaper_name = '%s - AP1' % shaper_name
641             else:
642                 lin_shaper_name = shaper_name
643             args += ['--shaperspace', lin_shaper_name,
644                      '--shapersize', str(lut_resolution_shaper)]
645
646             args += ['--cubesize', str(lut_resolution_3d)]
647
648             margs = ['--format',
649                      'cinespace',
650                      os.path.join(
651                          baked_directory,
652                          'maya',
653                          '%s for %s Maya.csp' % (odt_name, input_space))]
654             bake_lut = Process(description='bake a LUT',
655                                cmd='ociobakelut',
656                                args=(args + margs))
657             bake_lut.execute()
658
659             hargs = ['--format',
660                      'houdini',
661                      os.path.join(
662                          baked_directory,
663                          'houdini',
664                          '%s for %s Houdini.lut' % (odt_name, input_space))]
665             bake_lut = Process(description='bake a LUT',
666                                cmd='ociobakelut',
667                                args=(args + hargs))
668             bake_lut.execute()
669
670
671 def create_config_dir(config_directory, bake_secondary_LUTs):
672     """
673     Object description.
674
675     Parameters
676     ----------
677     parameter : type
678         Parameter description.
679
680     Returns
681     -------
682     type
683          Return value description.
684     """
685
686     lut_directory = os.path.join(config_directory, 'luts')
687     dirs = [config_directory, lut_directory]
688     if bake_secondary_LUTs:
689         dirs.extend([os.path.join(config_directory, 'baked'),
690                      os.path.join(config_directory, 'baked', 'flame'),
691                      os.path.join(config_directory, 'baked', 'photoshop'),
692                      os.path.join(config_directory, 'baked', 'houdini'),
693                      os.path.join(config_directory, 'baked', 'lustre'),
694                      os.path.join(config_directory, 'baked', 'maya')])
695
696     for d in dirs:
697         not os.path.exists(d) and os.mkdir(d)
698
699     return lut_directory
700
701
702 def create_ACES_config(aces_ctl_directory,
703                        config_directory,
704                        lut_resolution_1d=4096,
705                        lut_resolution_3d=64,
706                        bake_secondary_LUTs=True,
707                        cleanup=True):
708     """
709     Creates the ACES configuration.
710
711     Parameters
712     ----------
713     parameter : type
714         Parameter description.
715
716     Returns
717     -------
718     type
719          Return value description.
720     """
721
722     lut_directory = create_config_dir(config_directory, bake_secondary_LUTs)
723
724     odt_info = aces.get_ODTs_info(aces_ctl_directory)
725     lmt_info = aces.get_LMTs_info(aces_ctl_directory)
726
727     shaper_name = 'Output Shaper'
728     config_data = generate_LUTs(odt_info,
729                                 lmt_info,
730                                 shaper_name,
731                                 aces_ctl_directory,
732                                 lut_directory,
733                                 lut_resolution_1d,
734                                 lut_resolution_3d,
735                                 cleanup)
736
737     print('Creating "generic" config')
738     config = create_config(config_data)
739     print('\n\n\n')
740
741     write_config(config,
742                  os.path.join(config_directory, 'config.ocio'))
743
744     print('Creating "Nuke" config')
745     nuke_config = create_config(config_data, nuke=True)
746     print('\n\n\n')
747
748     write_config(nuke_config,
749                  os.path.join(config_directory, 'nuke_config.ocio'))
750
751     if bake_secondary_LUTs:
752         generate_baked_LUTs(odt_info,
753                             shaper_name,
754                             os.path.join(config_directory, 'baked'),
755                             os.path.join(config_directory, 'config.ocio'),
756                             lut_resolution_1d,
757                             lut_resolution_3d,
758                             lut_resolution_1d)
759
760     return True
761
762
763 def main():
764     """
765     Object description.
766
767     Parameters
768     ----------
769     parameter : type
770         Parameter description.
771
772     Returns
773     -------
774     type
775          Return value description.
776     """
777
778     import optparse
779
780     p = optparse.OptionParser(description='An OCIO config generation script',
781                               prog='createACESConfig',
782                               version='createACESConfig 0.1',
783                               usage='%prog [options]')
784     p.add_option('--acesCTLDir', '-a', default=os.environ.get(
785         ACES_OCIO_CTL_DIRECTORY_ENVIRON, None))
786     p.add_option('--configDir', '-c', default=os.environ.get(
787         ACES_OCIO_CONFIGURATION_DIRECTORY_ENVIRON, None))
788     p.add_option('--lutResolution1d', default=4096)
789     p.add_option('--lutResolution3d', default=64)
790     p.add_option('--dontBakeSecondaryLUTs', action='store_true')
791     p.add_option('--keepTempImages', action='store_true')
792
793     options, arguments = p.parse_args()
794
795     aces_ctl_directory = options.acesCTLDir
796     config_directory = options.configDir
797     lut_resolution_1d = int(options.lutResolution1d)
798     lut_resolution_3d = int(options.lutResolution3d)
799     bake_secondary_luts = not options.dontBakeSecondaryLUTs
800     cleanup_temp_images = not options.keepTempImages
801
802     # TODO: Investigate the following statements.
803     try:
804         args_start = sys.argv.index('--') + 1
805         args = sys.argv[args_start:]
806     except:
807         args_start = len(sys.argv) + 1
808         args = []
809
810     print('command line : \n%s\n' % ' '.join(sys.argv))
811
812     assert aces_ctl_directory is not None, (
813         'process: No "{0}" environment variable defined or no "ACES CTL" '
814         'directory specified'.format(
815             ACES_OCIO_CTL_DIRECTORY_ENVIRON))
816
817     assert config_directory is not None, (
818         'process: No "{0}" environment variable defined or no configuration '
819         'directory specified'.format(
820             ACES_OCIO_CONFIGURATION_DIRECTORY_ENVIRON))
821
822     return create_ACES_config(aces_ctl_directory,
823                               config_directory,
824                               lut_resolution_1d,
825                               lut_resolution_3d,
826                               bake_secondary_luts,
827                               cleanup_temp_images)
828
829
830 if __name__ == '__main__':
831     main()