# Python3\_add\_library should get defined even if libpython not present

**URL:** https://discourse.cmake.org/t/python3-add-library-should-get-defined-even-if-libpython-not-present/4640
**Category:** Usage
**Tags:** os:linux
**Created:** [December 10, 2021, 5:54pm UTC](https://discourse.cmake.org/t/python3-add-library-should-get-defined-even-if-libpython-not-present/4640 "2021-12-10T17:54:00Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Catherine\_Holloway](https://discourse.cmake.org/user_avatar/discourse.cmake.org/catherine_holloway/32/1958_2.png) [@Catherine\_Holloway](https://discourse.cmake.org/u/Catherine_Holloway)
#### Post date: [December 10, 2021, 5:54pm UTC](https://discourse.cmake.org/t/python3-add-library-should-get-defined-even-if-libpython-not-present/4640/1 "2021-12-10T17:54:00Z")

</div>

Python3\_add\_library doesn’t get defined unless the “Development” component is requested in find\_package, but “Development” will fail to be defined if libpython\*.so is not present. For example, the manylinux project docker images don’t have the libpython shared objects or python development packages.

However, it is completely possible to create valid python extensions without libpython\*.so. I can set Python3\_LIBRARY to something invalid and it will build perfectly fine. I can look at all the resulting makefiles from a successful build and there’s no usage of libpython\*.so. Is there a way I can force Python3\_add\_library to be defined without searching for the “development” component?

---

<div class="post-metadata">

### Author: ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)
#### Post date: [December 10, 2021, 6:00pm UTC](https://discourse.cmake.org/t/python3-add-library-should-get-defined-even-if-libpython-not-present/4640/2 "2021-12-10T18:00:16Z")

</div>

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: [December 10, 2021, 6:11pm UTC](https://discourse.cmake.org/t/python3-add-library-should-get-defined-even-if-libpython-not-present/4640/3 "2021-12-10T18:11:58Z")

</div>

You can use COMPONENT `Development.Module` rather than `Development`.  
On platforms other than `Windows`, the library is not required fir this component.

But anyway, I think your docker image is broken if you have python headers files but not the library…

---

<div class="post-metadata">

### Author: ![Catherine\_Holloway](https://discourse.cmake.org/user_avatar/discourse.cmake.org/catherine_holloway/32/1958_2.png) [@Catherine\_Holloway](https://discourse.cmake.org/u/Catherine_Holloway)
#### Post date: [December 10, 2021, 6:14pm UTC](https://discourse.cmake.org/t/python3-add-library-should-get-defined-even-if-libpython-not-present/4640/4 "2021-12-10T18:14:07Z")

</div>

It’s not my docker image, it’s the pypa team’s own manylinux image

---

<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: [December 10, 2021, 6:23pm UTC](https://discourse.cmake.org/t/python3-add-library-should-get-defined-even-if-libpython-not-present/4640/5 "2021-12-10T18:23:32Z")

</div>

To complete my answer, `Python3_add_library` must be used with type `MODULE` to use target `Python3::Module`.

---

<div class="post-metadata">

### Author: ![Catherine\_Holloway](https://discourse.cmake.org/user_avatar/discourse.cmake.org/catherine_holloway/32/1958_2.png) [@Catherine\_Holloway](https://discourse.cmake.org/u/Catherine_Holloway)
#### Post date: [December 10, 2021, 6:33pm UTC](https://discourse.cmake.org/t/python3-add-library-should-get-defined-even-if-libpython-not-present/4640/6 "2021-12-10T18:33:00Z")

</div>

thanks @marc.chevrier !
