Get the windows 2010 command prompt for python precompiled libraries - python

While this isn't a direct programming question, it's something that has been bothering me for quite some time. And keeps annoying me to no end, and I expect others also have this problem.
On windows quite a few libraries require you to use a precompiled version (numpy, pyqt, mod_wsgi). Now these precompiled versions require often you to have installed the correct C-compiler, the one used for python 3.4 is VC10. This compiler corresponds with visual studio 2010.
Now some (mod_wsgi as explained here) use further build steps to finalize the library. To do this one should "open the VS 2010 command prompt". Which is included in (free) VS 2010 express.
However googling and further links lead to microsoft' site for visual studio. But there only 2015 (or 2013) is available.
So how to finalize the build process (ie the last steps for mod_wsgi) on windows? Can I use VS 2015 command prompt without breaking things? I doubt I can?
Are we basically stuck until python updates to a newer version of visual studio?

Related

Configuring Visual Studio 2022 to develop Python projects in WSL2

I installed WSL2 and use Visual Studio (VS) 2022 on the windows. I want to configure my VS 2022, so I can develop Python projects in WLS2. All tutorials I find online only talks about visual studio code. I don't want to install another IDE. Does anybody know how to do that or point me to some material?
Unfortunately not at this time, no. The VSCode integration with WSL is done through the use of an extension that creates an interop server between Windows VSCode and the Linux side of WSL. There isn't an extension like that for Visual Studio, however.
The only WSL integration that I'm aware of in Visual Studio 2022 is the inclusion of a WSL toolchain that allows you to target WSL/Linux in C++ projects. But nothing that I'm aware of for Python, no.
I believe you'll need to install an additional IDE to get Python/WSL support, sorry.
Not sure if VS is available for Linux or WSL2 yet.
If you look at https://visualstudio.microsoft.com/downloads/, only Windows & Mac seem to be supported.
So you have 2 main options:
Use VS on Windows itself. Then you just need to install the Python Tools for Visual Studio (PTVS) to be able to support Python development
Use VS Code on WSL2 - it's pretty lightweight to install anyway as a code editor, but can be endowed with comparable features to VS
EDIT: It may be that I'm misunderstanding the question as pointed out below by NotTheDr01ds, and instead you want to target WSL2 from the VS IDE, developing Python.

Can I develop C extensions for Python 2.7 through 3.1 on Windows *without* installing Visual Studio 2008?

I'm aware that Python extensions on Windows typically have to be built with the same version of Visual Studio used to compile Python itself, and I'm further aware that Python 2.7 through 3.1 are built using Visual Studio 2008. But the machine I'm on already has VS 2013 installed, and, as I've discovered countless times, one way to rapidly mess up your Windows development environments is to install Visual Studio in any order than from oldest to newest. Besides which, install VS2008 on a brand-new Windows 8.1 box seems silly. Python extensions are the only thing I have that needs 2008; if I can avoid installing it, I'd really prefer not to.
Can I avoid installing VS 2008 and still build against the official Python distributions, perhaps by installing a specific Platform SDK? If not, is there an alternative build of Python that might go with e.g. MinGW, or something that does not require I install VS 2008?
I can suggest a few possible solutions to your problem. From potentially the easiest, to probably the hardest:
Just use Visual Studio 2013 to compile your extension modules. For this to work your extension module mustn't access any C runtime objects created by the Python interpreter, nor may it pass any C runtime objects it creates to the interpreter. In particular you can't use any FILE * or file descriptor objects provided by Python. You can still read and write to files in your module, just not files that Python has opened.
Uninstall Visual Studio 2013, install Visual Studio 2008, reinstall Visual Studio 2013. As silly as this sounds it's probably going to be a quicker and lot less frustrating than either of the following solutions. This will let you build extension modules pretty much normally and you won't have to worry about what C runtime objects you use.
Use mingw32 and employ various hacks to get it to work. This page explains how one person got it to work: https://lists.launchpad.net/kicad-developers/msg09473.html
Copy the appropriate msvcrt*.lib file from VS 2008 installed on another machine. Manually edit your linker options to use this library instead of VS 2013's msvcrt*.lib of the same name. If that doesn't work, copy the include files and other libraries as well, and modify your compiler and linker options to use them instead. If that still doesn't work, copy the VS 2008 command line compiler and all of its dependent DLLs, set the PATH correctly, and then modify your build process to use that compiler instead.

How to obtain pre-built *debug* version of Python library (e.g. Python27_d.dll) for Windows

Firstly, I should state that my current development environment is MSYS + mingw-w64 + ActivePython under Windows 7 and that on a normal day I am primarily a Linux developer. I am having no joy obtaining, or compiling, a version of the Python library with debug symbols.
I need both 32bit and 64bit debug versions of the Python27.dll file, ideally. I want to be able to embed Python and implement Python extensions in C++, and be able to call upon a seamless debugging facility using the gdb-7.4 I have built for mingw-w64, and WingIDE for the pure Python side of things.
Building Python 2.7.3 from source with my mingw-w64 toolchain is proving too problematic -- and before anyone flames me for trying: I acknowledge that this environment is unsupported, but I thought I might be able to get this working with a few judicious patches (hacks) and:
make OPT='-g -DMS_WIN32 -DWIN32 -DNDEBUG -D_WINDOWS -DUSE_DL_EXPORT'
I was wrong... I gave up at posixmodule.c since the impact of my changes became uncertain; ymmv.
I have tried building with Visual C++ 2010 Express but being primarily a Linux developer the culture-shock is too much for me to bear today; the Python project does not even import successfully. Apparently, I need Visual C++ 2008, yet I am already convinced I don't want to go down this road if at all possible...
It's really surprising to me that there is not a zip-file providing the requisite .dlls somewhere on the Internet. ActiveState should really provide these as an optional download with each release of ActivePython that they make -- perhaps that's where the paid support comes in ;-).
What is the best way to obtain the Python debug library files given my environment?
I've just built CPython 2.7.5 in debug mode with Visual Studio 2012 Express (free).
I documented the process via wiki page: https://wiki.python.org/moin/VS2012
The best way to create a debug version of Python under Windows is to use the Debug build in the Visual Studio projects that come with the Python source, using the compiler version needed for the specific Python release, i.e. VS 2008.
There may be other ways, but this is certainly the best way.
If you really need a 64-bit debug build also, the best way is to buy a copy of VS 2008 (i.e. not use the Express version). It may be possible to create an AMD64 debug build using the SDK 64-bit compiler, but again, using the officially-supported procedures is the best way.
The libs can be aquired from the official Python site https://www.python.org/ftp/python/. Just navigate to the specific version you like and then download the respective installer.
For installation you can call the installers like this :
your_installer.msi targetdir="the_path_to_your_directory_of_choice"
or simply Run them as Administrator.
You may also use the Python installer to download the debug symbols as well(use the webinstall version).

How do I get cx_Oracle to work on 64-bit Itanium Windows?

