Skip to content

MAINT: add ninja to test dependencies #755

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

Closed
wants to merge 1 commit into from

Conversation

tobiasdiez
Copy link
Contributor

It's needed to run the tests.

But the CI spends some time to install ninja from the system; so I'm not sure what's the best approach here. Maybe add a dev group?

@eli-schwartz
Copy link
Member

It's needed to run the tests.

But the CI spends some time to install ninja from the system; so I'm not sure what's the best approach here. Maybe add a dev group?

def get_requires_for_build_wheel(config_settings: Optional[Dict[str, str]] = None) -> List[str]:
dependencies = []
if os.environ.get('NINJA') is None and _env_ninja_command() is None:
dependencies.append(f'ninja >= {_NINJA_REQUIRED_VERSION}')
if sys.platform.startswith('linux') and not shutil.which('patchelf'):
dependencies.append('patchelf >= 0.11.0')
return dependencies

It uses itself as the build backend, and this "should" be dynamically added...

@tobiasdiez
Copy link
Contributor Author

In a new codespace:

$ pip install .[test]
Processing /workspaces/meson-python
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Collecting meson>=1.2.3 (from meson-python==0.19.0.dev0)
  Using cached meson-1.8.1-py3-none-any.whl.metadata (1.8 kB)
Requirement already satisfied: packaging>=23.2 in /home/codespace/.local/lib/python3.12/site-packages (from meson-python==0.19.0.dev0) (24.2)
Collecting pyproject-metadata>=0.9.0 (from meson-python==0.19.0.dev0)
  Using cached pyproject_metadata-0.9.1-py3-none-any.whl.metadata (7.0 kB)
Requirement already satisfied: build in /usr/local/python/3.12.1/lib/python3.12/site-packages (from meson-python==0.19.0.dev0) (1.2.2.post1)
Collecting pytest>=6.0 (from meson-python==0.19.0.dev0)
  Downloading pytest-8.3.5-py3-none-any.whl.metadata (7.6 kB)
Collecting pytest-cov[toml] (from meson-python==0.19.0.dev0)
  Downloading pytest_cov-6.1.1-py3-none-any.whl.metadata (28 kB)
Collecting pytest-mock (from meson-python==0.19.0.dev0)
  Downloading pytest_mock-3.14.1-py3-none-any.whl.metadata (3.9 kB)
Collecting cython>=3.0.3 (from meson-python==0.19.0.dev0)
  Downloading cython-3.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.5 kB)
Collecting wheel (from meson-python==0.19.0.dev0)
  Downloading wheel-0.45.1-py3-none-any.whl.metadata (2.3 kB)
Collecting iniconfig (from pytest>=6.0->meson-python==0.19.0.dev0)
  Downloading iniconfig-2.1.0-py3-none-any.whl.metadata (2.7 kB)
Collecting pluggy<2,>=1.5 (from pytest>=6.0->meson-python==0.19.0.dev0)
  Downloading pluggy-1.6.0-py3-none-any.whl.metadata (4.8 kB)
Requirement already satisfied: pyproject_hooks in /usr/local/python/3.12.1/lib/python3.12/site-packages (from build->meson-python==0.19.0.dev0) (1.2.0)
WARNING: pytest-cov 6.1.1 does not provide the extra 'toml'
Collecting coverage>=7.5 (from coverage[toml]>=7.5->pytest-cov[toml]; extra == "test"->meson-python==0.19.0.dev0)
  Downloading coverage-7.8.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (8.9 kB)
Downloading cython-3.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.2/3.2 MB 45.2 MB/s eta 0:00:00
Using cached meson-1.8.1-py3-none-any.whl (1.0 MB)
Using cached pyproject_metadata-0.9.1-py3-none-any.whl (18 kB)
Downloading pytest-8.3.5-py3-none-any.whl (343 kB)
Downloading pytest_mock-3.14.1-py3-none-any.whl (9.9 kB)
Downloading wheel-0.45.1-py3-none-any.whl (72 kB)
Downloading coverage-7.8.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (245 kB)
Downloading pluggy-1.6.0-py3-none-any.whl (20 kB)
Downloading iniconfig-2.1.0-py3-none-any.whl (6.0 kB)
Downloading pytest_cov-6.1.1-py3-none-any.whl (23 kB)
Building wheels for collected packages: meson-python
  Building wheel for meson-python (pyproject.toml) ... done
  Created wheel for meson-python: filename=meson_python-0.19.0.dev0-py3-none-any.whl size=28470 sha256=537742d78ccd2b8471f89a908ab2ad7864348e6077a6fa0758692e0a9275d3c0
  Stored in directory: /home/codespace/.cache/pip/wheels/16/e4/3a/e032a9adcc1b4ca8594ae3ff30b480c689beb3276609d64be7
Successfully built meson-python
Installing collected packages: wheel, pyproject-metadata, pluggy, meson, iniconfig, cython, coverage, pytest, meson-python, pytest-mock, pytest-cov
Successfully installed coverage-7.8.2 cython-3.1.1 iniconfig-2.1.0 meson-1.8.1 meson-python-0.19.0.dev0 pluggy-1.6.0 pyproject-metadata-0.9.1 pytest-8.3.5 pytest-cov-6.1.1 pytest-mock-3.14.1 wheel-0.45.1

[notice] A new release of pip is available: 25.0.1 -> 25.1.1
[notice] To update, run: python3 -m pip install --upgrade pip

$ pytest
================================================= test session starts =================================================
platform linux -- Python 3.12.1, pytest-8.3.5, pluggy-1.6.0
rootdir: /workspaces/meson-python
configfile: pyproject.toml
testpaths: tests
plugins: anyio-4.9.0, mock-3.14.1, cov-6.1.1
collected 132 items / 1 error                                                                                         

======================================================= ERRORS ========================================================
_______________________________________ ERROR collecting tests/test_options.py ________________________________________
tests/test_options.py:13: in <module>
    ninja_ver_str = subprocess.run(['ninja', '--version'], check=True, stdout=subprocess.PIPE, text=True).stdout
/usr/local/python/3.12.1/lib/python3.12/subprocess.py:548: in run
    with Popen(*popenargs, **kwargs) as process:
/usr/local/python/3.12.1/lib/python3.12/subprocess.py:1026: in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
/usr/local/python/3.12.1/lib/python3.12/subprocess.py:1950: in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
E   FileNotFoundError: [Errno 2] No such file or directory: 'ninja'
=============================================== short test summary info ===============================================
ERROR tests/test_options.py - FileNotFoundError: [Errno 2] No such file or directory: 'ninja'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================== 1 error in 0.62s ===================================================
̀ ``

@rgommers
Copy link
Contributor

But the CI spends some time to install ninja from the system; so I'm not sure what's the best approach here. Maybe add a dev group?

We consider using system ninja best practice for local development, so adding it to the test group is probably not ideal. Not 100% sure, maybe a separate group indeed so it is captured but not installed with .[test] for everything/everyone. Perhaps something like:

# Note: installing `ninja` with your system package manager is considered best practice
test-sysdeps = ['ninja']

@dnicolodi
Copy link
Member

Adding ninja to the test optional dependencies has the unwanted effect that it gets installed also when provided by the system. The preference is for using ninja from the system. I think this is better covered by documentation rather than by adding ninja to the test optional dependencies (or to any other optional dependency group).

@tobiasdiez
Copy link
Contributor Author

Okay, I've added installing ninja as an additional setup step in #752.

@tobiasdiez tobiasdiez closed this May 29, 2025
@tobiasdiez tobiasdiez deleted the ninja-dep branch May 29, 2025 14:37
@rgommers
Copy link
Contributor

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants