def write_linklet_bundle_hash(ht, out_port, env, cont): from pycket.util import console_log from pycket.racket_entry import get_primitive console_log("BUNDLE AST TO BE SERIALIZED: %s" % ht.tostring(), 7) with PerfRegion("ast->sexp"): l = ht.length() keys = [None] * l vals = [None] * l i = 0 for k, v in ht.iteritems(): keys[i] = k vals[i] = ast_to_sexp(v) i += 1 bundle_s_exp = make_simple_immutable_table(W_EqImmutableHashTable, keys, vals) console_log("WRITING BUNDLE SEXP : %s" % bundle_s_exp.tostring(), 7) s_exp_to_fasl = get_primitive("s-exp->fasl") with PerfRegionCPS("s-exp->fasl"): return s_exp_to_fasl.call([bundle_s_exp, out_port, values.w_false], env, finish_perf_region_cont( "s-exp->fasl", env, cont))
def load_bootstrap_linklet(which_str, debug, is_it_expander=False, from_fasl=True): from pycket.error import SchemeException with PerfRegion("%s-linklet" % which_str): console_log("Loading the %s linklet..." % which_str) linklet_file_path = locate_linklet("%s.rktl.linklet" % which_str) if from_fasl: try: linklet_file_path = locate_linklet("%s.zo" % which_str) except SchemeException: linklet_file_path = locate_linklet("%s.fasl" % which_str) # load the linklet _instance = load_inst_linklet(linklet_file_path, debug, set_version=is_it_expander, from_fasl=from_fasl) _instance.expose_vars_to_prim_env(excludes=syntax_primitives) if is_it_expander: from pycket.env import w_global_config w_global_config.set_config_val('expander_loaded', 1) return 0
def make_instance(args): # name, data, *vars_vals with PerfRegion("make-instance"): name = args[0] # W_Symbol data = w_false mode = w_false from pycket.util import console_log if "'" in name.tostring(): console_log("making instance : %s" % name.tostring(), 3) else: console_log("making instance : %s" % name.tostring(), 4) if len(args) <= 2: data = args[1] vars_vals = [] else: data = args[1] mode = args[2] vars_vals = args[3:] # check if the vars and vals match if ((len(vars_vals) % 2) != 0): raise SchemeException( "Variable names and values do not match : %s" % vars_vals) vars_vals_dict = {} for i in range(0, len(vars_vals), 2): n = vars_vals[i] v = vars_vals[i + 1] vars_vals_dict[n] = W_LinkletVar(v, n, mode) return W_LinkletInstance(name, vars_vals_dict, data)
def read_linklet_bundle_hash(in_port, env, cont): from pycket.racket_entry import get_primitive from pycket.fasl import Fasl from pycket.util import console_log current_load_relative_dir_path = get_primitive("current-load-relative-directory").get_cell_value(cont) fasl_to_s_exp = get_primitive("fasl->s-exp") with PerfRegion("fasl->s-exp"): bundle_map = Fasl(current_load_relative_dir_path).to_sexp_from_w_port(in_port) #return fasl_to_s_exp.call([in_port, values.w_true], env, read_linklet_cont(env, cont)) if not isinstance(bundle_map, W_HashTable): raise SchemeException("got something that is not a table: %s" % bundle_map.tostring()) console_log("BUNDLE SEXP FASL-READ from ZO: %s" % deserialize_loop(bundle_map).tostring(), 7) with PerfRegion("s-exp->ast"): return return_value(deserialize_loop(bundle_map), env, cont)
def process_w_body_sexp(w_body, importss_list, exports, from_zo=False): body_forms_ls, body_length = to_rpython_list(w_body, unwrap_correlated=True) cur_toplevels = {} # make a recursive (!arbitrarily deep!) pass to find set!ed ids mutated = find_mutated(w_body) # {W_Symbol:None} # another pass to find toplevel defined ids all_toplevels = get_toplevel_defined_ids(body_forms_ls) variable_set_lines = 0 for d in all_toplevels: if d in exports: variable_set_lines += 1 # for each exported defined id, we need to add a variable-set! for # the exported var with the defined id total_forms_len = body_length + variable_set_lines body_forms = [None] * (total_forms_len) added = 0 current_index = 0 # this juggling is because we don't know how many extra ast forms # we're going to add for the exported defined ids for b in body_forms_ls: b_form = sexp_to_ast(b, [], exports, all_toplevels, importss_list, mutated) if not from_zo: # no need to normalize if it's alread normalized with PerfRegion("compile-normalize"): b_form = interp.Context.normalize_term(b_form) with PerfRegion("compile-assign-convert"): b_form = assign_convert(b_form) body_forms[current_index + added] = b_form current_index += 1 if isinstance(b_form, interp.DefineValues): for n in b_form.names: if n in exports: rator = interp.ModuleVar(var_set_sym, "#%kernel", var_set_sym, None) exp_var = interp.LinkletVar(exports[n].int_id) top_var = interp.ToplevelVar(n, is_free=False) mode = interp.Quote( values.w_false) # FIXME: possible optimization rands = [exp_var, top_var, mode] body_forms[current_index + added] = interp.App.make( rator, rands) added += 1 return body_forms
def read_linklet_cont(env, cont, _vals): from pycket.util import console_log from pycket.util import finish_perf_region bundle_map = check_one_val(_vals) finish_perf_region("fasl->s-exp") if not isinstance(bundle_map, W_HashTable): raise SchemeException("got something that is not a table: %s" % bundle_map.tostring()) console_log("BUNDLE SEXP FASL-READ from ZO: %s" % bundle_map.tostring(), 7) with PerfRegion("s-exp->ast"): return return_value(deserialize_loop(bundle_map), env, cont)
def load_bootstrap_linklet(which_str, debug, is_it_expander=False, generate_zo=False): with PerfRegion("%s-linklet" % which_str): console_log("Loading the %s linklet..." % which_str) linklet_file_path = locate_linklet("%s.rktl.linklet" % which_str) # load the linklet _instance, sys_config = load_inst_linklet_json(linklet_file_path, debug, set_version=is_it_expander, generate_zo=generate_zo) _instance.expose_vars_to_prim_env(excludes=syntax_primitives) if is_it_expander: from pycket.env import w_global_config w_global_config.set_config_val('expander_loaded', 1) return sys_config
def do_compile_linklet(form, name, import_keys, get_import, options, env, cont): from pycket.util import console_log if isinstance(form, W_WrappedConsProper): # s-expr # read it and create an AST, put it in a W_Linklet and return if not isinstance(form.car(), W_Symbol) or "linklet" != form.car().tostring(): raise SchemeException( "Malformed s-expr. Expected a linklet, got %s" % form.tostring()) else: w_name = W_Symbol.make("ad-hoc") if name is w_false else name # Process the imports w_importss = form.cdr().car() importss = get_imports_from_w_importss_sexp(w_importss) # list of directories (one for each import group) # importss_list ==> [[Import ...] ...] # Process the exports w_exports = form.cdr().cdr().car() exports = get_exports_from_w_exports_sexp(w_exports) # exports ==> {int_id:Export ...} # Process the body w_body = form.cdr().cdr().cdr() with PerfRegion("compile-sexp-to-ast"): body_forms = process_w_body_sexp(w_body, importss, exports) linkl = W_Linklet(w_name, importss, exports, body_forms) console_log("compiled linklet : %s" % (linkl.tostring()), 6) if import_keys is w_false: return return_value_direct(linkl, env, cont) else: return return_multi_vals(Values.make([linkl, import_keys]), env, cont) elif isinstance(form, W_Linklet): if import_keys is w_false: return return_value_direct(form, env, cont) else: return return_multi_vals(Values.make([form, import_keys]), env, cont) else: # correlated # take the AST from the correlated and put it in a W_Linklet and return raise SchemeException("NYI")
def loads(s): if not we_are_translated(): import json from pycket.util import PerfRegion data = json.loads(s) with PerfRegion("json_convert"): return _convert(data) decoder = OwnJSONDecoder(s) try: w_res = decoder.decode_any(0) i = decoder.skip_whitespace(decoder.pos) if i < len(s): start = i end = len(s) - 1 raise ValueError("Extra data: char %d - %d" % (start, end)) return w_res finally: decoder.close()
def load_linklet(json_file_name, set_version=False): from pycket.expand import readfile_rpython, getkey, JsonLoader from pycket.util import console_log from pycket.env import w_version """ Expands and loads a linklet from a JSON file""" with PerfRegion("json-load"): data = readfile_rpython(json_file_name) json = pycket_json.loads(data) console_log("Finished reading JSON from %s" % json_file_name, 2) assert json.is_object json_python_dict = json.value_object() assert "linklet" in json_python_dict linklet_dict = getkey(json_python_dict, "linklet", type='o') assert "exports" in linklet_dict and "body" in linklet_dict # list of JsonObject exports_list = getkey(linklet_dict, "exports", type='a') if set_version: from pycket.util import console_log conf = getkey(linklet_dict, "config", type='o') ver = conf['version'].value_string() console_log("Setting the version to %s" % ver) w_version.set_version(ver) exports = {} for exp in exports_list: if exp.is_array: arr = exp.value_array() internal_str = arr[0].value_object()['quote'].value_object( )['toplevel'].value_string() internal_name = W_Symbol.make(internal_str) external_name = W_Symbol.make( arr[1].value_object()['quote'].value_object() ['toplevel'].value_string()) w_internal_name = Gensym.gensym(internal_str) exports[internal_name] = Export(w_internal_name, external_name) else: exp_str = exp.value_object()['quote'].value_object( )['toplevel'].value_string() exp_sym = W_Symbol.make(exp_str) w_exp_sym = Gensym.gensym(exp_str) exports[exp_sym] = Export(w_exp_sym, exp_sym) imports_list = getkey(linklet_dict, "importss", type='a', default=[]) importss = [None] * len(imports_list) # list of dict if "importss" in linklet_dict: for index, imports in enumerate(imports_list): arr = imports.value_array() # bootstrap linklets have no imports at all # this is only for debugging purposes instance_imports = [] for id_str in arr: imp_str = id_str.value_object()['quote'].value_object( )['toplevel'].value_string() imp_sym = W_Symbol.make(imp_str) w_imp_sym = Gensym.gensym(imp_str) instance_imports.append( Import(W_Fixnum(index), imp_sym, w_imp_sym, w_imp_sym)) importss[index] = instance_imports console_log("Converting linklet forms to AST ...", 2) loader = JsonLoader() with PerfRegion("json-to-ast"): all_forms = [] for body_form in getkey(linklet_dict, "body", type='a'): form_2 = loader.to_ast(body_form) form_1 = Context.normalize_term(form_2) form = assign_convert(form_1) all_forms.append(form) # for each exported defined id, we need to add a # variable-set! for the exported var with the defined id for exp_sym, exp_obj in exports.iteritems(): rator = ModuleVar(var_set_sym, "#%kernel", var_set_sym, None) exp_var = LinkletVar(exp_obj.int_id) top_var = ToplevelVar(exp_sym) mode = Quote(values.w_false) # FIXME: possible optimization rands = [exp_var, top_var, mode] all_forms.append(App.make(rator, rands)) linkl = W_Linklet(W_Symbol.make(json_file_name), importss, exports, all_forms) console_log("Finished converting linklet forms to AST ...", 2) config = {} config_obj = getkey(linklet_dict, "config", type='o') if config_obj is not None: for k, v in config_obj.iteritems(): config[k] = v.value_string() return linkl, config
def load_linklet(json_file_name, set_version=False, generate_zo=False): from pycket.expand import readfile_rpython, getkey, JsonLoader from pycket.util import console_log from pycket.env import w_version import os if generate_zo: try: os.remove("expander.zo") except OSError: pass if set_version and os.path.exists("expander.zo"): console_log("Loading the expander linklet from expander.zo") # We're loading the expander, so try fasl->sexp from pycket.racket_entry import get_primitive from pycket.prims.input_output import open_input_file with PerfRegion("expander-linklet"): fasl_to_s_exp = get_primitive("fasl->s-exp") in_file = open_input_file.w_prim.call_interpret( [W_Path("expander.zo")]) try: expander_zo_sexp = fasl_to_s_exp.call_interpret( [in_file, w_true]) version = expander_zo_sexp.car() expander_sexp = expander_zo_sexp.cdr() expander_linkl = deserialize_loop(expander_sexp) w_version.set_version(version.tostring()) console_log("Setting the version to %s" % version.tostring()) return expander_linkl, None except (SchemeException, OSError): console_log("Couldn't read from expander.zo") """ Expands and loads a linklet from a JSON file""" with PerfRegion("json-load"): data = readfile_rpython(json_file_name) json = pycket_json.loads(data) console_log("Finished reading JSON from %s" % json_file_name, 2) assert json.is_object json_python_dict = json.value_object() assert "linklet" in json_python_dict linklet_dict = getkey(json_python_dict, "linklet", type='o') assert "exports" in linklet_dict and "body" in linklet_dict # list of JsonObject exports_list = getkey(linklet_dict, "exports", type='a') if set_version: from pycket.util import console_log conf = getkey(linklet_dict, "config", type='o') ver = conf['version'].value_string() console_log("Setting the version to %s" % ver) w_version.set_version(ver) exports = {} for exp in exports_list: if exp.is_array: arr = exp.value_array() internal_str = arr[0].value_object()['quote'].value_object( )['toplevel'].value_string() internal_name = W_Symbol.make(internal_str) external_name = W_Symbol.make( arr[1].value_object()['quote'].value_object() ['toplevel'].value_string()) w_internal_name = Gensym.gensym(internal_str) exports[internal_name] = Export(w_internal_name, external_name) else: exp_str = exp.value_object()['quote'].value_object( )['toplevel'].value_string() exp_sym = W_Symbol.make(exp_str) w_exp_sym = Gensym.gensym(exp_str) exports[exp_sym] = Export(w_exp_sym, exp_sym) imports_list = getkey(linklet_dict, "importss", type='a', default=[]) importss = [None] * len(imports_list) # list of dict if "importss" in linklet_dict: for index, imports in enumerate(imports_list): arr = imports.value_array() # bootstrap linklets have no imports at all # this is only for debugging purposes instance_imports = [] for id_str in arr: imp_str = id_str.value_object()['quote'].value_object( )['toplevel'].value_string() imp_sym = W_Symbol.make(imp_str) w_imp_sym = Gensym.gensym(imp_str) instance_imports.append( Import(W_Fixnum(index), imp_sym, w_imp_sym, w_imp_sym)) importss[index] = instance_imports console_log("Converting linklet forms to AST ...", 2) loader = JsonLoader() with PerfRegion("json-to-ast"): all_forms = [] for body_form in getkey(linklet_dict, "body", type='a'): form_2 = loader.to_ast(body_form) form_1 = Context.normalize_term(form_2) # if form_1.tostring() != form_2.tostring(): # import pdb;pdb.set_trace() form = assign_convert(form_1) all_forms.append(form) # for each exported defined id, we need to add a # variable-set! for the exported var with the defined id for exp_sym, exp_obj in exports.iteritems(): rator = ModuleVar(var_set_sym, "#%kernel", var_set_sym, None) exp_var = LinkletStaticVar(exp_obj.int_id) top_var = ToplevelVar(exp_sym) mode = Quote(values.w_false) # FIXME: possible optimization rands = [exp_var, top_var, mode] all_forms.append(App.make(rator, rands)) linkl = W_Linklet(W_Symbol.make(json_file_name), importss, exports, all_forms) console_log("Finished converting linklet forms to AST ...", 2) config = {} config_obj = getkey(linklet_dict, "config", type='o') if config_obj is not None: for k, v in config_obj.iteritems(): config[k] = v.value_string() if set_version and not os.path.exists("expander.zo"): console_log("Serializing the expander linklet into expander.zo") from pycket.racket_entry import get_primitive from pycket.prims.input_output import open_output_file s_exp_to_fasl = get_primitive("s-exp->fasl") expander_sexp = ast_to_sexp(linkl) version = W_Symbol.make(w_version.get_version()) expander_zo_sexp = W_Cons.make(version, expander_sexp) try: out_file = open_output_file.w_prim.call_interpret( [W_Path("expander.zo")]) s_exp_to_fasl.call_interpret( [expander_zo_sexp, out_file, values.w_false]) except (SchemeException, OSError): console_log("Couldn't write the expander.zo") return linkl, config
def deserialize_loop(sexp): from pycket.prims.linklet import W_Linklet, W_LinkletBundle, W_LinkletDirectory from pycket.env import w_global_config if isinstance(sexp, values.W_Cons): c = sexp.car() if c is dir_sym: dir_map = sexp.cdr() return W_LinkletDirectory(deserialize_loop(dir_map)) elif c is bundle_sym: bundle_map = sexp.cdr() return W_LinkletBundle(deserialize_loop(bundle_map)) elif looks_like_linklet(sexp): # Unify this with compile_linklet if isinstance(sexp.cdr().car(), values.W_List): w_name = mksym("anonymous") w_importss = sexp.cdr().car() w_exports = sexp.cdr().cdr().car() w_body = sexp.cdr().cdr().cdr() else: w_name = sexp.cdr().car() w_importss = sexp.cdr().cdr().car() w_exports = sexp.cdr().cdr().cdr().car() w_body = sexp.cdr().cdr().cdr().cdr() importss_list = deserialize_importss(w_importss) # Process the exports exports = deserialize_exports(w_exports) # Process the body with PerfRegion("compile-sexp-to-ast"): body_forms = process_w_body_sexp(w_body, importss_list, exports, from_zo=True) return W_Linklet(w_name, importss_list, exports, body_forms) else: # get the length ls = sexp length = 0 is_improper = False while ls is not values.w_null: if isinstance(ls, values.W_Cons): length += 1 ls = ls.cdr() else: is_improper = True ls = values.w_null # allocate an r_list (to avoid reversing w_list) if is_improper: sexp_ls = [None] * (length + 1) else: sexp_ls = [None] * length # second pass, get the elements ls = sexp for i in range(length - 1, -1, -1): sexp_ls[i] = ls.car() ls = ls.cdr() if is_improper: sexp_ls[length] = ls # make the new list new = values.w_null for s in sexp_ls: new = values.W_Cons.make(deserialize_loop(s), new) return new elif isinstance(sexp, simple.W_EqImmutableHashTable): l = sexp.length() keys = [None] * l vals = [None] * l i = 0 for k, v in sexp.iteritems(): keys[i] = k vals[i] = deserialize_loop(v) i += 1 return simple.make_simple_immutable_table( simple.W_EqImmutableHashTable, keys, vals) elif isinstance(sexp, equal.W_EqualHashTable): l = sexp.length() keys = [None] * l vals = [None] * l i = 0 for k, v in sexp.hash_items(): keys[i] = k vals[i] = deserialize_loop(v) i += 1 return equal.W_EqualHashTable(keys, vals, immutable=True) elif isinstance(sexp, vector.W_Vector): new = [None] * sexp.length() items = sexp.get_strategy().ref_all(sexp) for index, obj in enumerate(items): new[index] = deserialize_loop(obj) return vector.W_Vector.fromelements(new, sexp.immutable()) else: return sexp
def racket_entry(names, config, command_line_arguments): from pycket.prims.general import executable_yield_handler from pycket.values import W_Fixnum if config['make-zos']: make_bootstrap_zos() return 0 linklet_perf.init() loads, startup_options, flags = get_options(names, config) init_library = startup_options['init_library'][0] set_run_file = startup_options['set_run_file'][0] set_collects_dir = startup_options['set_collects_dir'][0] set_config_dir = startup_options['set_config_dir'][0] set_addon_dir = startup_options['set_addon_dir'][0] eval_sexp = startup_options['eval_sexp'][0] run_as_linklet = startup_options['run_as_linklet'][0] load_linklets = startup_options['load_linklets'] load_as_linklets = startup_options['load_as_linklets'] is_repl = flags['is_repl'] no_lib = flags['no_lib'] just_kernel = flags['just_kernel'] just_init = flags['just_init'] use_compiled = flags['use_compiled'] debug = flags['debug'] version = flags['version'] c_a = flags['compile_any'] do_load_regexp = flags['do_load_regexp'] dev_mode = flags['dev_mode'] if load_as_linklets: for rkt in load_as_linklets: create_linklet_json(rkt) load_inst_linklet("%s.linklet" % rkt) return 0 if load_linklets: load_linklets_at_startup(load_linklets) return 0 if dev_mode: dev_mode_entry(dev_mode, eval_sexp, run_as_linklet) return 0 with PerfRegion("startup"): initiate_boot_sequence(command_line_arguments, use_compiled, debug, set_run_file, set_collects_dir, set_config_dir, set_addon_dir, compile_any=c_a, do_load_regexp=do_load_regexp) if just_init: return 0 namespace_require = get_primitive("namespace-require") load = get_primitive("load") if just_kernel: console_log("Running on just the #%kernel") namespace_require_kernel() if not no_lib: with PerfRegion("init-lib"): init_lib = W_WrappedConsProper.make(W_Symbol.make("lib"), W_WrappedConsProper.make(W_String.make(init_library), w_null)) console_log("(namespace-require %s) ..." % init_lib.tostring()) namespace_require_plus(init_lib) console_log("Init lib : %s loaded..." % (init_library)) put_newline = False if loads: for rator_str, rand_str in loads: if rator_str == "load": # -f console_log("(load %s)" % (rand_str)) load.call_interpret([W_String.make(rand_str)]) elif rator_str == "file" or rator_str == "lib": # -t & -l require_spec = W_WrappedConsProper.make(W_Symbol.make(rator_str), W_WrappedConsProper.make(W_String.make(rand_str), w_null)) console_log("(namespace-require '(%s %s))" % (rator_str, rand_str)) namespace_require_plus(require_spec) elif rator_str == "eval": # -e console_log("(eval (read (open-input-string %s)))" % rand_str) read_eval_print_string(rand_str, False, debug) if version: from pycket.env import w_version print("Welcome to Pycket v%s" % w_version.get_version()) if is_repl: # -i put_newline = True dynamic_require = get_primitive("dynamic-require") repl = dynamic_require.call_interpret([W_Symbol.make("racket/repl"), W_Symbol.make("read-eval-print-loop")]) from pycket.env import w_global_config w_global_config.set_config_val('repl_loaded', 1) repl.call_interpret([]) if put_newline: print linklet_perf.print_report() # we just want the global value anyway eyh = executable_yield_handler.call_interpret([]) eyh.call_interpret([W_Fixnum.ZERO]) exit = get_primitive("exit") exit.call_interpret([]) return 0
def initiate_boot_sequence(command_line_arguments, use_compiled=False, debug=False, set_run_file="", set_collects_dir="", set_config_dir="", set_addon_dir="", compile_any=False, do_load_regexp=False): from pycket.env import w_version load_bootstrap_linklets(debug, do_load_regexp=do_load_regexp) with PerfRegion("set-params"): # These need to be set before the boot sequence if set_run_file: console_log("Setting the 'run-file path to %s" % set_run_file) set_path("run-file", set_run_file) if set_collects_dir: console_log("Setting the 'collects-dir path to %s" % set_collects_dir) set_path("collects-dir", set_collects_dir) if set_config_dir: console_log("Setting the 'config-dir path to %s" % set_config_dir) set_path("config-dir", set_config_dir) if set_addon_dir: console_log("Setting the 'addon-dir path to %s" % set_addon_dir) set_path("addon-dir", set_addon_dir) # Set the cmd arguments for racket ccla = get_primitive("current-command-line-arguments") ccla.call_interpret([W_Vector.fromelements(command_line_arguments)]) # Run "boot" to set things like (current-module-name-resolver) (o/w it's going to stay as the # "core-module-name-resolver" which can't recognize modules like 'racket/base (anything other than # things like '#%kernel really) console_log("Entering Boot Sequence") console_log("(boot)") boot = get_primitive("boot") boot.call_interpret([]) console_log("(current-library-collection-links (find-library-collection-links))") flcl = get_primitive("find-library-collection-links") lib_coll_links = flcl.call_interpret([]) clcl = get_primitive("current-library-collection-links") clcl.call_interpret([lib_coll_links]) console_log("(current-library-collection-paths (find-library-collection-paths))") flcp = get_primitive("find-library-collection-paths") lib_coll_paths = flcp.call_interpret([]) clcp = get_primitive("current-library-collection-paths") clcp.call_interpret([lib_coll_paths]) console_log("(read-accept-compiled true)") read_accept_compiled = get_primitive("read-accept-compiled") read_accept_compiled.call_interpret([w_true]) compiled_file_path = "compiled/pycket" ucfp = get_primitive("use-compiled-file-paths") if use_compiled: console_log("(use-compiled-file-paths %s)" % compiled_file_path) ucfp.call_interpret([W_WrappedConsProper.make(W_String.make(compiled_file_path), w_null)]) else: ucfp.call_interpret([w_null]) console_log("(use-compiled-file-paths null)") cctm = get_primitive("current-compile-target-machine") if compile_any: cctm.call_interpret([w_false]) # set the current directory to the current directory import os c_dir = os.getcwd() console_log("(current-directory %s)" % c_dir) # We can't call the current-directory like a primitive # because it prints a report to stdout from pycket.values_parameter import top_level_config from pycket.prims.general import current_directory_param c = top_level_config.get(current_directory_param) assert isinstance(c, W_ThreadCell) c.set(W_Path(c_dir)) console_log("...Boot Sequence Completed") from pycket.env import w_global_config as glob glob.boot_is_completed() return 0