Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 40eaa55

Browse files
mattiprgommers
authored andcommitted
BUILD: fixes for MSVC
1 parent f6eaca8 commit 40eaa55

5 files changed

Lines changed: 31 additions & 13 deletions

File tree

building_with_meson.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ into a problem._
99

1010
**Install build tools:** Use one of:
1111

12-
- `mamba create -f environment.yml
13-
- `pip install -r build_requirements.txt # also make sure you have pkg-config and the usual system dependencies for NumPy`
12+
- `mamba env create -f environment.yml && mamba activate numpy-dev
13+
14+
- `python -m pip install -r build_requirements.txt
15+
# also make sure you have pkg-config and the usual system dependencies for
16+
# NumPy`
17+
18+
Then install devpy:
19+
- `python -m pip install git+https://github.com/scientific-python/devpy`
1420

1521
**Compile and install:** `./dev.py build`
1622

environment.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ dependencies:
1515
- setuptools=59.2.0
1616
- meson >= 0.64.0
1717
- ninja
18-
- pkg-config # note: not available on Windows, comment out this line
18+
- pkg-config
1919
- meson-python
20+
- pip # so you can use pip to install devpy
2021
# For testing
2122
- pytest
2223
- pytest-cov

numpy/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@
112112
ComplexWarning, ModuleDeprecationWarning, VisibleDeprecationWarning,
113113
TooHardError, AxisError)
114114

115+
# Allow distributors to run custom init code before importing numpy.core
116+
from . import _distributor_init
117+
115118
# We first need to detect if we're being called as part of the numpy setup
116119
# procedure itself in a reliable manner.
117120
try:
@@ -137,9 +140,6 @@
137140
# mapping of {name: (value, deprecation_msg)}
138141
__deprecated_attrs__ = {}
139142

140-
# Allow distributors to run custom init code
141-
from . import _distributor_init
142-
143143
from . import core
144144
from .core import *
145145
from . import compat

numpy/core/meson.build

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,19 @@ cdata.set('NPY_SIZEOF_PY_LONG_LONG',
109109
if cc.has_header('complex.h')
110110
cdata.set10('HAVE_COMPLEX_H', true)
111111
cdata.set10('NPY_USE_C99_COMPLEX', true)
112-
complex_types_to_check = [
113-
['NPY_HAVE_COMPLEX_FLOAT', 'NPY_SIZEOF_COMPLEX_FLOAT', 'complex float', 'float'],
114-
['NPY_HAVE_COMPLEX_DOUBLE', 'NPY_SIZEOF_COMPLEX_DOUBLE', 'complex double', 'double'],
115-
['NPY_HAVE_COMPLEX_LONG_DOUBLE', 'NPY_SIZEOF_COMPLEX_LONGDOUBLE', 'complex long double', 'long double'],
116-
]
112+
if cc.get_id() == 'msvc'
113+
complex_types_to_check = [
114+
['NPY_HAVE_COMPLEX_FLOAT', 'NPY_SIZEOF_COMPLEX_FLOAT', '_Fcomplex', 'float'],
115+
['NPY_HAVE_COMPLEX_DOUBLE', 'NPY_SIZEOF_COMPLEX_DOUBLE', '_Dcomplex', 'double'],
116+
['NPY_HAVE_COMPLEX_LONG_DOUBLE', 'NPY_SIZEOF_COMPLEX_LONGDOUBLE', '_Lcomplex', 'long double'],
117+
]
118+
else
119+
complex_types_to_check = [
120+
['NPY_HAVE_COMPLEX_FLOAT', 'NPY_SIZEOF_COMPLEX_FLOAT', 'complex float', 'float'],
121+
['NPY_HAVE_COMPLEX_DOUBLE', 'NPY_SIZEOF_COMPLEX_DOUBLE', 'complex double', 'double'],
122+
['NPY_HAVE_COMPLEX_LONG_DOUBLE', 'NPY_SIZEOF_COMPLEX_LONGDOUBLE', 'complex long double', 'long double'],
123+
]
124+
endif
117125
foreach symbol_type: complex_types_to_check
118126
if cc.has_type(symbol_type[2], prefix: '#include <complex.h>')
119127
cdata.set10(symbol_type[0], true)
@@ -250,7 +258,9 @@ else
250258
# function is not available in CI. For the latter there is a fallback path,
251259
# but that is broken because we don't have the exact long double
252260
# representation checks.
253-
cdata.set10('HAVE_STRTOLD_L', false)
261+
if cc.get_id() != 'msvc'
262+
cdata.set10('HAVE_STRTOLD_L', false)
263+
endif
254264
endif
255265

256266
# Other optional functions
@@ -451,7 +461,7 @@ if cc.get_id() == 'msvc'
451461
# libnpymath and libnpyrandom)
452462
if cc.has_argument('-d2VolatileMetadata-')
453463
staticlib_cflags += '-d2VolatileMetadata-'
454-
endif
464+
endif
455465
endif
456466
# TODO: change to "feature" option in meson_options.txt? See
457467
# https://mesonbuild.com/Build-options.html#build-options

numpy/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ endif
1010
# Platform detection
1111
is_windows = host_machine.system() == 'windows'
1212
is_mingw = is_windows and cc.get_id() == 'gcc'
13+
is_msvc = is_windows and cc.get_id() == 'msvc'
1314

1415
if is_windows
1516
# For mingw-w64, link statically against the UCRT.

0 commit comments

Comments
 (0)