Thanks to visit codestin.com
Credit goes to github.com

Skip to content

cmake: Rework python.cmake #2858

@Mizux

Description

@Mizux

After few discussions with conda-forge maintainer few things to improve:

  • 0) Fix check of __version__ in CheckPythonModule (not available for absl, mypy_protobuf etc...) (v9.2)
  • 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 file (see PEP 621, PEP 518)
  • 4) ortools.__version__ no longer exists for Python #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: conda-forge/staged-recipes#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: conda-forge/staged-recipes#16147 (comment)
note: --files seems not needed.

For 1.

'@PROJECT_NAME@':[$<$<STREQUAL:$<TARGET_PROPERTY:@PYTHON_PROJECT@,TYPE>,SHARED_LIBRARY>:'.libs/*', '../$<TARGET_SONAME_FILE_NAME:@PYTHON_PROJECT@>'>],
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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions