Skip to content

Commit 13dbabe

Browse files
author
Thomas Heller
committed
To build on windows, the manual editing of the python_nt.rc file to
change the version number is no longer required. Instead, a make_versioninfo.exe is compiled, which spits out an include file for python_nt.rc. Will backport to 2.3
1 parent b97f0b7 commit 13dbabe

5 files changed

Lines changed: 162 additions & 34 deletions

File tree

PC/.cvsignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pythonnt_rc.h
2+
pythonnt_rc_d.h

PC/make_versioninfo.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <stdio.h>
2+
#include "patchlevel.h"
3+
/*
4+
* This program prints out an include file containing fields required to build
5+
* the version info resource of pythonxx.dll because the resource compiler
6+
* cannot do the arithmetic.
7+
*/
8+
/*
9+
* FIELD3 is the third field of the version number.
10+
* This is what we'd like FIELD3 to be:
11+
*
12+
* #define FIELD3 (PY_MICRO_VERSION*1000 + PY_RELEASE_LEVEL*10 + PY_RELEASE_SERIAL)
13+
*
14+
* but that neither gives an error nor comes anywhere close to working.
15+
*
16+
* For 2.4a0,
17+
* PY_MICRO_VERSION = 0
18+
* PY_RELEASE_LEVEL = 'alpha' = 0xa
19+
* PY_RELEASE_SERIAL = 0
20+
*
21+
* gives FIELD3 = 0*1000 + 10*10 + 0 = 100
22+
*/
23+
int main(int argc, char **argv)
24+
{
25+
printf("/* This file created by make_versioninfo.exe */\n");
26+
printf("#define FIELD3 %d\n",
27+
PY_MICRO_VERSION*1000 + PY_RELEASE_LEVEL*10 + PY_RELEASE_SERIAL);
28+
printf("#define MS_DLL_ID \"%d.%d\"\n",
29+
PY_MAJOR_VERSION, PY_MINOR_VERSION);
30+
printf("#define PYTHON_DLL_NAME \"python%d%d.dll\"\n",
31+
PY_MAJOR_VERSION, PY_MINOR_VERSION);
32+
return 0;
33+
}

PC/python_nt.rc

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,12 @@
66
#define MS_WINDOWS
77
#include "modsupport.h"
88
#include "patchlevel.h"
9-
10-
/* Across releases, change:
11-
* MS_DLL_ID if the minor version number changes.
12-
* PYTHON_DLL_NAME ditto.
13-
* MS_DLL_ID must match PY_VERSION in the Windows install script.
14-
*/
15-
#define MS_DLL_ID "2.4"
16-
17-
#ifndef PYTHON_DLL_NAME
18-
#define PYTHON_DLL_NAME "python24.dll"
9+
#ifdef _DEBUG
10+
# include "pythonnt_rc_d.h"
11+
#else
12+
# include "pythonnt_rc.h"
1913
#endif
2014

21-
/* Nothing below this should need to be changed except for copyright
22-
* notices, company name, and FIELD3. Unfortunately, all attempts
23-
* to get the resource compiler to do arithmetic in macros have
24-
* failed miserably -- it gives syntax errors, ignores operators,
25-
* or does stuff that's simply bizarre.
26-
*/
27-
28-
29-
/* This is what we'd like FIELD3 to be:
30-
*
31-
* #define FIELD3 (PY_MICRO_VERSION*1000 + PY_RELEASE_LEVEL*10 + PY_RELEASE_SERIAL)
32-
*
33-
* but that neither gives an error nor comes anywhere close to working. The
34-
* following comment and #define are output from PCbuild\field3.py:
35-
*
36-
* For 2.4a0,
37-
* PY_MICRO_VERSION = 0
38-
* PY_RELEASE_LEVEL = 'alpha' = 0xa
39-
* PY_RELEASE_SERIAL = 0
40-
*
41-
* and 0*1000 + 10*10 + 0 = 100
42-
*/
43-
#define FIELD3 100
44-
4515
/* e.g., 2.1a2
4616
* PY_VERSION comes from patchevel.h
4717
*/

PCbuild/make_versioninfo.dsp

Lines changed: 108 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PCbuild/pcbuild.dsw

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,18 @@ Package=<4>
159159

160160
###############################################################################
161161

162+
Project: "make_versioninfo"=.\make_versioninfo.dsp - Package Owner=<4>
163+
164+
Package=<5>
165+
{{{
166+
}}}
167+
168+
Package=<4>
169+
{{{
170+
}}}
171+
172+
###############################################################################
173+
162174
Project: "mmap"=.\mmap.dsp - Package Owner=<4>
163175

164176
Package=<5>
@@ -227,6 +239,9 @@ Package=<5>
227239

228240
Package=<4>
229241
{{{
242+
Begin Project Dependency
243+
Project_Dep_Name make_versioninfo
244+
End Project Dependency
230245
}}}
231246

232247
###############################################################################

0 commit comments

Comments
 (0)