Commit b655ef4d authored by Kevin Modzelewski's avatar Kevin Modzelewski

Some sys-module variables

parent e66e20a3
......@@ -18,6 +18,9 @@ namespace pyston {
int GLOBAL_VERBOSITY = 0;
int PYSTON_VERSION_MAJOR = 0;
int PYSTON_VERSION_MINOR = 2;
int PYTHON_VERSION_MAJOR = DEFAULT_PYTHON_MAJOR_VERSION;
int PYTHON_VERSION_MINOR = DEFAULT_PYTHON_MINOR_VERSION;
int PYTHON_VERSION_MICRO = DEFAULT_PYTHON_MICRO_VERSION;
......
......@@ -21,6 +21,7 @@ extern "C" {
extern int GLOBAL_VERBOSITY;
#define VERBOSITY(x) GLOBAL_VERBOSITY
extern int PYSTON_VERSION_MAJOR, PYSTON_VERSION_MINOR;
// Version number we're targeting:
extern int PYTHON_VERSION_MAJOR, PYTHON_VERSION_MINOR, PYTHON_VERSION_MICRO, PYTHON_VERSION_HEX;
......
......@@ -153,7 +153,7 @@ int main(int argc, char** argv) {
}
if (repl) {
printf("Pyston v0.2 (rev " STRINGIFY(GITREV) ")");
printf("Pyston v%d.%d (rev " STRINGIFY(GITREV) ")", PYSTON_VERSION_MAJOR, PYSTON_VERSION_MINOR);
printf(", targeting Python %d.%d.%d\n", PYTHON_VERSION_MAJOR, PYTHON_VERSION_MINOR, PYTHON_VERSION_MICRO);
if (!main_module) {
......
......@@ -14,6 +14,10 @@
#include <algorithm>
#include <cmath>
#include <sstream>
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "core/types.h"
#include "gc/collector.h"
......@@ -99,6 +103,14 @@ public:
}
};
static std::string generateVersionString() {
std::ostringstream oss;
oss << PYTHON_VERSION_MAJOR << '.' << PYTHON_VERSION_MINOR << '.' << PYTHON_VERSION_MICRO;
oss << '\n';
oss << "[Pyston " << PYSTON_VERSION_MAJOR << '.' << PYSTON_VERSION_MINOR << "]";
return oss.str();
}
void setupSys() {
sys_modules_dict = new BoxedDict();
gc::registerPermanentRoot(sys_modules_dict);
......@@ -122,6 +134,16 @@ void setupSys() {
sys_module->giveAttr("platform", boxStrConstant("unknown")); // seems like a reasonable, if poor, default
llvm::SmallString<128> main_fn;
// TODO supposed to pass argv0, main_addr to this function:
main_fn = llvm::sys::fs::getMainExecutable(NULL, NULL);
sys_module->giveAttr("executable", boxString(main_fn.str()));
// TODO: should configure this in a better way
sys_module->giveAttr("prefix", boxStrConstant("/usr"));
sys_module->giveAttr("exec_prefix", boxStrConstant("/usr"));
sys_module->giveAttr("version", boxString(generateVersionString()));
sys_module->giveAttr("hexversion", boxInt(PY_VERSION_HEX));
sys_module->giveAttr("maxint", boxInt(PYSTON_INT_MAX));
......
# allow-warning: converting unicode literal to str
import sys
import os.path
print sys.version[:3]
print os.path.exists(sys.executable)
print sys.prefix, sys.exec_prefix
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment