GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — TST: fix linting, add dependency on meson for tests · numpy/numpy@d86576c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • numpy/random/tests
    • test_extending.py
  • test_requirements.txt
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎numpy/random/tests/test_extending.py‎

Copy file name to clipboardExpand all lines: numpy/random/tests/test_extending.py
+10-10Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import importlib
1+
from importlib.util import spec_from_file_location, module_from_spec
22
import os
33
import pathlib
44
import pytest
@@ -60,7 +60,9 @@ def test_cython(tmp_path):
6060
# We don't want a wheel build, so do the steps in a controlled way
6161
# The meson.build file is not copied as part of the build, so generate it
6262
with open(build_dir / "meson.build", "wt", encoding="utf-8") as fid:
63-
fid.write(textwrap.dedent("""\
63+
get_inc = ('import os; os.chdir(".."); import numpy; '
64+
'print(os.path.abspath(numpy.get_include() + "../../.."))')
65+
fid.write(textwrap.dedent(f"""\
6466
project('random-build-examples', 'c', 'cpp', 'cython')
6567
6668
# https://mesonbuild.com/Python-module.html
@@ -77,10 +79,8 @@ def test_cython(tmp_path):
7779
error('tests requires Cython >= 0.29.35')
7880
endif
7981
80-
_numpy_abs = run_command(py3,
81-
['-c', 'import os; os.chdir(".."); import numpy; print(os.path.abspath(numpy.get_include() + "../../.."))'],
82-
check: true
83-
).stdout().strip()
82+
_numpy_abs = run_command(py3, ['-c', '{get_inc}'],
83+
check: true).stdout().strip()
8484
8585
npymath_path = _numpy_abs / 'core' / 'lib'
8686
npy_include_path = _numpy_abs / 'core' / 'include'
@@ -123,11 +123,11 @@ def test_cython(tmp_path):
123123
# import without adding the directory to sys.path
124124
so1 = sorted(glob.glob(str(target_dir / "extending.*")))[0]
125125
so2 = sorted(glob.glob(str(target_dir / "extending_distributions.*")))[0]
126-
spec1 = importlib.util.spec_from_file_location("extending", so1)
127-
spec2 = importlib.util.spec_from_file_location("extending_distributions", so2)
128-
extending = importlib.util.module_from_spec(spec1)
126+
spec1 = spec_from_file_location("extending", so1)
127+
spec2 = spec_from_file_location("extending_distributions", so2)
128+
extending = module_from_spec(spec1)
129129
spec1.loader.exec_module(extending)
130-
extending_distributions = importlib.util.module_from_spec(spec2)
130+
extending_distributions = module_from_spec(spec2)
131131
spec2.loader.exec_module(extending_distributions)
132132
# actually test the cython c-extension
133133
from numpy.random import PCG64
Collapse file

‎test_requirements.txt‎

Copy file name to clipboardExpand all lines: test_requirements.txt
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ cython>=0.29.34,<3.0
22
wheel==0.38.1
33
setuptools==59.2.0 ; python_version < '3.12'
44
setuptools ; python_version >= '3.12'
5+
meson
56
hypothesis==6.24.1
67
pytest==6.2.5
78
pytz==2021.3

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.