Giovanni Bajo <[EMAIL PROTECTED]> wrote:
> If anybody has ideas for a better solution, speak up. I was thinking of
just
> building the bootloader as a statically-linked executable, but I fear
> interactions with python itself.
Actually, this was easier than expected. It is sufficient to avoid passing
Python a FILE* opened by the bootloader. After that, we can switch the
bootloader to be compiled as a static executable and that's it.
The work in the no-msvcrt has still some room: in fact, the bootloader is
much bigger now for no good reason. When the work in no-msvcrt is completed,
the bootloader binary will be much smaller.
Committed as r164. This fixes ticket #12.
--
Giovanni Bajo
Index: source/common/launch.h
===================================================================
--- source/common/launch.h (revision 162)
+++ source/common/launch.h (working copy)
@@ -136,7 +136,7 @@
EXTDECLPROC(PyObject *, PyList_New, (int));
EXTDECLPROC(int, PyList_Append, (PyObject *, PyObject *));
EXTDECLPROC(PyObject *, Py_BuildValue, (char *, ...));
-EXTDECLPROC(PyObject *, PyFile_FromFile, (FILE *, char *, char *, int));
+EXTDECLPROC(PyObject *, PyFile_FromString, (char *, char *));
EXTDECLPROC(PyObject *, PyObject_CallFunction, (PyObject *, char *, ...));
EXTDECLPROC(PyObject *, PyModule_GetDict, (PyObject *));
EXTDECLPROC(PyObject *, PyDict_GetItemString, (PyObject *, char *));
Index: source/common/launch.c
===================================================================
--- source/common/launch.c (revision 162)
+++ source/common/launch.c (working copy)
@@ -63,7 +63,7 @@
DECLPROC(PyList_New);
DECLPROC(PyList_Append);
DECLPROC(Py_BuildValue);
-DECLPROC(PyFile_FromFile);
+DECLPROC(PyFile_FromString);
DECLPROC(PyObject_CallFunction);
DECLPROC(PyModule_GetDict);
DECLPROC(PyDict_GetItemString);
@@ -273,7 +273,7 @@
GETPROC(dll, PyList_New);
GETPROC(dll, PyList_Append);
GETPROC(dll, Py_BuildValue);
- GETPROC(dll, PyFile_FromFile);
+ GETPROC(dll, PyFile_FromString);
GETPROC(dll, PyObject_CallFunction);
GETPROC(dll, PyModule_GetDict);
GETPROC(dll, PyDict_GetItemString);
@@ -570,6 +570,8 @@
TOC *ptoc;
PyObject *co;
PyObject *mod;
+ PyObject *res;
+ char buf[32];
VS("importing modules from CArchive\n");
@@ -581,8 +583,17 @@
marshaldict = PyModule_GetDict(marshal);
loadfunc = PyDict_GetItemString(marshaldict, "load");
- /* Make a Python file object from f_fp */
- pyfile = PyFile_FromFile(f_fp, f_archivename, "rb+", 0);
+ /* Reopen the archive as a Python file. We cannot use PyFile_FromFile
+ * because that would require this boot-loader and Python DLL to share
+ * the same libc, while they purposely don't.
+ */
+ fclose(f_fp);
+ pyfile = PyFile_FromString(f_archivename, "rb");
+ if (PyErr_Occurred())
+ {
+ PyErr_Print();
+ return -1;
+ }
/* Iterate through toc looking for module entries (type 'm')
* this is normally just bootstrap stuff (archive and iu)
@@ -593,8 +604,11 @@
{
VS(ptoc->name);
VS("\n");
+
/* Go to start of Python module (start + 8) and load
the code object */
- fseek(f_fp, f_pkgstart + ntohl(ptoc->pos) + 8,
SEEK_SET);
+ res = PyObject_CallMethod(pyfile, "seek", "(ii)",
f_pkgstart + ntohl(ptoc->pos) + 8, 0);
+ Py_XDECREF(res);
+
co = PyObject_CallFunction(loadfunc, "O", pyfile);
mod = PyImport_ExecCodeModule(ptoc->name, co);
@@ -602,19 +616,28 @@
if (mod == NULL) {
FATALERROR("mod is NULL - ");
FATALERROR(ptoc->name);
- //return -1;
}
if (PyErr_Occurred())
{
PyErr_Print();
PyErr_Clear();
- //FATALERROR("PyErr loading mod - ");
- //FATALERROR(ptoc->name);
- //return -1;
}
}
ptoc = incrementTocPtr(ptoc);
}
+
+ /* Close the file and release the object. */
+ res = PyObject_CallMethod(pyfile, "close", "()");
+ Py_XDECREF(res);
+ Py_DECREF(pyfile);
+
+ /* After closing the python file, we can reopen it as normal file. */
+ f_fp = fopen(f_archivename, "rb");
+ if (f_fp == NULL) {
+ VS("Cannot reopen archive: ");
+ VS(f_archivename);
+ VS("\n");
+ }
return 0;
}
Index: doc/CHANGES.txt
===================================================================
--- doc/CHANGES.txt (revision 162)
+++ doc/CHANGES.txt (working copy)
@@ -3,14 +3,17 @@
Current changes since PyInstaller 1.0
-------------------------------------
- + Fix problem with incorrect python path detection. Now using distutils.
+ + Fix problem with incorrect python path detection. Now using helpers from
+ distutils.
+ Fix problem with rare encodings introduced in newer Python versions: now all
the encodings are automatically found and included, so this problem should
be gone forever.
+ Add import hook for dnspython (tested with 1.3.4)
+ + (Windows) Make single-file packages not depend on MSVCRT71.DLL anymore,
+ even under Python 2.4. You can eventually ship your programs really as
+ single-file executables, even when using the newest Python version!
-
PyInstaller 1.0 (with respect to McMillan's Python Installer 5b5):
---------------
Index: Sconstruct
===================================================================
--- Sconstruct (revision 162)
+++ Sconstruct (working copy)
@@ -33,10 +33,11 @@
for mode in "cons", "win":
env = base_env.Copy()
- # The DLL runtime must be the same of that used by the python
DLL.
- # I cannot think of a way to guess it from here, so let's
assume
- # the user has a non-debug build of Python in his system.
- env.Append(CCFLAGS = ["/MD"])
+ # The bootloader is built as a static executable. We want it
+ # to be self-contained. Extra care was put in writing it so
+ # that it does not share objects/memory with python.dll (which
+ # it loads).
+ env.Append(CCFLAGS = ["/ML"])
if flavour == "debug":
# No optimizations
Index: support/loader/inprocsrvr_6rw.dll
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: support/loader/inprocsrvr_7rw.dll
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: support/loader/run_6dc.exe
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: support/loader/run_7dc.exe
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: support/loader/run_6rw.exe
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: support/loader/run_7rw.exe
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: support/loader/inprocsrvr_6rc.dll
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: support/loader/inprocsrvr_7rc.dll
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: support/loader/run_6rc.exe
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: support/loader/run_7rc.exe
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: support/loader/inprocsrvr_6dw.dll
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: support/loader/inprocsrvr_7dw.dll
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: support/loader/run_6dw.exe
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: support/loader/run_7dw.exe
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: support/loader/inprocsrvr_6dc.dll
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: support/loader/inprocsrvr_7dc.dll
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: doc/source/Manual.rst
===================================================================
--- doc/source/Manual.rst (revision 162)
+++ doc/source/Manual.rst (working copy)
@@ -328,19 +328,6 @@
|GOBACK|
-``--onefile`` and Python 2.4 for Windows (**important**)
---------------------------------------------------------
-
-Currently, there is an issue when using ``--onefile`` with Python 2.4: the
-resulting executable will depend on ``MSVCR71.DLL``. This is a standard
-Microsoft library which was not present on older Windows (like Win9x), so
-you are forced to ship it with your application if you need compatibility
-with those operating systems. We plan to fix this issue in a future version
-of |PyInstaller| (consult our Roadmap_ for more information).
-
-|GOBACK|
-
-
PyInstaller Utilities
+++++++++++++++++++++
_______________________________________________
PyInstaller mailing list
[email protected]
http://lists.hpcf.upr.edu/mailman/listinfo/pyinstaller