blob: c05f72a853a9bfc3b76711819a93eb7abbbea0c1 [file] [log] [blame]
Christian Heimesd8654cf2007-12-02 15:22:16 +00001.. highlightlang:: none
2
3.. _using-on-windows:
4
5*************************
6 Using Python on Windows
7*************************
8
9.. sectionauthor:: Robert Lehmann <lehmannro@gmail.com>
10
11This document aims to give an overview of Windows-specific behaviour you should
12know about when using Python on Microsoft Windows.
13
Larry Hastings3732ed22014-03-15 21:13:56 -070014.. XXX (ncoghlan)
15
16 This looks rather stale to me...
17
Christian Heimesd8654cf2007-12-02 15:22:16 +000018
19Installing Python
20=================
21
22Unlike most Unix systems and services, Windows does not require Python natively
23and thus does not pre-install a version of Python. However, the CPython team
24has compiled Windows installers (MSI packages) with every `release
Georg Brandle73778c2014-10-29 08:36:35 +010025<https://www.python.org/download/releases/>`_ for many years.
Christian Heimesd8654cf2007-12-02 15:22:16 +000026
27With ongoing development of Python, some platforms that used to be supported
Christian Heimes380f7f22008-02-28 11:19:05 +000028earlier are no longer supported (due to the lack of users or developers).
Christian Heimesd8654cf2007-12-02 15:22:16 +000029Check :pep:`11` for details on all unsupported platforms.
30
Christian Heimesd8654cf2007-12-02 15:22:16 +000031* `Windows CE <http://pythonce.sourceforge.net/>`_ is still supported.
Georg Brandl525d3552014-10-29 10:26:56 +010032* The `Cygwin <http://cygwin.com/>`_ installer offers to install the Python
33 interpreter as well (cf. `Cygwin package source
Christian Heimesd8654cf2007-12-02 15:22:16 +000034 <ftp://ftp.uni-erlangen.de/pub/pc/gnuwin32/cygwin/mirrors/cygnus/
35 release/python>`_, `Maintainer releases
36 <http://www.tishler.net/jason/software/python/>`_)
37
Georg Brandle73778c2014-10-29 08:36:35 +010038See `Python for Windows <https://www.python.org/download/windows/>`_
Zachary Warec3cf97b2014-01-17 15:23:42 -060039for detailed information about platforms with pre-compiled installers.
Christian Heimesd8654cf2007-12-02 15:22:16 +000040
41.. seealso::
42
43 `Python on XP <http://www.richarddooling.com/index.php/2006/03/14/python-on-xp-7-minutes-to-hello-world/>`_
44 "7 Minutes to "Hello World!""
45 by Richard Dooling, 2006
46
Georg Brandl525d3552014-10-29 10:26:56 +010047 `Installing on Windows <http://www.diveintopython.net/installing_python/windows.html>`_
Christian Heimesd8654cf2007-12-02 15:22:16 +000048 in "`Dive into Python: Python from novice to pro
Georg Brandl525d3552014-10-29 10:26:56 +010049 <http://www.diveintopython.net/>`_"
Christian Heimesd8654cf2007-12-02 15:22:16 +000050 by Mark Pilgrim, 2004,
51 ISBN 1-59059-356-1
52
Georg Brandlfe858072014-10-28 23:00:25 +010053 `For Windows users <http://www.swaroopch.com/notes/python/#install_windows>`_
Christian Heimesd8654cf2007-12-02 15:22:16 +000054 in "Installing Python"
Georg Brandlfe858072014-10-28 23:00:25 +010055 in "`A Byte of Python <http://www.swaroopch.com/notes/python/>`_"
Christian Heimesd8654cf2007-12-02 15:22:16 +000056 by Swaroop C H, 2003
57
58
59Alternative bundles
60===================
61
62Besides the standard CPython distribution, there are modified packages including
63additional functionality. The following is a list of popular versions and their
64key features:
65
Zachary Warec3cf97b2014-01-17 15:23:42 -060066`ActivePython <http://www.activestate.com/activepython/>`_
Christian Heimesd8654cf2007-12-02 15:22:16 +000067 Installer with multi-platform compatibility, documentation, PyWin32
68
Georg Brandl525d3552014-10-29 10:26:56 +010069`Enthought Python Distribution <https://www.enthought.com/products/epd/>`_
Christian Heimesd8654cf2007-12-02 15:22:16 +000070 Popular modules (such as PyWin32) with their respective documentation, tool
Ezio Melotti0639d5a2009-12-19 23:26:38 +000071 suite for building extensible Python applications
Christian Heimesd8654cf2007-12-02 15:22:16 +000072
Christian Heimes255f53b2007-12-08 15:33:56 +000073Notice that these packages are likely to install *older* versions of Python.
74
Christian Heimesd8654cf2007-12-02 15:22:16 +000075
76
77Configuring Python
78==================
79
80In order to run Python flawlessly, you might have to change certain environment
81settings in Windows.
82
83
Brian Curtina86f1852012-08-19 11:22:20 -050084.. _setting-envvars:
85
Christian Heimesd8654cf2007-12-02 15:22:16 +000086Excursus: Setting environment variables
87---------------------------------------
88
Christian Heimes255f53b2007-12-08 15:33:56 +000089Windows has a built-in dialog for changing environment variables (following
Georg Brandl48310cd2009-01-03 21:18:54 +000090guide applies to XP classical view): Right-click the icon for your machine
91(usually located on your Desktop and called "My Computer") and choose
92:menuselection:`Properties` there. Then, open the :guilabel:`Advanced` tab
Christian Heimes255f53b2007-12-08 15:33:56 +000093and click the :guilabel:`Environment Variables` button.
Christian Heimesd8654cf2007-12-02 15:22:16 +000094
95In short, your path is:
96
97 :menuselection:`My Computer
98 --> Properties
99 --> Advanced
100 --> Environment Variables`
101
102In this dialog, you can add or modify User and System variables. To change
103System variables, you need non-restricted access to your machine
104(i.e. Administrator rights).
105
106Another way of adding variables to your environment is using the :command:`set`
107command::
108
109 set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib
110
111To make this setting permanent, you could add the corresponding command line to
Christian Heimes255f53b2007-12-08 15:33:56 +0000112your :file:`autoexec.bat`. :program:`msconfig` is a graphical interface to this
113file.
Christian Heimesd8654cf2007-12-02 15:22:16 +0000114
115Viewing environment variables can also be done more straight-forward: The
116command prompt will expand strings wrapped into percent signs automatically::
117
118 echo %PATH%
119
120Consult :command:`set /?` for details on this behaviour.
121
122.. seealso::
123
124 http://support.microsoft.com/kb/100843
125 Environment variables in Windows NT
126
127 http://support.microsoft.com/kb/310519
128 How To Manage Environment Variables in Windows XP
129
Christian Heimes255f53b2007-12-08 15:33:56 +0000130 http://www.chem.gla.ac.uk/~louis/software/faq/q1.html
131 Setting Environment variables, Louis J. Farrugia
132
Christian Heimesd8654cf2007-12-02 15:22:16 +0000133
Nick Coghlan349c8022012-09-30 13:00:43 +0530134.. _windows-path-mod:
135
Christian Heimesd8654cf2007-12-02 15:22:16 +0000136Finding the Python executable
137-----------------------------
138
Brian Curtina86f1852012-08-19 11:22:20 -0500139.. versionchanged:: 3.3
140
Christian Heimesd8654cf2007-12-02 15:22:16 +0000141Besides using the automatically created start menu entry for the Python
Brian Curtina86f1852012-08-19 11:22:20 -0500142interpreter, you might want to start Python in the command prompt. As of
143Python 3.3, the installer has an option to set that up for you.
Christian Heimesd8654cf2007-12-02 15:22:16 +0000144
Brian Curtina86f1852012-08-19 11:22:20 -0500145At the "Customize Python 3.3" screen, an option called
146"Add python.exe to search path" can be enabled to have the installer place
147your installation into the :envvar:`%PATH%`. This allows you to type
148:command:`python` to run the interpreter. Thus, you can also execute your
149scripts with command line options, see :ref:`using-on-cmdline` documentation.
Christian Heimesd8654cf2007-12-02 15:22:16 +0000150
Brian Curtina86f1852012-08-19 11:22:20 -0500151If you don't enable this option at install time, you can always re-run the
152installer to choose it.
153
154The alternative is manually modifying the :envvar:`%PATH%` using the
155directions in :ref:`setting-envvars`. You need to set your :envvar:`%PATH%`
156environment variable to include the directory of your Python distribution,
157delimited by a semicolon from other entries. An example variable could look
158like this (assuming the first two entries are Windows' default)::
159
160 C:\WINDOWS\system32;C:\WINDOWS;C:\Python33
Christian Heimesd8654cf2007-12-02 15:22:16 +0000161
162
163Finding modules
164---------------
165
166Python usually stores its library (and thereby your site-packages folder) in the
167installation directory. So, if you had installed Python to
168:file:`C:\\Python\\`, the default library would reside in
169:file:`C:\\Python\\Lib\\` and third-party modules should be stored in
170:file:`C:\\Python\\Lib\\site-packages\\`.
171
Georg Brandl7306ad52010-10-17 10:05:13 +0000172This is how :data:`sys.path` is populated on Windows:
Christian Heimesd8654cf2007-12-02 15:22:16 +0000173
Georg Brandl7306ad52010-10-17 10:05:13 +0000174* An empty entry is added at the start, which corresponds to the current
175 directory.
Christian Heimesd8654cf2007-12-02 15:22:16 +0000176
Georg Brandl7306ad52010-10-17 10:05:13 +0000177* If the environment variable :envvar:`PYTHONPATH` exists, as described in
178 :ref:`using-on-envvars`, its entries are added next. Note that on Windows,
179 paths in this variable must be separated by semicolons, to distinguish them
180 from the colon used in drive identifiers (``C:\`` etc.).
Christian Heimesd8654cf2007-12-02 15:22:16 +0000181
Georg Brandl7306ad52010-10-17 10:05:13 +0000182* Additional "application paths" can be added in the registry as subkeys of
183 :samp:`\\SOFTWARE\\Python\\PythonCore\\{version}\\PythonPath` under both the
184 ``HKEY_CURRENT_USER`` and ``HKEY_LOCAL_MACHINE`` hives. Subkeys which have
185 semicolon-delimited path strings as their default value will cause each path
186 to be added to :data:`sys.path`. (Note that all known installers only use
187 HKLM, so HKCU is typically empty.)
188
189* If the environment variable :envvar:`PYTHONHOME` is set, it is assumed as
190 "Python Home". Otherwise, the path of the main Python executable is used to
191 locate a "landmark file" (``Lib\os.py``) to deduce the "Python Home". If a
192 Python home is found, the relevant sub-directories added to :data:`sys.path`
193 (``Lib``, ``plat-win``, etc) are based on that folder. Otherwise, the core
194 Python path is constructed from the PythonPath stored in the registry.
195
196* If the Python Home cannot be located, no :envvar:`PYTHONPATH` is specified in
197 the environment, and no registry entries can be found, a default path with
198 relative entries is used (e.g. ``.\Lib;.\plat-win``, etc).
199
200The end result of all this is:
201
202* When running :file:`python.exe`, or any other .exe in the main Python
203 directory (either an installed version, or directly from the PCbuild
204 directory), the core path is deduced, and the core paths in the registry are
205 ignored. Other "application paths" in the registry are always read.
206
207* When Python is hosted in another .exe (different directory, embedded via COM,
208 etc), the "Python Home" will not be deduced, so the core path from the
209 registry is used. Other "application paths" in the registry are always read.
210
211* If Python can't find its home and there is no registry (eg, frozen .exe, some
212 very strange installation setup) you get a path with some default, but
213 relative, paths.
Christian Heimesd8654cf2007-12-02 15:22:16 +0000214
215
216Executing scripts
217-----------------
218
Vinay Sajipd89dae12012-06-24 11:23:07 +0100219As of Python 3.3, Python includes a launcher which facilitates running Python
220scripts. See :ref:`launcher` for more information.
221
222Executing scripts without the Python launcher
223---------------------------------------------
224
225Without the Python launcher installed, Python scripts (files with the extension
226``.py``) will be executed by :program:`python.exe` by default. This executable
227opens a terminal, which stays open even if the program uses a GUI. If you do
228not want this to happen, use the extension ``.pyw`` which will cause the script
229to be executed by :program:`pythonw.exe` by default (both executables are
230located in the top-level of your Python installation directory). This
231suppresses the terminal window on startup.
Christian Heimesd8654cf2007-12-02 15:22:16 +0000232
233You can also make all ``.py`` scripts execute with :program:`pythonw.exe`,
Georg Brandl2ee470f2008-07-16 12:55:28 +0000234setting this through the usual facilities, for example (might require
Christian Heimes2380ac72008-01-09 00:17:24 +0000235administrative rights):
Christian Heimesd8654cf2007-12-02 15:22:16 +0000236
Christian Heimes2380ac72008-01-09 00:17:24 +0000237#. Launch a command prompt.
238#. Associate the correct file group with ``.py`` scripts::
Georg Brandl48310cd2009-01-03 21:18:54 +0000239
Christian Heimes2380ac72008-01-09 00:17:24 +0000240 assoc .py=Python.File
Christian Heimesd8654cf2007-12-02 15:22:16 +0000241
Christian Heimes2380ac72008-01-09 00:17:24 +0000242#. Redirect all Python files to the new executable::
Georg Brandl48310cd2009-01-03 21:18:54 +0000243
Christian Heimes2380ac72008-01-09 00:17:24 +0000244 ftype Python.File=C:\Path\to\pythonw.exe "%1" %*
Christian Heimesd8654cf2007-12-02 15:22:16 +0000245
246
Vinay Sajipd89dae12012-06-24 11:23:07 +0100247.. _launcher:
248
249Python Launcher for Windows
250===========================
251
252.. versionadded:: 3.3
253
254The Python launcher for Windows is a utility which aids in the location and
255execution of different Python versions. It allows scripts (or the
256command-line) to indicate a preference for a specific Python version, and
257will locate and execute that version.
258
259Getting started
260---------------
261
262From the command-line
263^^^^^^^^^^^^^^^^^^^^^
264
265You should ensure the launcher is on your PATH - depending on how it was
266installed it may already be there, but check just in case it is not.
267
268From a command-prompt, execute the following command:
269
270::
271
272 py
273
274You should find that the latest version of Python 2.x you have installed is
275started - it can be exited as normal, and any additional command-line
276arguments specified will be sent directly to Python.
277
278If you have multiple versions of Python 2.x installed (e.g., 2.6 and 2.7) you
279will have noticed that Python 2.7 was started - to launch Python 2.6, try the
280command:
281
282::
283
284 py -2.6
285
286If you have a Python 3.x installed, try the command:
287
288::
289
290 py -3
291
292You should find the latest version of Python 3.x starts.
293
294From a script
295^^^^^^^^^^^^^
296
297Let's create a test Python script - create a file called ``hello.py`` with the
298following contents
299
300::
301
302 #! python
303 import sys
304 sys.stdout.write("hello from Python %s\n" % (sys.version,))
305
306From the directory in which hello.py lives, execute the command:
307
308::
309
310 py hello.py
311
312You should notice the version number of your latest Python 2.x installation
313is printed. Now try changing the first line to be:
314
315::
316
317 #! python3
318
319Re-executing the command should now print the latest Python 3.x information.
320As with the above command-line examples, you can specify a more explicit
321version qualifier. Assuming you have Python 2.6 installed, try changing the
322first line to ``#! python2.6`` and you should find the 2.6 version
323information printed.
324
325From file associations
326^^^^^^^^^^^^^^^^^^^^^^
327
328The launcher should have been associated with Python files (i.e. ``.py``,
329``.pyw``, ``.pyc``, ``.pyo`` files) when it was installed. This means that
330when you double-click on one of these files from Windows explorer the launcher
331will be used, and therefore you can use the same facilities described above to
332have the script specify the version which should be used.
333
334The key benefit of this is that a single launcher can support multiple Python
335versions at the same time depending on the contents of the first line.
336
337Shebang Lines
338-------------
339
340If the first line of a script file starts with ``#!``, it is known as a
341"shebang" line. Linux and other Unix like operating systems have native
342support for such lines and are commonly used on such systems to indicate how
343a script should be executed. This launcher allows the same facilities to be
344using with Python scripts on Windows and the examples above demonstrate their
345use.
346
347To allow shebang lines in Python scripts to be portable between Unix and
348Windows, this launcher supports a number of 'virtual' commands to specify
349which interpreter to use. The supported virtual commands are:
350
351* ``/usr/bin/env python``
352* ``/usr/bin/python``
353* ``/usr/local/bin/python``
354* ``python``
355
356For example, if the first line of your script starts with
357
358::
359
360 #! /usr/bin/python
361
362The default Python will be located and used. As many Python scripts written
363to work on Unix will already have this line, you should find these scripts can
364be used by the launcher without modification. If you are writing a new script
365on Windows which you hope will be useful on Unix, you should use one of the
366shebang lines starting with ``/usr``.
367
368Arguments in shebang lines
369--------------------------
370
371The shebang lines can also specify additional options to be passed to the
372Python interpreter. For example, if you have a shebang line:
373
374::
375
376 #! /usr/bin/python -v
377
378Then Python will be started with the ``-v`` option
379
380Customization
381-------------
382
383Customization via INI files
384^^^^^^^^^^^^^^^^^^^^^^^^^^^
385
386 Two .ini files will be searched by the launcher - ``py.ini`` in the
387 current user's "application data" directory (i.e. the directory returned
388 by calling the Windows function SHGetFolderPath with CSIDL_LOCAL_APPDATA)
389 and ``py.ini`` in the same directory as the launcher. The same .ini
390 files are used for both the 'console' version of the launcher (i.e.
391 py.exe) and for the 'windows' version (i.e. pyw.exe)
392
393 Customization specified in the "application directory" will have
394 precedence over the one next to the executable, so a user, who may not
395 have write access to the .ini file next to the launcher, can override
396 commands in that global .ini file)
397
398Customizing default Python versions
399^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
400
401In some cases, a version qualifier can be included in a command to dictate
402which version of Python will be used by the command. A version qualifier
403starts with a major version number and can optionally be followed by a period
404('.') and a minor version specifier. If the minor qualifier is specified, it
405may optionally be followed by "-32" to indicate the 32-bit implementation of
406that version be used.
407
408For example, a shebang line of ``#!python`` has no version qualifier, while
409``#!python3`` has a version qualifier which specifies only a major version.
410
411If no version qualifiers are found in a command, the environment variable
412``PY_PYTHON`` can be set to specify the default version qualifier - the default
413value is "2". Note this value could specify just a major version (e.g. "2") or
414a major.minor qualifier (e.g. "2.6"), or even major.minor-32.
415
416If no minor version qualifiers are found, the environment variable
417``PY_PYTHON{major}`` (where ``{major}`` is the current major version qualifier
418as determined above) can be set to specify the full version. If no such option
419is found, the launcher will enumerate the installed Python versions and use
420the latest minor release found for the major version, which is likely,
421although not guaranteed, to be the most recently installed version in that
422family.
423
424On 64-bit Windows with both 32-bit and 64-bit implementations of the same
425(major.minor) Python version installed, the 64-bit version will always be
426preferred. This will be true for both 32-bit and 64-bit implementations of the
427launcher - a 32-bit launcher will prefer to execute a 64-bit Python installation
428of the specified version if available. This is so the behavior of the launcher
429can be predicted knowing only what versions are installed on the PC and
430without regard to the order in which they were installed (i.e., without knowing
431whether a 32 or 64-bit version of Python and corresponding launcher was
432installed last). As noted above, an optional "-32" suffix can be used on a
433version specifier to change this behaviour.
434
435Examples:
436
437* If no relevant options are set, the commands ``python`` and
438 ``python2`` will use the latest Python 2.x version installed and
439 the command ``python3`` will use the latest Python 3.x installed.
440
441* The commands ``python3.1`` and ``python2.7`` will not consult any
442 options at all as the versions are fully specified.
443
444* If ``PY_PYTHON=3``, the commands ``python`` and ``python3`` will both use
445 the latest installed Python 3 version.
446
447* If ``PY_PYTHON=3.1-32``, the command ``python`` will use the 32-bit
448 implementation of 3.1 whereas the command ``python3`` will use the latest
449 installed Python (PY_PYTHON was not considered at all as a major
450 version was specified.)
451
452* If ``PY_PYTHON=3`` and ``PY_PYTHON3=3.1``, the commands
453 ``python`` and ``python3`` will both use specifically 3.1
454
455In addition to environment variables, the same settings can be configured
456in the .INI file used by the launcher. The section in the INI file is
457called ``[defaults]`` and the key name will be the same as the
Ezio Melotti5b69fbd2012-10-19 20:40:18 +0300458environment variables without the leading ``PY_`` prefix (and note that
Vinay Sajipd89dae12012-06-24 11:23:07 +0100459the key names in the INI file are case insensitive.) The contents of
460an environment variable will override things specified in the INI file.
461
462For example:
463
464* Setting ``PY_PYTHON=3.1`` is equivalent to the INI file containing:
465
466::
467
468 [defaults]
469 python=3.1
470
471* Setting ``PY_PYTHON=3`` and ``PY_PYTHON3=3.1`` is equivalent to the INI file
472 containing:
473
474::
475
476 [defaults]
477 python=3
478 python3=3.1
479
480Diagnostics
481-----------
482
483If an environment variable ``PYLAUNCH_DEBUG`` is set (to any value), the
484launcher will print diagnostic information to stderr (i.e. to the console).
485While this information manages to be simultaneously verbose *and* terse, it
486should allow you to see what versions of Python were located, why a
487particular version was chosen and the exact command-line used to execute the
488target Python.
489
490
Christian Heimesd8654cf2007-12-02 15:22:16 +0000491Additional modules
492==================
493
494Even though Python aims to be portable among all platforms, there are features
495that are unique to Windows. A couple of modules, both in the standard library
496and external, and snippets exist to use these features.
497
498The Windows-specific standard modules are documented in
499:ref:`mswin-specific-services`.
500
501
502PyWin32
503-------
504
505The `PyWin32 <http://python.net/crew/mhammond/win32/>`_ module by Mark Hammond
506is a collection of modules for advanced Windows-specific support. This includes
Georg Brandl2ee470f2008-07-16 12:55:28 +0000507utilities for:
Christian Heimesd8654cf2007-12-02 15:22:16 +0000508
509* `Component Object Model <http://www.microsoft.com/com/>`_ (COM)
510* Win32 API calls
511* Registry
512* Event log
Georg Brandl495f7b52009-10-27 15:28:25 +0000513* `Microsoft Foundation Classes <http://msdn.microsoft.com/en-us/library/fe1cf721%28VS.80%29.aspx>`_ (MFC)
Christian Heimesd8654cf2007-12-02 15:22:16 +0000514 user interfaces
515
516`PythonWin <http://web.archive.org/web/20060524042422/
Georg Brandle73778c2014-10-29 08:36:35 +0100517https://www.python.org/windows/pythonwin/>`_ is a sample MFC application
Christian Heimesd8654cf2007-12-02 15:22:16 +0000518shipped with PyWin32. It is an embeddable IDE with a built-in debugger.
519
520.. seealso::
521
522 `Win32 How Do I...? <http://timgolden.me.uk/python/win32_how_do_i.html>`_
523 by Tim Golden
524
525 `Python and COM <http://www.boddie.org.uk/python/COM.html>`_
526 by David and Paul Boddie
527
528
Zachary Warec3cf97b2014-01-17 15:23:42 -0600529cx_Freeze
530---------
Christian Heimesd8654cf2007-12-02 15:22:16 +0000531
Zachary Warec3cf97b2014-01-17 15:23:42 -0600532`cx_Freeze <http://cx-freeze.sourceforge.net/>`_ is a :mod:`distutils`
533extension (see :ref:`extending-distutils`) which wraps Python scripts into
534executable Windows programs (:file:`{*}.exe` files). When you have done this,
535you can distribute your application without requiring your users to install
536Python.
Christian Heimesd8654cf2007-12-02 15:22:16 +0000537
538
539WConio
540------
541
542Since Python's advanced terminal handling layer, :mod:`curses`, is restricted to
543Unix-like systems, there is a library exclusive to Windows as well: Windows
544Console I/O for Python.
545
546`WConio <http://newcenturycomputers.net/projects/wconio.html>`_ is a wrapper for
547Turbo-C's :file:`CONIO.H`, used to create text user interfaces.
548
549
550
551Compiling Python on Windows
552===========================
553
554If you want to compile CPython yourself, first thing you should do is get the
Georg Brandle73778c2014-10-29 08:36:35 +0100555`source <https://www.python.org/download/source/>`_. You can download either the
Christian Heimesd8654cf2007-12-02 15:22:16 +0000556latest release's source or just grab a fresh `checkout
Georg Brandlb7354a62014-10-29 10:57:37 +0100557<https://docs.python.org/devguide/setup.html#getting-the-source-code>`_.
Christian Heimesd8654cf2007-12-02 15:22:16 +0000558
Zachary Waref8ceb042013-11-30 16:59:33 -0600559The source tree contains a build solution and project files for Microsoft
560Visual C++, which is the compiler used to build the official Python releases.
561View the :file:`readme.txt` in their respective directories:
Christian Heimesd8654cf2007-12-02 15:22:16 +0000562
563+--------------------+--------------+-----------------------+
564| Directory | MSVC version | Visual Studio version |
565+====================+==============+=======================+
Zachary Waref8ceb042013-11-30 16:59:33 -0600566| :file:`PC/VS9.0/` | 9.0 | 2008 |
Christian Heimesd8654cf2007-12-02 15:22:16 +0000567+--------------------+--------------+-----------------------+
Zachary Waref8ceb042013-11-30 16:59:33 -0600568| :file:`PCbuild/` | 10.0 | 2010 |
Christian Heimesd8654cf2007-12-02 15:22:16 +0000569+--------------------+--------------+-----------------------+
570
Zachary Waref8ceb042013-11-30 16:59:33 -0600571Note that any build directories within the :file:`PC` directory are not
572necessarily fully supported. The :file:`PCbuild` directory contains the files
573for the compiler used to build the official release.
Christian Heimesd8654cf2007-12-02 15:22:16 +0000574
Zachary Waref8ceb042013-11-30 16:59:33 -0600575Check :file:`PCbuild/readme.txt` for general information on the build process.
Christian Heimesd8654cf2007-12-02 15:22:16 +0000576
577
578For extension modules, consult :ref:`building-on-windows`.
579
580.. seealso::
581
582 `Python + Windows + distutils + SWIG + gcc MinGW <http://sebsauvage.net/python/mingw.html>`_
583 or "Creating Python extensions in C/C++ with SWIG and compiling them with
584 MinGW gcc under Windows" or "Installing Python extension with distutils
585 and without Microsoft Visual C++" by Sébastien Sauvage, 2003
586
Georg Brandl495f7b52009-10-27 15:28:25 +0000587 `MingW -- Python extensions <http://oldwiki.mingw.org/index.php/Python%20extensions>`_
Christian Heimesd8654cf2007-12-02 15:22:16 +0000588 by Trent Apted et al, 2007
589
590
591Other resources
592===============
593
594.. seealso::
595
Georg Brandlb7354a62014-10-29 10:57:37 +0100596 `Python Programming On Win32 <http://shop.oreilly.com/product/9781565926219.do>`_
Christian Heimesd8654cf2007-12-02 15:22:16 +0000597 "Help for Windows Programmers"
598 by Mark Hammond and Andy Robinson, O'Reilly Media, 2000,
599 ISBN 1-56592-621-8
600
601 `A Python for Windows Tutorial <http://www.imladris.com/Scripts/PythonForWindows.html>`_
602 by Amanda Birmingham, 2004
603
Vinay Sajipd89dae12012-06-24 11:23:07 +0100604 :pep:`397` - Python launcher for Windows
605 The proposal for the launcher to be included in the Python distribution.
606
607