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
d2067f70
Commit
d2067f70
authored
Nov 08, 2018
by
Michael Droettboom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handling of bytecode files
parent
ff5b9e61
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
4 deletions
+78
-4
packages/pytest/meta.yaml
packages/pytest/meta.yaml
+2
-1
packages/pytest/patches/workaround_get_tag.patch
packages/pytest/patches/workaround_get_tag.patch
+12
-0
pyodide_build/buildpkg.py
pyodide_build/buildpkg.py
+1
-1
src/main.c
src/main.c
+30
-1
test/test_common.py
test/test_common.py
+33
-1
No files found.
packages/pytest/meta.yaml
View file @
d2067f70
...
...
@@ -8,6 +8,7 @@ source:
patches
:
-
patches/named-tmp-and-rm-dup2.patch
-
patches/workaround_get_tag.patch
requirements
:
run
:
...
...
packages/pytest/patches/workaround_get_tag.patch
0 → 100644
View file @
d2067f70
diff -ur pytest-3.6.3-bak/src/_pytest/assertion/rewrite.py pytest-3.6.3/src/_pytest/assertion/rewrite.py
--- pytest-3.6.3-bak/src/_pytest/assertion/rewrite.py 2018-11-08 14:58:43.984236991 -0500
+++ pytest-3.6.3/src/_pytest/assertion/rewrite.py 2018-11-08 14:59:59.881455735 -0500
@@ -19,7 +19,7 @@
# pytest caches rewritten pycs in __pycache__.
-if hasattr(imp, "get_tag"):
+if hasattr(imp, "get_tag") and imp.get_tag() is not None:
PYTEST_TAG = imp.get_tag() + "-PYTEST"
else:
if hasattr(sys, "pypy_version_info"):
pyodide_build/buildpkg.py
View file @
d2067f70
...
...
@@ -133,7 +133,7 @@ def package_files(buildpath, srcpath, pkg, args):
'--js-output={}'
.
format
(
name
+
'.js'
),
'--export-name=pyodide._module'
,
'--exclude'
,
'*.wasm.pre'
,
'--exclude'
,
'
__pycache__
'
,
'--exclude'
,
'
*__pycache__*
'
,
'--use-preload-plugins'
],
cwd
=
buildpath
,
check
=
True
)
subprocess
.
run
([
...
...
src/main.c
View file @
d2067f70
...
...
@@ -41,11 +41,40 @@ main(int argc, char** argv)
{
hiwire_setup
();
setenv
(
"PYTHONDONTWRITEBYTECODE"
,
"1"
,
0
);
setenv
(
"PYTHONHOME"
,
"/"
,
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
))
{
Py_DECREF
(
sys
);
return
1
;
}
// By disabling the cache_tag, Python won't look for cached bytecode files when
// importing modules, which saves on filesystem I/O time
PyObject
*
implementation
=
PyObject_GetAttrString
(
sys
,
"implementation"
);
if
(
implementation
==
NULL
)
{
Py_DECREF
(
sys
);
return
1
;
}
if
(
PyObject_SetAttrString
(
implementation
,
"cache_tag"
,
Py_None
))
{
Py_DECREF
(
implementation
);
Py_DECREF
(
sys
);
return
1
;
}
Py_DECREF
(
implementation
);
Py_DECREF
(
sys
);
if
(
js2python_init
()
||
JsImport_init
()
||
JsProxy_init
()
||
pyimport_init
()
||
pyproxy_init
()
||
python2js_init
()
||
runpython_init_js
()
||
runpython_init_py
()
||
runpython_finalize_js
())
{
...
...
test/test_common.py
View file @
d2067f70
...
...
@@ -49,10 +49,42 @@ def test_import(name, selenium_standalone):
'{} fails to load and is not supported on {}.'
.
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
)
# 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
:
selenium_standalone
.
run
(
'import %s'
%
import_name
)
except
Exception
as
e
:
print
(
selenium_standalone
.
logs
)
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