Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
38fa581e
Commit
38fa581e
authored
Jun 25, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the stdlib dir to sys.path, so now the stdlib is importable!
(Though most libraries will probably crash)
parent
e806062d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
3 deletions
+21
-3
src/core/types.h
src/core/types.h
+2
-1
src/jit.cpp
src/jit.cpp
+11
-1
src/runtime/builtin_modules/sys.cpp
src/runtime/builtin_modules/sys.cpp
+7
-1
test/tests/import_stdlib_test.py
test/tests/import_stdlib_test.py
+1
-0
No files found.
src/core/types.h
View file @
38fa581e
...
...
@@ -453,7 +453,8 @@ BoxedModule* createModule(const std::string& name, const std::string& fn);
std
::
string
getPythonFuncAt
(
void
*
ip
,
void
*
sp
);
// TODO where to put this
void
addToSysPath
(
const
std
::
string
&
path
);
void
appendToSysPath
(
const
std
::
string
&
path
);
void
prependToSysPath
(
const
std
::
string
&
path
);
void
addToSysArgv
(
const
char
*
str
);
std
::
string
formatException
(
Box
*
e
);
...
...
src/jit.cpp
View file @
38fa581e
...
...
@@ -112,6 +112,16 @@ int main(int argc, char** argv) {
addToSysArgv
(
""
);
}
std
::
string
self_path
=
llvm
::
sys
::
fs
::
getMainExecutable
(
argv
[
0
],
(
void
*
)
main
);
assert
(
self_path
.
size
());
llvm
::
SmallString
<
128
>
stdlib_dir
(
self_path
);
llvm
::
sys
::
path
::
remove_filename
(
stdlib_dir
);
// executable name
llvm
::
sys
::
path
::
remove_filename
(
stdlib_dir
);
// "src/" dir
llvm
::
sys
::
path
::
append
(
stdlib_dir
,
"lib_python"
);
llvm
::
sys
::
path
::
append
(
stdlib_dir
,
"2.7"
);
appendToSysPath
(
stdlib_dir
.
c_str
());
// end of argument parsing
_t
.
split
(
"to run"
);
...
...
@@ -130,7 +140,7 @@ int main(int argc, char** argv) {
llvm
::
sys
::
path
::
append
(
path
,
fn
);
llvm
::
sys
::
path
::
remove_filename
(
path
);
ad
dToSysPath
(
path
.
str
());
prepen
dToSysPath
(
path
.
str
());
int
num_iterations
=
1
;
if
(
BENCH
)
...
...
src/runtime/builtin_modules/sys.cpp
View file @
38fa581e
...
...
@@ -58,11 +58,17 @@ void addToSysArgv(const char* str) {
listAppendInternal
(
sys_argv
,
boxStrConstant
(
str
));
}
void
a
d
dToSysPath
(
const
std
::
string
&
path
)
{
void
a
ppen
dToSysPath
(
const
std
::
string
&
path
)
{
BoxedList
*
sys_path
=
getSysPath
();
listAppendInternal
(
sys_path
,
boxStringPtr
(
&
path
));
}
void
prependToSysPath
(
const
std
::
string
&
path
)
{
BoxedList
*
sys_path
=
getSysPath
();
static
std
::
string
attr
=
"insert"
;
callattr
(
sys_path
,
&
attr
,
false
,
ArgPassSpec
(
2
),
boxInt
(
0
),
new
BoxedString
(
path
),
NULL
,
NULL
,
NULL
);
}
void
setupSys
()
{
sys_modules_dict
=
new
BoxedDict
();
gc
::
registerStaticRootObj
(
sys_modules_dict
);
...
...
test/tests/import_stdlib_test.py
0 → 100644
View file @
38fa581e
import
this
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