Background
I'm using cx_Freeze to build Windows and Mac packages of my application; the build executes successfully on both platforms resulting in an msi on Windows and dmg/app on Mac which I can install.
Problem
The problem occurs when I run the application on either platform. I get the error:
AttributeError: 'module' object has no attribute 'DateTime'
This is triggered by site-packages/sqlobject/col.py line 66:
DateTimeType = type(DateTime.DateTime())
I've never installed mx DateTime and have never had any trouble running the application via IDE or script but somehow bundling with cx_Freeze is changing something. I'm assuming that the import (col.py) of DateTime is getting mixed up with the import of datetime, but I'm not sure.
Workaround:
I was able to get everything working by editing col.py to set mxdatetime_available = False
prior to this failed use of DateTime.DateTime() so that it never attempts to use the mxDateTime. However, modifying the underlying library source locally obviously isn't something I want to do and maintain.
Does anyone know what I might be missing here to avoid the incorrect import of the third-party library? My hack isn't a valid fix that I could submit to the SQLObject project as it removes functionality for everyone, but it shouldn't be getting into that code path to begin with and I am simply failing to see the underlying cause.
My setup.py (with a few bits removed for brevity)
import sys
from cx_Freeze import Executable, setup
cx_freeze_target = [Executable(script="main.py")]
setup_dict = dict(
name="myapp",
version="0.0.3",
author="me",
description="An app",
license="Undecided",
packages=['myapp'],
executables=cx_freeze_target
)
def main():
setup(**setup_dict)
if __name__ == '__main__':
main()