I'm running Windows Server 2003 on a 64-bit Itanium server which is also running 64-bit Oracle 10.2, and I'd like to install cx_Oracle for Python 2.5. I've used cx_Oracle before many times on both Windows and Linux, and I've also compiled it before on 32 bit versions of those platforms, but I've never tried an IA64 compile.
None of the binary builds of cx_Oracle at http://cx-oracle.sourceforge.net/ are 64 bit, and I get an error after installing any of them when trying to run import cx_Oracle so I figure the thing to do is to compile it from source.
When running python setup.py build then I get the error that Python was built with Visual Studio 2003 and that I need something which can produce compatible binaries. I have Visual Studio 2005, which apparently doesn't fit the bill due to linking against a different version of the C standard library, and probably for other reasons as well. Unfortunately, Visual Studio 2003 is no longer available for download, and I'm not sure where to get it.
So I download MinGW from http://sourceforge.net/projects/mingw/files/ but this is also only available in 32 bit form. I go ahead and give it a try anyway, but it gives me an error during compilation about one of the Oracle DLLs I'm linking against having an invalid file format.
At this point I've got a lot of options, and I'm not sure where to place my efforts:
I could download the 64 bit MinGW from http://sourceforge.net/projects/mingw-w64/ and try using that, except that it only seems to be available as source, so I'd have to compile the compiler, probably using Visual Studio 2005.
I could try using an x86 32 bit build of Python and then download the Oracle Instant Client SDK from http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html and then use that to build cx_Oracle. I'd probably have to set my ORACLE_HOME to the client so that it didn't try linking against the 64 bit server DLLs, but this seems like it might work.
I could try compiling Python itself from source, using Visual Studio 2005, so that I could then use Visual Studio 2005 to build cx_Oracle and not worry about binary compatibility issues. I've compiled Python from source many times on Linux and never had any problems, so I'd like to believe that it's just as simple on Windows.
I could try to figure out how to make Visual Studio 2005 link against the right DLLs and thus produce compatible binaries in that manner without needing Visual Studio 2003. Intuitively it seems like Visual Studio should be able to produce compatible binaries with older versions of itself, but almost all of my compiler experience is with gcc so I don't really know.
I'm just really not sure where to direct my efforts. Does anyone have any suggestions about where to go next? I can copy/paste some of the specific error messages I've gotten if that would be helpful.
I'd especially love to hear from anyone who's ever gotten cx_Oracle to work on a 64 bit Itanium version of Windows - I can't be the first to try this.
I ended up going with Option #2: I downloaded the 32-bit Oracle Instant Client, then compiled cx_Oracle for 32-bit Python with the instant client. So everything involved is 32-bit, and I'm just not using any IA64-bit executables, and this works just fine.
If I had an IA64 compiler, I'd try Option #3, but it turns out that Visual Studio Pro doesn't support the IA64 platform, and we'd need to spend a lot of money to upgrade to whatever's higher than Pro.
I read this yesterday and am not suprised to see that nobody has answered. It is a very specific and complex question. While I do not have direct experience with many of the tools you are dealing with I have delt with the issues surrounding incompatabilities with different compilers and binaries. For what its worth 3. sounds like your best bet.

Can I use VS2005 to build extensions for a Python system built with VS2003

RDFLib needs C extensions to be compiled to install on ActiveState Python 2.5; as far as I can tell, there's no binary installer anywhere obvious on the web. On attempting to install with python setup.py install, it produces the following message:
error: Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.
There are various resources on the web about configuring a compiler for distutils that discuss using MinGW, although I haven't got this to work yet. As an alternative I have VS2005.
Can anyone categorically tell me whether you can use the C compiler in VS2005 to build Python extension modules for a VS2003 compiled Python (in this case ActiveState Python 2.5). If this is possible, what configuration is needed?
The main problem is C run-time library. Python 2.4/2.5 linked against msvcr71.dll and therefore all C-extensions should be linked against this dll.
Another option is to use gcc (mingw) instead of VS2005, you can use it to compile python extensions only. There is decent installer that allows you to configure gcc as default compiler for your Python version:
http://www.develer.com/oss/GccWinBinaries
I can't tell you categorically, but I don't believe you can. I've only run into this problem in the inverse situation (Python built with VS2005, trying to build with VS2003). Searching the web did not turn up any way to hack around it. My eventual solution was to get VC Express, since VC2005 is when Microsoft started releasing the free editions. But that's obviously not an option for you.
I don't use ActiveState Python, but is there a newer version you could use? The source ships with project files for VS2008, and I'm pretty sure the python.org binary builds stopped using VS2003 a while ago.
As of today Mar 2012, I can categorically say it is possible with Python2.4.4 (only one I've tested) and Visual Studio 2005 and 2008. Just installing VS10 to check that. I don't know why it works and I have problems using distutils so I have to compile manually.

Categories

Resources