[issue602345] option for not writing .py[co] files

2008-01-07 Thread Georg Brandl

Georg Brandl added the comment:

Committed r59824.

--
status: open -> closed


Tracker <[EMAIL PROTECTED]>


___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue602345] option for not writing .py[co] files

2008-01-06 Thread Guido van Rossum

Guido van Rossum added the comment:

PS the patch still has a problem:

Python/pythonrun.c:177: error: ‘Py_ReadOnlyBytecodeFlag’ undeclared
(first use in this function)


Tracker <[EMAIL PROTECTED]>


___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue602345] option for not writing .py[co] files

2008-01-06 Thread Guido van Rossum

Guido van Rossum added the comment:

Looks good, please commit!

(Christian: the problem with using PYC in the envar name is that it is
ambiguous about what happens to PYO files...)

--
resolution:  -> accepted


Tracker <[EMAIL PROTECTED]>


___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue602345] option for not writing .py[co] files

2008-01-06 Thread Georg Brandl

Georg Brandl added the comment:

Attaching new diff, with -B flag name, PYTHONDONTWRITEBYTECODE, and
sys.dont_write_bytecode.

Added file: http://bugs.python.org/file9079/no-pyc-flag.diff


Tracker <[EMAIL PROTECTED]>


___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue602345] option for not writing .py[co] files

2008-01-06 Thread Skip Montanaro

Changes by Skip Montanaro:


--
nosy:  -skip.montanaro


Tracker <[EMAIL PROTECTED]>


___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue602345] option for not writing .py[co] files

2008-01-06 Thread Christian Heimes

Christian Heimes added the comment:

What do you think about PYTHONOMITPYC, --omit-pyc and sys.omit_pyc_creation?


Tracker <[EMAIL PROTECTED]>


___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue602345] option for not writing .py[co] files

2008-01-06 Thread Georg Brandl

Georg Brandl added the comment:

Does the flag name -R still make sense with the new env var name?


Tracker <[EMAIL PROTECTED]>


___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue602345] option for not writing .py[co] files

2008-01-05 Thread Guido van Rossum

Guido van Rossum added the comment:

"dont" is a pretty common contraction (see e.g. telnet.py).


Tracker <[EMAIL PROTECTED]>


___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue602345] option for not writing .py[co] files

2008-01-05 Thread Brett Cannon

Brett Cannon added the comment:

For some reason I don't love the use of "dont", with the missing 
apostrophe.  Just looks ugly to me.  But I don't know if "donot" is that 
much better.  And I don't think "PYTHONSKIPWRITINGBYTECODE" is much 
better.

In other words, I wish there was a better option, but I don't think any 
of my suggestions are really better.


Tracker <[EMAIL PROTECTED]>


___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue602345] option for not writing .py[co] files

2008-01-05 Thread Guido van Rossum

Guido van Rossum added the comment:

I'm okay with this feature, and the patch looks fine, except I don't
like the names used.  It's not really about "read-only-ness" of
bytecode, it's about whether we write certain files.  I'd suggest naming
the envvar PYTHONDONTWRITEBYTECODE, the C flag variable
Py_DontWriteByteCodeFlag, and the sys variable sys.dont_write_byte_code.
 With those changes I'm find with Georg checkin it in.

--
assignee: skip.montanaro -> georg.brandl
keywords: +patch


Tracker <[EMAIL PROTECTED]>


___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue602345] option for not writing .py[co] files

2008-01-05 Thread Christian Heimes

Christian Heimes added the comment:

Should the read only option be considered for 2.6?

--
nosy: +tiran
versions: +Python 2.6


Tracker <[EMAIL PROTECTED]>


___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue602345] option for not writing .py[co] files

2007-10-19 Thread Georg Brandl

Georg Brandl added the comment:

Since the PEP is now withdrawn, I updated Neal's patch to the trunk and
added the env variable as well as the sys module value, including
documentation.

--
priority: low -> normal
Added file: http://bugs.python.org/file8567/no-pyc-flag.diff


Tracker <[EMAIL PROTECTED]>

Index: Python/pythonrun.c
===
--- Python/pythonrun.c  (Revision 58468)
+++ Python/pythonrun.c  (Arbeitskopie)
@@ -72,6 +72,7 @@
 int Py_InteractiveFlag; /* Needed by Py_FdIsInteractive() below */
 int Py_InspectFlag; /* Needed to determine whether to exit at SystemError */
 int Py_NoSiteFlag; /* Suppress 'import site' */
+int Py_ReadOnlyBytecodeFlag; /* Suppress writing bytecode files (*.py[co]) */
 int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c: deprecated */
 int Py_FrozenFlag; /* Needed by getpath.c */
 int Py_UnicodeFlag = 0; /* Needed by compile.c */
@@ -172,6 +173,8 @@
Py_VerboseFlag = add_flag(Py_VerboseFlag, p);
if ((p = Py_GETENV("PYTHONOPTIMIZE")) && *p != '\0')
Py_OptimizeFlag = add_flag(Py_OptimizeFlag, p);
+   if ((p = Py_GETENV("PYTHONNOPYCFILES")) && *p != '\0')
+   Py_ReadOnlyBytecodeFlag = add_flag(Py_ReadOnlyBytecodeFlag, p);
 
interp = PyInterpreterState_New();
if (interp == NULL)
Index: Python/import.c
===
--- Python/import.c (Revision 58468)
+++ Python/import.c (Arbeitskopie)
@@ -951,8 +951,11 @@
if (Py_VerboseFlag)
PySys_WriteStderr("import %s # from %s\n",
name, pathname);
-   if (cpathname)
-   write_compiled_module(co, cpathname, mtime);
+   if (cpathname) {
+   PyObject *ro = PySys_GetObject("readonly_bytecode");
+   if (ro == NULL || !PyObject_IsTrue(ro))
+   write_compiled_module(co, cpathname, mtime);
+   }
}
m = PyImport_ExecCodeModuleEx(name, (PyObject *)co, pathname);
Py_DECREF(co);
Index: Python/sysmodule.c
===
--- Python/sysmodule.c  (Revision 58468)
+++ Python/sysmodule.c  (Arbeitskopie)
@@ -1128,6 +1128,9 @@
v = Py_BuildValue("(ssz)", "CPython", branch, svn_revision);
PyDict_SetItemString(sysdict, "subversion", v);
Py_XDECREF(v);
+PyDict_SetItemString(sysdict, "readonly_bytecode",
+ v = PyBool_FromLong(Py_ReadOnlyBytecodeFlag));
+Py_XDECREF(v);
/*
 * These release level checks are mutually exclusive and cover
 * the field, so don't get too fancy with the pre-processor!
Index: Include/pydebug.h
===
--- Include/pydebug.h   (Revision 58468)
+++ Include/pydebug.h   (Arbeitskopie)
@@ -17,6 +17,7 @@
 PyAPI_DATA(int) Py_UnicodeFlag;
 PyAPI_DATA(int) Py_IgnoreEnvironmentFlag;
 PyAPI_DATA(int) Py_DivisionWarningFlag;
+PyAPI_DATA(int) Py_ReadOnlyBytecodeFlag;
 /* _XXX Py_QnewFlag should go away in 3.0.  It's true iff -Qnew is passed,
   on the command line, and is used in 2.2 by ceval.c to make all "/" divisions
   true divisions (which they will be in 3.0). */
Index: Doc/library/sys.rst
===
--- Doc/library/sys.rst (Revision 58468)
+++ Doc/library/sys.rst (Arbeitskopie)
@@ -457,6 +457,17 @@
implement a dynamic prompt.
 
 
+.. data:: readonly_bytecode
+
+   If this is true, Python won't try to write ``.pyc`` or ``.pyo`` files on the
+   import of source modules.  This value is initially set to ``True`` or 
``False``
+   depending on the ``-R`` command line option and the ``PYTHONNOPYCFILES``
+   environment variable, but you can set it yourself to control bytecode file
+   generation.
+
+   .. versionadded:: 2.6
+
+
 .. function:: setcheckinterval(interval)
 
Set the interpreter's "check interval".  This integer value determines how 
often
Index: Modules/main.c
===
--- Modules/main.c  (Revision 58468)
+++ Modules/main.c  (Arbeitskopie)
@@ -40,7 +40,7 @@
 static int  orig_argc;
 
 /* command line options */
-#define BASE_OPTS "3c:dEhim:OQ:StuUvVW:xX?"
+#define BASE_OPTS "3c:dEhim:OQ:RStuUvVW:xX?"
 
 #ifndef RISCOS
 #define PROGRAM_OPTS BASE_OPTS
@@ -71,27 +71,30 @@
 -O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x\n\
 -OO: remove doc-strings in addition to the -O optimizations\n\
 -Q arg : division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew\n\
+-R : don't write .py[co] files on import; also PYTHONNOPYCFILES=x\n\
 -S : don't imply 'import

[issue602345] option for not writing .py[co] files

2007-10-19 Thread Tom Tanner

Tom Tanner added the comment:

Is there likely to be any action on this. We can get issues with the
creation of .pyc files due to our build setup. We can get situations
where we run builds in parallel on 2 different architectures. Our build
is set up so that anything generated by compilers end up in individual
architecture specific directories, but we cannot do this with python. We
are also using clearmae, which has its own build avoidance features,
which get thoroughly confused by the generation of these files)

End result is one of
1) We get corrupt .pyc files
2) The build breaks
3) We rebuild things we don't need to.

We'd be very grateful for a way of suppressing the generation of .pyc
files completely.

--
nosy: +thosrtanner


Tracker <[EMAIL PROTECTED]>


___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com