__all__ = [
    'workspace',
]

import logging
from pathlib import Path

import iga.env
import iga.path
from iga.core import WriteOnceDict
from iga.error import IgaError


LOG = logging.getLogger(__name__)
LOG.addHandler(logging.NullHandler())


def workspace(
        *,
        root=None,
        source='.',
        build='build'):
    """Define workspace variables in root env."""
    root = root or iga.path.get_caller_path(ancestor=1).parent
    LOG.info('root = %s', root)
    if not root.is_dir():
        raise IgaError('"root" is not a dir: %s' % root)
    source = Path(root, source)
    LOG.info('source = %s', source)
    if not source.is_dir():
        raise IgaError('"source" is not a dir: %s' % source)
    build = Path(root, build)
    LOG.info('build = %s', build)
    rule_makers = WriteOnceDict()
    rule_makers.update(load_rule_makers())
    if LOG.isEnabledFor(logging.INFO):
        for rule_maker_name in rule_makers.keys():
            LOG.info('add rule %s', rule_maker_name)
    iga.env.root().update(
        root=root,
        source=source,
        build=build,
        rule_makers=rule_makers,
    )


def load_rule_makers():
    # TODO...
    return {}

@@ -101,43 +101,8 @@
 ath%0A
-from iga.core import WriteOnceDict%0A
 from
@@ -746,228 +746,8 @@
 ld)%0A
-    rule_makers = WriteOnceDict()%0A    rule_makers.update(load_rule_makers())%0A    if LOG.isEnabledFor(logging.INFO):%0A        for rule_maker_name in rule_makers.keys():%0A            LOG.info('add rule %25s', rule_maker_name)%0A
     
@@ -840,93 +840,6 @@
     
-    rule_makers=rule_makers,%0A    )%0A%0A%0Adef load_rule_makers():%0A    # TODO...%0A    return %7B%7D
+)
 %0A

Remove unused code