cmake: Rework python.cmake
- Dominant language
- C++
- Stars
- 14.1k
- Forks
- 2.5k
- Avg merge
- 8h 39m
- Merged PRs (30d)
- 72
Description
After few discussions with conda-forge maintainer few things to improve:
* [x] 0) Fix check of `__version__` in CheckPythonModule (not available for `absl`, `mypy_protobuf` etc...) (v9.2)
* [x] 1) Add flags to fail if missing python deps than trying to install them (in user space) (v9.2)
* [ ] 2) Be able to build a python lib using an already preinstalled or-tools C++
* [ ] 2.5) need a `FindORTOOLS.cmake`
* [ ] 3) Migrate our `setup.py` to an [`pyproject.toml`](https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/) file (see [PEP 621](https://www.python.org/dev/peps/pep-0621/), [PEP 518](https://www.python.org/dev/peps/pep-0518/))
* [x] 4) #2860 (v9.2)
ps: feel free to give feedback and I will add them to this list.
## DevNote
You can (re)read the thread on or-tools integration to conda forge, TLDR: it wasn't as smooth as it should have so let's fix what we can on the or-tools cmake side if possible...
src: https://github.com/conda-forge/staged-recipes/pull/16147
Some preliminary PoC can be done using https://github.com/Mizux/python-native which compile in few dozen of seconds contrary to ortools...
For 0.
could use:
```
import subprocess, sys
from email.parser import BytesHeaderParser
p = subprocess.run([sys.executable, '-m', 'pip', 'show', 'pip', '--files'], stdout=subprocess.PIPE)
h = BytesHeaderParser().parsebytes(p.stdout)
print(h['Version'])
21.3
```
src: https://github.com/conda-forge/staged-recipes/pull/16147#issuecomment-945934282
note: `--files` seems not needed.
For 1.
https://github.com/google/or-tools/blob/86d4c543f717fa8716a9d66c25143660668bf825/ortools/python/setup.py.in#L49 basically replace this or adding a "is external lib" check then do nothing -> which could be done by checking property IMPORTED ? https://cmake.org/cmake/help/latest/prop_tgt/IMPORTED.html
Contributor guide
Assessment
This issue has not been assessed yet.