How to install Python package from source on Windows

bartc bc at freeuk.com
Fri May 19 07:00:56 EDT 2017


On 19/05/2017 08:56, Gregory Ewing wrote:
> Bart, I think the original experiment you were trying to do
> (compiling Python with tcc) would be much more easily performed
> on Linux than Windows. Have you considered trying that?

Yes, the last time I tried to compile CPython, I had to do it on Linux. 
Using configure etc, and it worked. (Turnaround time to make incremental 
changes was 5 seconds; slower than I was used to, but workable. But 
finding my way around a sprawling application on an alien OS, and with 
slow, unresponsive, unfamiliar editors was too much effort.)

I wouldn't know how to change things to use tcc, but after there's been 
a first pass with gcc, there might be a good chance that any synthesised 
headers etc are in place and will be usable for manual compiling from tcc.

  > Configure and compile it for Linux using gcc first, then
> set CC=tcc and try to compile it again. If you're lucky,
> you won't have to fix too many things before it works.

Actually, I remember struggling to get even tcc installed! I think I had 
to compile from source, using configure and make (and that worked, this 
being Linux). But didn't know how to set it up to work from anywhere. So 
CC=tcc might not work.

> You may find it's still not easy, but at least you won't
> be fighting against a programmer-hostile system before
> even getting started.

By programmer-hostile do you mean Windows? Or the build system?! I'm 
quite capable of compiling the files one by one provided I knew what 
they were! And it would then be trivial to script it - but my way.

(I might well have finished the lot, even by hand, in the 2.5 hours I 
spent yesterday trying to do it via VS2015!)

These are the binary files on my Python 3.4 system:

python.exe
pythonw.exe
DLLs/pyexpat.pyd
DLLs/python3.dll
DLLs/select.pyd
DLLs/sqlite3.dll
DLLs/tcl86t.dll
DLLs/tk86t.dll
DLLs/unicodedata.pyd
DLLs/winsound.pyd
DLLs/_bz2.pyd
DLLs/_ctypes.pyd
DLLs/_ctypes_test.pyd
DLLs/_decimal.pyd
DLLs/_elementtree.pyd
DLLs/_hashlib.pyd
DLLs/_lzma.pyd
DLLs/_msi.pyd
DLLs/_multiprocessing.pyd
DLLs/_overlapped.pyd
DLLs/_socket.pyd
DLLs/_sqlite3.pyd
DLLs/_ssl.pyd
DLLs/_testbuffer.pyd
DLLs/_testcapi.pyd
DLLs/_testimportmultiple.pyd
DLLs/_tkinter.pyd

(The .pyd files are apparently .dll shared libraries if you look inside. 
Not Python code or byte-code, so the extension is confusing.)

So, which sources are needed to compile and link python.exe for example? 
Which headers or other files need to be synthesised for them can be 
compiled, and what would typical versions look like for Windows?

Just to get the ball rolling, they don't need to be perfect. Building 
python.exe would be a useful first step, even if it fails to run for 
many other reasons.

Once this exercise can be done for a compiler which is expected to (ie. 
gcc) /then/ it would be possible to try with another.

-- 
Bartc



More information about the Python-list mailing list