Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyodide
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
pyodide
Commits
1287eebd
Commit
1287eebd
authored
Nov 12, 2018
by
Michael Droettboom
Committed by
GitHub
Nov 12, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #249 from mdboom/bytecode
Improve handling of bytecode files
parents
14a52f00
f0ff58e7
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
4 deletions
+50
-4
packages/pytest/meta.yaml
packages/pytest/meta.yaml
+1
-1
pyodide_build/buildpkg.py
pyodide_build/buildpkg.py
+1
-1
src/main.c
src/main.c
+14
-1
test/test_common.py
test/test_common.py
+34
-1
No files found.
packages/pytest/meta.yaml
View file @
1287eebd
pyodide_build/buildpkg.py
View file @
1287eebd
...
@@ -133,7 +133,7 @@ def package_files(buildpath, srcpath, pkg, args):
...
@@ -133,7 +133,7 @@ def package_files(buildpath, srcpath, pkg, args):
'--js-output={}'
.
format
(
name
+
'.js'
),
'--js-output={}'
.
format
(
name
+
'.js'
),
'--export-name=pyodide._module'
,
'--export-name=pyodide._module'
,
'--exclude'
,
'*.wasm.pre'
,
'--exclude'
,
'*.wasm.pre'
,
'--exclude'
,
'
__pycache__
'
,
'--exclude'
,
'
*__pycache__*
'
,
'--use-preload-plugins'
],
'--use-preload-plugins'
],
cwd
=
buildpath
,
check
=
True
)
cwd
=
buildpath
,
check
=
True
)
subprocess
.
run
([
subprocess
.
run
([
...
...
src/main.c
View file @
1287eebd
...
@@ -41,11 +41,24 @@ main(int argc, char** argv)
...
@@ -41,11 +41,24 @@ main(int argc, char** argv)
{
{
hiwire_setup
();
hiwire_setup
();
setenv
(
"PYTHONDONTWRITEBYTECODE"
,
"1"
,
0
);
setenv
(
"PYTHONHOME"
,
"/"
,
0
);
setenv
(
"PYTHONHOME"
,
"/"
,
0
);
Py_InitializeEx
(
0
);
Py_InitializeEx
(
0
);
// This doesn't seem to work anymore, but I'm keeping it for good measure
// anyway The effective way to turn this off is below: setting
// sys.done_write_bytecode = True
setenv
(
"PYTHONDONTWRITEBYTECODE"
,
"1"
,
0
);
PyObject
*
sys
=
PyImport_ImportModule
(
"sys"
);
if
(
sys
==
NULL
)
{
return
1
;
}
if
(
PyObject_SetAttrString
(
sys
,
"dont_write_bytecode"
,
Py_True
))
{
return
1
;
}
Py_DECREF
(
sys
);
if
(
js2python_init
()
||
JsImport_init
()
||
JsProxy_init
()
||
if
(
js2python_init
()
||
JsImport_init
()
||
JsProxy_init
()
||
pyimport_init
()
||
pyproxy_init
()
||
python2js_init
()
||
pyimport_init
()
||
pyproxy_init
()
||
python2js_init
()
||
runpython_init_js
()
||
runpython_init_py
()
||
runpython_finalize_js
())
{
runpython_init_js
()
||
runpython_init_py
()
||
runpython_finalize_js
())
{
...
...
test/test_common.py
View file @
1287eebd
...
@@ -49,10 +49,43 @@ def test_import(name, selenium_standalone):
...
@@ -49,10 +49,43 @@ def test_import(name, selenium_standalone):
'{} fails to load and is not supported on {}.'
'{} fails to load and is not supported on {}.'
.
format
(
name
,
selenium_standalone
.
browser
))
.
format
(
name
,
selenium_standalone
.
browser
))
for
import_name
in
meta
.
get
(
'test'
,
{}).
get
(
'imports'
,
[]):
selenium_standalone
.
run
(
"import glob, os"
)
baseline_pyc
=
selenium_standalone
.
run
(
"""
len(list(glob.glob(
'/lib/python3.7/site-packages/**/*.pyc',
recursive=True)
))
"""
)
selenium_standalone
.
load_package
(
name
)
selenium_standalone
.
load_package
(
name
)
# Make sure there are no additional .pyc file
assert
selenium_standalone
.
run
(
"""
len(list(glob.glob(
'/lib/python3.7/site-packages/**/*.pyc',
recursive=True)
))
"""
)
==
baseline_pyc
for
import_name
in
meta
.
get
(
'test'
,
{}).
get
(
'imports'
,
[]):
try
:
try
:
selenium_standalone
.
run
(
'import %s'
%
import_name
)
selenium_standalone
.
run
(
'import %s'
%
import_name
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
selenium_standalone
.
logs
)
print
(
selenium_standalone
.
logs
)
raise
raise
# Make sure that even after importing, there are no additional .pyc
# files
assert
selenium_standalone
.
run
(
"""
len(list(glob.glob(
'/lib/python3.7/site-packages/**/*.pyc',
recursive=True)
))
"""
)
==
baseline_pyc
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment