Skip to content

Commit 518d092

Browse files
committed
Adding doc and don't write bytecode files in native image build time.
1 parent 1880fc1 commit 518d092

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ language runtime. The main focus is on user-observable behavior of the engine.
55

66
## Version 20.1.1
77
* When a `*.py` file is imported, `*.pyc` file is created. It contains binary data to speed up parsing.
8-
* Adding option `PyCachePrefix`, which is equivalent to PYTHONPYCACHEPREFIX environment variable.
8+
* Adding option `PyCachePrefix`, which is equivalent to PYTHONPYCACHEPREFIX environment variable, which is also accepted now.
99
* Adding optin `DontWriteBytecodeFlag`. Equivalent to the Python -B flag. Don't write bytecode files.
1010
* Command option -B works
1111

graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public static void main(String[] args) {
8787
private List<String> relaunchArgs;
8888
private boolean wantsExperimental = false;
8989
private Map<String, String> enginePolyglotOptions;
90-
private boolean dontWriteBytecode = ImageInfo.inImageBuildtimeCode();
90+
private boolean dontWriteBytecode = false;
9191

9292
@Override
9393
protected List<String> preprocessArguments(List<String> givenArgs, Map<String, String> polyglotOptions) {
@@ -608,6 +608,8 @@ protected void printHelp(OptionCategory maxCategory) {
608608
" as specifying the -R option: a random value is used to seed the hashes of\n" +
609609
" str, bytes and datetime objects. It can also be set to an integer\n" +
610610
" in the range [0,4294967295] to get hash values with a predictable seed.\n" +
611+
"PYTHONPYCACHEPREFIX: if this is set, GraalPython will write .pyc files in a mirror\n" +
612+
" directory tree at this path, instead of in __pycache__ directories within the source tree.\n" +
611613
"GRAAL_PYTHON_ARGS: the value is added as arguments as if passed on the\n" +
612614
" commandline. There is one special case: any `$$' in the value is replaced\n" +
613615
" with the current process id. To pass a literal `$$', you must escape the\n" +

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,13 @@ public void postInitialize(PythonCore core) {
192192
sys.setAttribute("executable", context.getOption(PythonOptions.Executable));
193193
sys.setAttribute("_base_executable", context.getOption(PythonOptions.Executable));
194194
}
195-
sys.setAttribute("dont_write_bytecode", context.getOption(PythonOptions.DontWriteBytecodeFlag));
195+
sys.setAttribute("dont_write_bytecode", ImageInfo.inImageBuildtimeCode() || context.getOption(PythonOptions.DontWriteBytecodeFlag));
196196
String pycachePrefix = context.getOption(PythonOptions.PyCachePrefix);
197197
sys.setAttribute("pycache_prefix", pycachePrefix.isEmpty() ? PNone.NONE : pycachePrefix);
198198
sys.setAttribute("__flags__", core.factory().createTuple(new Object[]{
199199
false, // bytes_warning
200200
!context.getOption(PythonOptions.PythonOptimizeFlag), // debug
201-
context.getOption(PythonOptions.DontWriteBytecodeFlag), // dont_write_bytecode
201+
ImageInfo.inImageBuildtimeCode() || context.getOption(PythonOptions.DontWriteBytecodeFlag), // dont_write_bytecode
202202
false, // hash_randomization
203203
context.getOption(PythonOptions.IgnoreEnvironmentFlag), // ignore_environment
204204
context.getOption(PythonOptions.InspectFlag), // inspect

0 commit comments

Comments
 (0)