Matthew Hughes created QPID-4578:
------------------------------------
Summary: Support packaging qpid-python in py2exe executables
Key: QPID-4578
URL: https://issues.apache.org/jira/browse/QPID-4578
Project: Qpid
Issue Type: Improvement
Components: Python Client
Affects Versions: 0.20
Environment: Py2exe build for windows
Reporter: Matthew Hughes
Priority: Minor
The data files in .../qpid-python/python/qpid/specs (i.e. amqp-0-10.dtd,
amqp-0-8.xml, amqp-0-9.xml) are accessed using a base path of __file__, which
is not available if byte compiled into a py2exe (or pyInstaller) executable.
The patch below works around this issue.
I thought this might be useful for others ...
--Matt Hughes
Index: specs_config.py
===================================================================
--- specs_config.py (revision 47091)
+++ specs_config.py (revision 47092)
@@ -18,8 +18,20 @@
#
import os
+import imp
+import sys
-AMQP_SPEC_DIR=os.path.join(os.path.dirname(os.path.abspath(__file__)), "specs")
+def is_frozen():
+ return (hasattr(sys, "frozen") or # new py2exe
+ hasattr(sys, "importers") # old py2exe
+ or imp.is_frozen("__main__")) # tools/freeze
+
+if is_frozen:
+ basepath = os.path.dirname(os.path.abspath(sys.executable))
+else:
+ basepath = os.path.dirname(os.path.abspath(__file__))
+
+AMQP_SPEC_DIR=os.path.join(basepath, "specs")
amqp_spec = os.path.join(AMQP_SPEC_DIR, "amqp-0-10-qpid-errata.xml")
amqp_spec_0_8 = os.path.join(AMQP_SPEC_DIR, "amqp-0-8.xml")
amqp_spec_0_9 = os.path.join(AMQP_SPEC_DIR, "amqp-0-9.xml")
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]