Skip to content

BLD: fix bug in random.mtrand extension, don't link libnpyrandom #24664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions numpy/random/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ npyrandom_sources = [
npyrandom_lib = static_library('npyrandom',
npyrandom_sources,
c_args: staticlib_cflags,
# include_directories: '../core/include',
dependencies: [py_dep, np_core_dep],
install: true,
install_dir: np_dir / 'random/lib',
Expand Down Expand Up @@ -52,23 +51,26 @@ if host_machine.system() == 'cygwin'
c_args_random += ['-Wl,--export-all-symbols']
endif

# name, sources, extra link libs, extra c_args
# name, sources, extra c_args, extra static libs to link
random_pyx_sources = [
['_bounded_integers', _bounded_integers_pyx, [], npymath_lib],
['_common', '_common.pyx', [], []],
['_mt19937', ['_mt19937.pyx', 'src/mt19937/mt19937.c', 'src/mt19937/mt19937-jump.c'], [], []],
['_philox', ['_philox.pyx', 'src/philox/philox.c'], [], []],
['_pcg64', ['_pcg64.pyx', 'src/pcg64/pcg64.c'], ['-U__GNUC_GNU_INLINE__'], []],
['_sfc64', ['_sfc64.pyx', 'src/sfc64/sfc64.c'], [], []],
['bit_generator', 'bit_generator.pyx', [], []],
['_bounded_integers', _bounded_integers_pyx, [], [npyrandom_lib, npymath_lib]],
['_common', '_common.pyx', [], [npyrandom_lib]],
['_mt19937', ['_mt19937.pyx', 'src/mt19937/mt19937.c', 'src/mt19937/mt19937-jump.c'],
[], [npyrandom_lib]
],
['_philox', ['_philox.pyx', 'src/philox/philox.c'], [], [npyrandom_lib]],
['_pcg64', ['_pcg64.pyx', 'src/pcg64/pcg64.c'], ['-U__GNUC_GNU_INLINE__'], [npyrandom_lib]],
['_sfc64', ['_sfc64.pyx', 'src/sfc64/sfc64.c'], [], [npyrandom_lib]],
['bit_generator', 'bit_generator.pyx', [], [npyrandom_lib]],
# The `fs.copyfile` usage here is needed because these two .pyx files import
# from _bounded_integers,and its pxd file is only present in the build directory
['_generator', fs.copyfile('_generator.pyx'), [], npymath_lib],
['_generator', fs.copyfile('_generator.pyx'), [], [npyrandom_lib, npymath_lib]],
['mtrand', [
fs.copyfile('mtrand.pyx'),
'src/distributions/distributions.c',
'src/legacy/legacy-distributions.c'
], ['-DNP_RANDOM_LEGACY=1'], npymath_lib,
],
['-DNP_RANDOM_LEGACY=1'], [npymath_lib],
],
]
foreach gen: random_pyx_sources
Expand All @@ -77,7 +79,7 @@ foreach gen: random_pyx_sources
c_args: [c_args_random, gen[2]],
include_directories: 'src',
dependencies: np_core_dep,
link_with: [npyrandom_lib, gen[3]],
link_with: gen[3],
install: true,
subdir: 'numpy/random',
)
Expand Down