Skip to content

Commit

Permalink
set WINVER in compiler configuration
Browse files Browse the repository at this point in the history
we don't have source control over libzmq itself to add includes
  • Loading branch information
minrk committed Jan 20, 2021
1 parent 549ca7f commit 2b54673
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions buildutils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,21 @@ def discover_settings(conf_base=None):
'bundle_msvcp': None,
'build_ext': {},
'bdist_egg': {},
'win_ver': None,
}
if sys.platform.startswith('win'):
settings['have_sys_un_h'] = False
# target Windows version, sets WINVER, _WIN32_WINNT macros
# see https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt for reference
# see https://github.com/python/cpython/blob/v3.9.1/PC/pyconfig.h#L137-L159
# for CPython's own values
if sys.version_info >= (3, 9):
# CPython 3.9 targets Windows 8 (0x0602)
settings["win_ver"] = "0x0602"
else:
# older Python, target Windows 7 (0x0601)
# CPython itself targets Vista (0x0600)
settings["win_ver"] = "0x0601"

if conf_base:
# lowest priority
Expand Down
7 changes: 7 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,13 @@ def init_settings_from_config(self):
if cfg['have_sys_un_h']:
settings['define_macros'].append(('HAVE_SYS_UN_H', 1))

if cfg['win_ver']:
# set target minimum Windows version
settings['define_macros'].extend([
('WINVER', cfg['win_ver']),
('_WIN32_WINNT', cfg['win_ver']),
])

if cfg.get('zmq_draft_api'):
settings['define_macros'].append(('ZMQ_BUILD_DRAFT_API', 1))

Expand Down

0 comments on commit 2b54673

Please sign in to comment.