473,395 Members | 1,616 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Importing packages not in library.zip with py2exe

Hello Guys,
Using Pythong 2.4 and py2exe 0.6.6. So, I've created a wxPython application that I use for testing. The idea is to have a tests directory so that every time the application starts, it looks in the directory and loads the tests it sees into a list it uses during runtime. So, I've got this working fine on my machine locally, but now I'm trying to get it working right with py2exe.

My problem is, if I include my 'tests" package in py2exe
Expand|Select|Wrap|Line Numbers
  1. package=["tests"]
, all my tests get included in my library.zip. This works, but then users can't easily create their own tests and have them be picked up by the app because the exe has to get regenerated every time before you can use the test.

So, I can tell py2exe not to include the package and just copy the directory over by hand, but then, when I try and import the package in my main file, I get an error "AttributeError: 'module' object has no attribute BLAH". I've tried appending to sys.path in my main file before I import the package, but that doesn't seem to work.

So, in py2exe is there any way to import a package not included in the library.zip?
Jul 16 '08 #1
3 4411
jlm699
314 100+
You can use a combo of package_dir and py_modules as below (where the packages I wanted to include in the distributable file were ../Common/[logfile, remoteCmd, and crc32])

Expand|Select|Wrap|Line Numbers
  1. setup(
  2.   zipfile = None,
  3.     # We use os.path.join for portability
  4.     package_dir = {'': os.path.join('..', 'Common')},
  5.     py_modules = ['logfile', 'remoteCmd', 'crc32'],
  6.     windows = [
  7.         {
  8.             "script": "MyTool.py",
  9.             "icon_resources": [(1, "MT.ico")],
  10.             "other_resources": [(24,1,manifest)]
  11.         }
  12.     ],
  13. )
  14.  
Jul 17 '08 #2
You can use a combo of package_dir and py_modules as below (where the packages I wanted to include in the distributable file were ../Common/[logfile, remoteCmd, and crc32])

Expand|Select|Wrap|Line Numbers
  1. setup(
  2.   zipfile = None,
  3.     # We use os.path.join for portability
  4.     package_dir = {'': os.path.join('..', 'Common')},
  5.     py_modules = ['logfile', 'remoteCmd', 'crc32'],
  6.     windows = [
  7.         {
  8.             "script": "MyTool.py",
  9.             "icon_resources": [(1, "MT.ico")],
  10.             "other_resources": [(24,1,manifest)]
  11.         }
  12.     ],
  13. )
  14.  

Sorry, but this didn't seem to make a difference. I added the tests directory as a "package_dir" and added it as a "py_modules", but then I still got the same error when I tried to start the app when it tries to import tests. Perhaps it would help if I gave more detail and I'll add my setup.py at the end.

One more complicating factor may be my directory structure. My tests package actually contains several sub packages. So, my __init__.py for tests looks like this.
Expand|Select|Wrap|Line Numbers
  1. __all__=["ANSI", "ETSI"]
and then there's an ANSI and ETSI directory, which from there, each has their own sub-directories with their own __init__.py. When I try to start the app, it says "AttributeError: 'module' object has no attribute 'ANSI'". So, I assume there's a problem with my path in py2exe seeing as how tests is not in library.zip. As I said, this all works fine interpreting the python locally, but might there be anything special I have to do in my __init__.py as well?

Full setup.py with only personal information removed
Expand|Select|Wrap|Line Numbers
  1. from distutils.core import setup
  2. import py2exe
  3. import os
  4. import sys
  5.  
  6. setup(name="isupConformance",
  7.       options = {"py2exe": {
  8.                           "compressed": 1,
  9.                           "optimize": 2,
  10.                           #"packages": ["tests"],
  11.                           "dll_excludes": ["w9xpopen.exe"],
  12.                           "ascii": 1,
  13.                           "bundle_files": 1,
  14.                       }},
  15.       #packages=["tests"],
  16.       package_dir = {'' : 'c:\\Python24\\Scripts\\Isup Conformance\\tests'},
  17.       py_modules=["GUI", "isupConfChassis", "isupConfSmta", "isupConfTest", "mgtsCtrl", "mgtsDevice", "sequence", "tests"],
  18.       windows=
  19.       [
  20.           {
  21.               "script": "gui.py",
  22.               "icon_resources": [(1, "wi0124-64.ico")],
  23.               "dest_base": "ISUP Conformance"
  24.           }
  25.       ],
  26.       )
Jul 17 '08 #3
Does anyone know how to import packages not included in the py2exe library.zip? Is it possible at all?
Jul 21 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Rene Olsthoorn | last post by:
Dear readers, py2exe has a problem including libxml2. Not at building time, but at runtime. The libxml2.dll cannot be loaded... Is there anyone that NOT has the problem? (and can you drop me...
0
by: Marco Aschwanden | last post by:
Hi - Win2000 - Python 2.3.3 - py2exe 0.5.0 - eGenix Comercial & Base Package I am developing an app using mxODBC. On the home page they say ...
1
by: Alban Hertroys | last post by:
I'm trying to create a package containing a number of classes I made, but I can't get it to work... My package is structured like this: X/ __init__.py A.py B.py
4
by: Peter Tillotson | last post by:
Hi all, I was wondering if this is possible. In python v2.3 the import systems was extended via PEP302 to cope with packages. *.py files in a directory hierarchy can be imported as modules each...
3
by: Michele Petrazzo | last post by:
I want to redistribute the library that I create. I create a project, its setup.py that when launched copy all files into the "site-packages/library" directory. And here it's all ok. When I call...
0
by: rrutkowski | last post by:
Hi! I need to rasterize a svg file. I'm currently trying to use an open source library called librsvg. I have completed all the dlls and started writing the following wrapper: static extern...
3
by: jainarun | last post by:
Hi, When i am trying to execute python module as shown below it it running sucessfully on some machine but on others m/c it is showing following error msg: C:\Python24>python subcontentitem.py...
4
mayfjf
by: mayfjf | last post by:
I have already tried the ff, and they compiled well: //SAMPLE PROGRAM ON THE USE OF STATIC MODIFIER package java_samples; public class samp1{ public static void main(String args){
5
by: Doug Morse | last post by:
Hi, I have an application that runs just fine using the standard Python distro interpreter (v2.5.1 on WinXP) but throws the following exception when run as an executable built with py2exe. My...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.