Skip to content

Commit

Permalink
fs api (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerThorsten authored Jun 13, 2024
1 parent 3f961ed commit d087ca6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ jobs:
environment-file: environment-dev.yml
environment-name: pyjs-wasm

# temporary: install pyjs_code_runner from source
- name: Install pyjs_code_runner
shell: bash -el {0}
run: |
python -m pip install git+https://github.com/emscripten-forge/pyjs-code-runner.git@main --no-deps --no-build-isolation

- name: Install Playwright
run: |
Expand Down
1 change: 1 addition & 0 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ dependencies:
- hatchling
- pip:
- JLDracula
- pyjs_code_runner >= 3.0
2 changes: 1 addition & 1 deletion include/pyjs/pre_js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Module['init_phase_1'] = async function(prefix, python_version) {
}


Module.FS.mkdirTree(side_path);
Module.create_directories(side_path);


Module["_interpreter"] = new Module["_Interpreter"]()
Expand Down
12 changes: 12 additions & 0 deletions src/export_js_module.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <iostream>
#include <filesystem>

#include <pyjs/export_py_object.hpp>
#include <pyjs/convert.hpp>
Expand Down Expand Up @@ -79,6 +80,14 @@ namespace pyjs
setenv(key.c_str(), value.c_str(), 1);
}

void create_directories(const std::string & p)
{
std::filesystem::create_directories(std::filesystem::path(p));
}
bool is_directory(const std::string & p)
{
return std::filesystem::is_directory(std::filesystem::path(p));
}

void export_js_module()
{
Expand All @@ -91,6 +100,9 @@ namespace pyjs
em::function("_exec", &exec);
em::function("_eval_file", &eval_file);

em::function("create_directories", &create_directories);
em::function("is_directory", &is_directory);


em::function("_untar", &untar);
em::function("setenv", &set_env);
Expand Down

0 comments on commit d087ca6

Please sign in to comment.