Skip to content

Commit

Permalink
Merge 22fe916 into 6545ada
Browse files Browse the repository at this point in the history
  • Loading branch information
wkcn committed Feb 15, 2020
2 parents 6545ada + 22fe916 commit 85881ba
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 27 deletions.
1 change: 0 additions & 1 deletion mobula/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .version import __version__
from .hacker import hacker
from . import func
from . import op
from . import testing
Expand Down
5 changes: 3 additions & 2 deletions mobula/build_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"OS_IS_WINDOWS", "OS_IS_LINUX", "build_context"]

from .config import config
from .utils import makedirs
import ast
import os
import threading
Expand Down Expand Up @@ -91,7 +92,7 @@ def update_build_path(build_path):
global code_hash, code_hash_filename, code_hash_updated
global dependant, dependant_filename, dependant_updated

os.makedirs(build_path, exist_ok=True)
makedirs(build_path, exist_ok=True)

config.BUILD_PATH = build_path

Expand Down Expand Up @@ -197,7 +198,7 @@ def run_command(command):
def mkdir(dir_name):
if not os.path.exists(dir_name):
print('mkdir -p %s' % dir_name)
os.makedirs(dir_name, exist_ok=True)
makedirs(dir_name, exist_ok=True)


if OS_IS_LINUX:
Expand Down
Empty file removed mobula/hacker/__init__.py
Empty file.
21 changes: 0 additions & 21 deletions mobula/hacker/hacker.py

This file was deleted.

6 changes: 3 additions & 3 deletions mobula/op/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ..edict import edict
from ..func import CFuncDef, bind, get_func_idcode, get_idcode_hash
from ..build import config, source_to_so_ctx, build_context, file_is_changed, ENV_PATH
from ..utils import get_git_hash
from ..utils import get_git_hash, makedirs
from ..dtype import DType, TemplateType
from ..version import OP_LOAD_MODULE_BUILD_VERSION
from ..glue.backend import get_glue_modules
Expand Down Expand Up @@ -218,7 +218,7 @@ def _build_lib(cpp_fname, code_buffer, ctx, target_name):
code=code_buffer)

build_path_ctx = os.path.join(build_path, ctx)
os.makedirs(build_path_ctx, exist_ok=True)
makedirs(build_path_ctx, exist_ok=True)

# build so
cpp_wrapper_fname = os.path.join(build_path_ctx,
Expand Down Expand Up @@ -435,7 +435,7 @@ def __init__(self, cfunc, arg_types, ctx, cpp_info):
build_path = os.path.join(cpp_path, 'build')

use_template = bool(cfunc.template_list)
os.makedirs(build_path, exist_ok=True)
makedirs(build_path, exist_ok=True)
build_info_fname = os.path.join(
build_path, os.path.splitext(cpp_basename)[0] + '.json')
build_info_fs = open(build_info_fname, 'a+')
Expand Down
13 changes: 13 additions & 0 deletions mobula/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,16 @@ def __new__(cls, name, _bases, attrs):
def __prepare__(cls, name, _bases):
return meta.__prepare__(name, bases)
return type.__new__(metaclass, 'class', (), {})


def makedirs(name, mode=511, exist_ok=False):
'''makedirs(name [, mode=0o777][, exist_ok=False])
Super-mkdir; create a leaf directory and all intermediate ones. Works like
mkdir, except that any intermediate path segment (not just the rightmost)
will be created if it does not exist. If the target directory already
exists, raise an OSError if exist_ok is False. Otherwise no exception is
raised. This is recursive.'''
if os.path.exists(name) and exist_ok:
return
os.makedirs(name, mode)

0 comments on commit 85881ba

Please sign in to comment.