From 91b4bb2da64cf2759149ae43fb4556985bbda9ea Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Wed, 22 May 2013 21:02:44 -0400 Subject: [PATCH] Fix python packing logic --- Sources/Plasma/Apps/plPythonPack/main.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Sources/Plasma/Apps/plPythonPack/main.cpp b/Sources/Plasma/Apps/plPythonPack/main.cpp index 6498aea6..6cc8ae6b 100644 --- a/Sources/Plasma/Apps/plPythonPack/main.cpp +++ b/Sources/Plasma/Apps/plPythonPack/main.cpp @@ -63,6 +63,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #endif static const char* kPackFileName = "python.pak"; +static const char* kModuleFile = "__init__.py"; #if HS_BUILD_FOR_WIN32 static const char* kGlueFile = ".\\plasma\\glue.py"; #else @@ -338,11 +339,15 @@ void FindPackages(std::vector& fileNames, std::vector& p std::vector packagePathNames; plFileName packagePath = plFileName::Join(path, packages[i]); FindFiles(packageFileNames, packagePathNames, packagePath); - for (int j = 0; j < packageFileNames.size(); j++) { - fileNames.push_back(packageName+"."+packageFileNames[j].AsString()); - pathNames.push_back(packagePathNames[j]); + + // Check for the magic file to make sure this is really a package... + if (std::find(packageFileNames.begin(), packageFileNames.end(), kModuleFile) != packageFileNames.end()) { + for (int j = 0; j < packageFileNames.size(); j++) { + fileNames.push_back(packageName+"."+packageFileNames[j].AsString()); + pathNames.push_back(packagePathNames[j]); + } + FindPackages(fileNames, pathNames, packagePath, packageName); } - FindPackages(fileNames, pathNames, packagePath, packageName); } } @@ -473,9 +478,13 @@ int main(int argc, char *argv[]) } PackDirectory(rootPath, rootPath, plFileName::Join(rootPath, kPackFileName), dirNames, true); - for (int i=0; i