# Feature Request: find Python3 package

**URL:** https://discourse.cmake.org/t/feature-request-find-python3-package/11337
**Category:** Development
**Created:** [July 27, 2024, 11:29am UTC](https://discourse.cmake.org/t/feature-request-find-python3-package/11337 "2024-07-27T11:29:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mwtoews](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mwtoews/32/4805_2.png) [@mwtoews](https://discourse.cmake.org/u/mwtoews)
#### Post date: [July 27, 2024, 11:29am UTC](https://discourse.cmake.org/t/feature-request-find-python3-package/11337/1 "2024-07-27T11:29:22Z")

</div>

In a project I’m involved with, we need to check if certain Python packages are available to the interpreter. To do this, I have written a basic macro [`find_Python3_package`](https://github.com/OSGeo/PROJ/blob/7d766a4ba112ec71c9e861c66d571cbdddd71009/test/cli/CMakeLists.txt#L39-L85).

This is used in a CMake block like this:

```cmake
find_package(Python3 COMPONENTS Interpreter)
if(Python3_FOUND)
  find_Python3_package("pyyaml" HAS_PYYAML)
  find_Python3_package("ruamel.yaml" HAS_RUAMEL_YAML)
endif()

```

with a possible CMake configure output:

```auto
...
-- Found Python3: /usr/bin/python3.10 (found version "3.10.12") found components: Interpreter 
-- Looking for pyyaml
-- Looking for pyyaml - not found
-- Looking for ruamel.yaml
-- Looking for ruamel.yaml - found version "0.17.16"
...

```

I think this type of functionality could be potentially useful for others, and I don’t believe it exists anywhere else. Is it within scope to refine and contribute to the CMake source? I can push this effort, but I might need some guidance.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 19, 2025, 1:51pm UTC](https://discourse.cmake.org/t/feature-request-find-python3-package/11337/2 "2025-07-19T13:51:36Z")

</div>

VTK has [this module](https://gitlab.kitware.com/vtk/vtk/-/blob/master/CMake/FindPythonModules.cmake) as well, but it doesn’t extract version information.

Cc: @marc.chevrier

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [July 19, 2025, 4:38pm UTC](https://discourse.cmake.org/t/feature-request-find-python3-package/11337/3 "2025-07-19T16:38:32Z")

</div>

I don’t think a such module is acceptable to be part of CMake distribution for the following reasons:

1. The rule is to not accept any new module because the maintenance cost is, by far, too high and regularly raise problems because CMake releases are not in sync with artifacts release managed by the module, so regularly the modules become obsolete and cannot be fixed until the next CMake delivery.
2. What you suggest implies a **lot** of developments (nearly infinite because `python` supports numerous packages) and a high cost of maintenance. So, a such module will be nearly always obsolete related to some python package…
