diff --git a/misc/format_server.py b/misc/format_server.py index 5acb17e46b7edb..a73e5bbc8bdba8 100644 --- a/misc/format_server.py +++ b/misc/format_server.py @@ -75,7 +75,7 @@ def do_GET(self): # self.exec(f'git checkout master') def x(): - a = 1 + a = 1 def run(addr, port): diff --git a/python/taichi/core/util.py b/python/taichi/core/util.py index 76a4576665f58d..53ee655e9b85f3 100644 --- a/python/taichi/core/util.py +++ b/python/taichi/core/util.py @@ -31,7 +31,9 @@ def import_tc_core(tmp_dir=None): import taichi_core as core except Exception as e: if isinstance(e, ImportError): - print("Share object taichi_core import failed. If you are on Windows, please consider installing \"Microsoft Visual C++ Redistributable\" (https://aka.ms/vs/16/release/vc_redist.x64.exe)") + print( + "Share object taichi_core import failed. If you are on Windows, please consider installing \"Microsoft Visual C++ Redistributable\" (https://aka.ms/vs/16/release/vc_redist.x64.exe)" + ) raise e tc_core = core if get_os_name() != 'win': @@ -127,6 +129,7 @@ def format(all=False, diff=None): create_sand_box_on_windows = True + def build(): tmp_cwd = os.getcwd() bin_dir = get_build_directory() @@ -151,6 +154,7 @@ def build(): os.chdir(tmp_cwd) + def prepare_sandbox(src): global g_tmp_dir assert os.path.exists(src) @@ -258,6 +262,7 @@ def prepare_sandbox(src): if log_level: tc_core.set_logging_level(log_level) + def get_dll_name(name): if get_os_name() == 'linux': return 'libtaichi_%s.so' % name @@ -295,7 +300,7 @@ def at_startup(): if not os.path.exists(output_dir): print('Making output directory') os.mkdir(output_dir) - + tc_core.set_core_state_python_imported(True) @@ -321,26 +326,32 @@ def task(): proc = multiprocessing.Process(target=task, daemon=True) proc.start() - + + def require_version(major, minor=None, patch=None): versions = [ - int(tc_core.get_version_major()), - int(tc_core.get_version_minor()), - int(tc_core.get_version_patch()), + int(tc_core.get_version_major()), + int(tc_core.get_version_minor()), + int(tc_core.get_version_patch()), ] - match = major == versions[0] and (minor < versions[1] or minor == versions[1] and patch <= versions[2]) + match = major == versions[0] and ( + minor < versions[1] or minor == versions[1] and patch <= versions[2]) if match: return else: - print("Taichi version mismatch. required >= {}.{}.{}".format(major, minor, patch)) + print("Taichi version mismatch. required >= {}.{}.{}".format( + major, minor, patch)) print("Installed =", tc_core.get_version_string()) raise Exception("Taichi version mismatch") + at_startup() device_string = 'cpu only' if not tc_core.with_cuda() else 'cuda {}'.format( tc_core.cuda_version()) -print(f'[Taichi] version {tc_core.get_version_string()}, {device_string}, commit {tc_core.get_commit_hash()[:8]}, python {sys.version_info[0]}.{sys.version_info[1]}.{sys.version_info[2]}') +print( + f'[Taichi] version {tc_core.get_version_string()}, {device_string}, commit {tc_core.get_commit_hash()[:8]}, python {sys.version_info[0]}.{sys.version_info[1]}.{sys.version_info[2]}' +) if not is_release(): tc_core.set_core_trigger_gdb_when_crash(True) diff --git a/python/taichi/main.py b/python/taichi/main.py index 485a91299f0015..515d932ae46d7e 100644 --- a/python/taichi/main.py +++ b/python/taichi/main.py @@ -32,16 +32,19 @@ def test_python(test_files=(), verbose=False): if verbose: args += ['-s'] if len(test_files) == 0 or len(test_files) > 4: - if int(pytest.main([os.path.join(root_dir, 'misc/empty_pytest.py'), '-n1'])) == 0: # if pytest has xdist + if int( + pytest.main([os.path.join(root_dir, 'misc/empty_pytest.py'), + '-n1'])) == 0: # if pytest has xdist try: from multiprocessing import cpu_count - threads = min(8, cpu_count()) # To prevent running out of memory + threads = min(8, cpu_count()) # To prevent running out of memory except: threads = 2 env_threads = os.environ.get('TI_TEST_THREADS', '') if env_threads: threads = int(env_threads) - print(f'Following TI_TEST_THREADS to use {threads} testing thread(s)...') + print( + f'Following TI_TEST_THREADS to use {threads} testing thread(s)...') print(f'Starting {threads} testing thread(s)...') if threads > 1: args += ['-n', str(threads)] @@ -66,7 +69,8 @@ def main(debug=False): if 'TI_DEBUG' in os.environ: val = os.environ['TI_DEBUG'] if val not in ['0', '1']: - raise ValueError("Environment variable TI_DEBUG can only have value 0 or 1.") + raise ValueError( + "Environment variable TI_DEBUG can only have value 0 or 1.") if debug: lines.append(u' *****************Debug Mode****************') os.environ['TI_DEBUG'] = '1' @@ -150,7 +154,8 @@ def main(debug=False): elif mode == "interpolate": interpolate_frames('.') elif mode == "doc": - os.system('cd {}/docs && sphinx-build -b html . build'.format(ti.get_repo_directory())) + os.system('cd {}/docs && sphinx-build -b html . build'.format( + ti.get_repo_directory())) elif mode == "video": files = sorted(os.listdir('.')) files = list(filter(lambda x: x.endswith('.png'), files)) @@ -248,5 +253,6 @@ def main(debug=False): def main_debug(): main(debug=True) + if __name__ == '__main__': exit(main())