Specifically, I have written some code in Cython and compiled to a .pyd. In order to run on other machines with ArcGIS 10.1, I have included with my code the Microsoft Manifest (Microsoft.VC90.CRT.manifest) and other required DLLs (msvcm90.dll, msvcp90.dll, msvcr90.dll) that are included in the ArcGIS 10.1 installation. I do not think the code was compiled with these DLLs, but I have been able to get the .pyd to import successfully on other computers without Visual Studio using these DLLs.

When I import my code before arcpy, it imports fine. When I import after, it throws the error "ImportError: DLL load failed: The specified module could not be found."

Is there an option for me to make my .pyd work when I distribute this code as part of a toolbox?

Please let me know if more details or the files themselves would be helpful.

ArcGIS uses a different version of the msvc libraries than what you're including, so once they try to load there's a version conflict when it tries to import your local ones. I'd recommend getting rid of the manifest altogether.

If you're using a setup.py to build, the thing I do is patch \PythonInstall\Lib\distutils\msvc9compiler.py and locate the following lines:

ArcGIS uses a different version of the msvc libraries than what you're including, so once they try to load there's a version conflict when it tries to import your local ones. I'd recommend getting rid of the manifest altogether.

If you're using a setup.py to build, the thing I do is patch \PythonInstall\Lib\distutils\msvc9compiler.py ...And just comment them all out.

Two questions: 1) Is there a way for me to compile the code using the same libraries used by ArcGIS? 2) What's the danger or consequences of doing what you suggested?

Note that despite having commented out the manifest embedding section in msvc90compiler.py, I still see the /MANIFESTFILE:build\temp.win32.7... which I am guessing is being embedded. That manifest file looks like this:

Commenting out those specific lines will not prevent the manifest from being created, only bypass the part where it embeds it in the PYD.

Have you tried 1. NOT packaging those DLLs with your library, and then 2. making sure the <PYTHON>\Lib\site-packages\<yourlib> is completely cleared out of all files before rebuilding and testing?

Yes and yes. For the second suggestion, I may not be following proper protocol or may not understand your suggestion. I havent put any of my scripts in <PYTHON>\Lib\site-packages, including the msvc libraries. Nor have I specified the library locations in any of the files to-be-compiled. One of my previous questions was how I might specify specific msvc library paths for the compiler.

You'll notice a bunch of Microsoft.VC* folders in <ArcGIS Install>\bin\. That has the various DLLs that ArcGIS uses. You can use one of many methods to determine their versions, set those versions as your dependencies, and then go back to embedding the manifest.

Though, based on how you're describing the symptoms, it may be something else at play here.

You'll notice a bunch of Microsoft.VC* folders in <ArcGIS Install>\bin\. That has the various DLLs that ArcGIS uses. You can use one of many methods to determine their versions, set those versions as your dependencies, and then go back to embedding the manifest.

Though, based on how you're describing the symptoms, it may be something else at play here.

I am not sure how to set the dependencies for these particular files, and the python help on this is sparse.