Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb7d748c

Browse files
Moves Python code out of interpreter file (pyscript#207)
* make copy of .py files part of build process* move code out ofinterpreter file and make it download and load code during initialization* fix double ; in interpreter* remove debugging print* update dependencies* fix project name and version* [pre-commit.ci] auto fixes from pre-commit.com hooksfor more information, seehttps://pre-commit.ci* lint* [pre-commit.ci] auto fixes from pre-commit.com hooksfor more information, seehttps://pre-commit.ci* change fmt-py* lint* [pre-commit.ci] auto fixes from pre-commit.com hooksfor more information, seehttps://pre-commit.ci* remove extra content* define missing strict type* create build folder if doesn't existCo-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent88a0dd3 commitb7d748c

File tree

14 files changed

+405
-538
lines changed

14 files changed

+405
-538
lines changed

‎pyscriptjs/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fmt: fmt-py fmt-ts
5656
@echo"Format completed"
5757

5858
.PHONY: fmt-check
59-
fmt-check: fmt-ts-check fmt-py
59+
fmt-check: fmt-ts-check fmt-py-check
6060
@echo"Format check completed"
6161

6262
.PHONY: fmt-ts
@@ -69,7 +69,8 @@ fmt-ts-check:
6969

7070
.PHONY: fmt-py
7171
fmt-py:
72-
$(conda_run) black -l 88.
72+
$(conda_run) black --skip-string-normalization.
73+
$(conda_run) isort --profile black.
7374

7475
.PHONY: fmt-py-check
7576
fmt-py-check:

‎pyscriptjs/environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ dependencies:
99
-black
1010
-isort
1111
-codespell
12+
-pre-commit

‎pyscriptjs/examples/micrograd_ai.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ def loss(batch_size=None):
153153
plt.ylim(yy.min(),yy.max())
154154

155155
finish=datetime.datetime.now()
156-
# print(f"It took {(finish-start).seconds} seconds to run this code.")
157156
print_div(f"It took{(finish-start).seconds} seconds to run this code.")
158157

159158
plt

‎pyscriptjs/package-lock.json

Lines changed: 51 additions & 51 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎pyscriptjs/package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name":"svelte-app",
3-
"version":"1.0.0",
2+
"name":"pyscript",
3+
"version":"0.0.1",
44
"scripts": {
55
"build":"NODE_ENV=production rollup -c",
66
"dev":"rollup -c -w",
@@ -15,36 +15,36 @@
1515
"devDependencies": {
1616
"@rollup/plugin-commonjs":"^17.0.0",
1717
"@rollup/plugin-node-resolve":"^11.0.0",
18-
"@rollup/plugin-typescript":"^8.1.0",
18+
"@rollup/plugin-typescript":"^8.3.2",
1919
"@tsconfig/svelte":"^1.0.0",
2020
"@typescript-eslint/eslint-plugin":"^5.20.0",
2121
"@typescript-eslint/parser":"^5.20.0",
22-
"autoprefixer":"^10.2.3",
22+
"autoprefixer":"^10.4.7",
2323
"eslint":"^8.14.0",
2424
"eslint-plugin-svelte3":"^3.4.1",
25-
"postcss":"^8.2.4",
25+
"postcss":"^8.4.13",
2626
"prettier":"^2.6.2",
2727
"prettier-plugin-svelte":"^2.7.0",
28-
"rollup":"^2.3.4",
28+
"rollup":"^2.71.1",
2929
"rollup-plugin-css-only":"^3.1.0",
3030
"rollup-plugin-livereload":"^2.0.0",
3131
"rollup-plugin-serve":"^1.1.0",
3232
"rollup-plugin-svelte":"^7.0.0",
3333
"rollup-plugin-terser":"^7.0.0",
34-
"svelte":"^3.0.0",
34+
"svelte":"^3.48.0",
3535
"svelte-check":"^1.0.0",
36-
"svelte-preprocess":"^4.6.3",
36+
"svelte-preprocess":"^4.10.6",
3737
"tailwindcss":"^2.0.2",
38-
"tslib":"^2.0.0",
39-
"typescript":"^4.1.3"
38+
"tslib":"^2.4.0",
39+
"typescript":"^4.6.4"
4040
},
4141
"dependencies": {
4242
"@codemirror/basic-setup":"^0.19.1",
43-
"@codemirror/lang-python":"^0.19.4",
43+
"@codemirror/lang-python":"^0.19.5",
4444
"@codemirror/state":"^0.19.9",
4545
"@codemirror/theme-one-dark":"^0.19.1",
4646
"@fortawesome/free-solid-svg-icons":"^6.0.0",
47-
"codemirror":"^5.65.2",
47+
"codemirror":"^5.65.3",
4848
"js-yaml":"^4.1.0",
4949
"sirv-cli":"^1.0.0",
5050
"svelte-fa":"^2.4.0",

‎pyscriptjs/rollup.config.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,43 @@ import { terser } from "rollup-plugin-terser";
66
importsveltePreprocessfrom"svelte-preprocess";
77
importtypescriptfrom"@rollup/plugin-typescript";
88
importcssfrom"rollup-plugin-css-only";
9-
importservefrom'rollup-plugin-serve'
9+
importservefrom'rollup-plugin-serve';
10+
11+
importpathfrom"path";
12+
importfsfrom"fs";
13+
14+
functioncopyPythonFiles(from,to,overwrite=false){
15+
return{
16+
name:'copy-files',
17+
generateBundle(){
18+
constlog=msg=>console.log('\x1b[36m%s\x1b[0m',msg)
19+
log(`copy files:${from}${to}`)
20+
21+
// create folder if it doesn't exist
22+
if(!fs.existsSync(to)){
23+
log(`Destination folder${to} doesn't exist. Creating...`)
24+
fs.mkdirSync(to);
25+
}
26+
27+
fs.readdirSync(from).forEach(file=>{
28+
constfromFile=`${from}/${file}`
29+
consttoFile=`${to}/${file}`
30+
if(fromFile.endsWith(`.py`)){
31+
log(`---->${fromFile}${toFile}`)
32+
if(fs.existsSync(toFile)&&!overwrite){
33+
log(`skipping${fromFile}${toFile}`)
34+
return
35+
}else{
36+
fs.copyFileSync(
37+
path.resolve(fromFile),
38+
path.resolve(toFile)
39+
);
40+
}
41+
}
42+
})
43+
}
44+
}
45+
}
1046

1147
constproduction=!process.env.ROLLUP_WATCH||(process.env.NODE_ENV==="production");
1248

@@ -68,6 +104,8 @@ export default {
68104
sourceMap:!production,
69105
inlineSources:!production,
70106
}),
107+
// Copy all the python files from source to the build folder
108+
copyPythonFiles("./src/","./examples/build",true),
71109
!production&&serve(),
72110
!production&&livereload("public"),
73111
production&&terser(),

‎pyscriptjs/src/App.svelte

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
<scriptlang="ts">
22
importTailwindfrom'./Tailwind.svelte';
33
import {loadInterpreter }from'./interpreter';
4-
import {
5-
initializers,
6-
loadedEnvironments,
7-
mode,
8-
postInitializers,
9-
pyodideLoaded,
10-
scriptsQueue,
11-
}from'./stores';
4+
import {initializers,loadedEnvironments,mode,postInitializers,pyodideLoaded,scriptsQueue }from'./stores';
125
136
let pyodideReadyPromise;
147

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp