Skip to content

Commit

Permalink
Fix custom components on windows (#8531)
Browse files Browse the repository at this point in the history
* Fix usability windows

* Add config.js

* Add code

* revert pnpm.lock'

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
freddyaboulton and gradio-pr-bot authored Jun 13, 2024
1 parent a4433be commit 88de38e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/slick-ducks-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/preview": patch
"gradio": patch
---

fix:Fix custom components on windows
2 changes: 1 addition & 1 deletion gradio/cli/commands/components/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def _build(
package_name = get_deep(pyproject_toml, ["project", "name"])

python_path = _get_executable_path(
"python", None, "--python-path", check_3=True
"python", python_path, "--python-path", check_3=True
)

if not isinstance(package_name, str):
Expand Down
4 changes: 3 additions & 1 deletion js/preview/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export async function make_build({
comp.frontend_dir &&
fs.existsSync(join(comp.frontend_dir, "gradio.config.js"))
) {
const m = await import(join(comp.frontend_dir, "gradio.config.js"));
const m = await import(
join("file://" + comp.frontend_dir, "gradio.config.js")
);

component_config.plugins = m.default.plugins || [];
component_config.svelte.preprocess = m.default.svelte?.preprocess || [];
Expand Down
6 changes: 3 additions & 3 deletions js/preview/src/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ async function generate_imports(
fs.existsSync(join(component.frontend_dir, "gradio.config.js"))
) {
const m = await import(
join(component.frontend_dir, "gradio.config.js")
join("file://" + component.frontend_dir, "gradio.config.js")
);

component_config.plugins = m.default.plugins || [];
Expand All @@ -184,13 +184,13 @@ async function generate_imports(
);

const example = exports.example
? `example: () => import("${to_posix(
? `example: () => import("/@fs/${to_posix(
join(component.frontend_dir, exports.example)
)}"),\n`
: "";
return `${acc}"${component.component_class_id}": {
${example}
component: () => import("${to_posix(
component: () => import("/@fs/${to_posix(
join(component.frontend_dir, exports.component)
)}")
},\n`;
Expand Down

0 comments on commit 88de38e

Please sign in to comment.