Skip to content
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

cmake: Rework python.cmake #2858

Open
3 of 6 tasks
Mizux opened this issue Oct 19, 2021 · 1 comment
Open
3 of 6 tasks

cmake: Rework python.cmake #2858

Mizux opened this issue Oct 19, 2021 · 1 comment
Assignees
Labels
Build: CMake CMake based build issue Feature Request Missing Feature/Wrapper Lang: Python Python wrapper issue
Milestone

Comments

@Mizux
Copy link
Collaborator

Mizux commented Oct 19, 2021

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

@Mizux Mizux added Feature Request Missing Feature/Wrapper Lang: Python Python wrapper issue Build: CMake CMake based build issue labels Oct 19, 2021
@Mizux Mizux added this to the v9.3 milestone Oct 19, 2021
@Mizux Mizux self-assigned this Oct 19, 2021
@Mizux Mizux added this to To do in Feature Requests via automation Oct 19, 2021
@BastianZim
Copy link

BastianZim commented Oct 19, 2021

(Conda-forge maintainer here)

For 0.

Yes it's not needed. I had seen it suggested as a way to get it formatted but it seems like it's the same. Pypa is also currently working on a --json flag.
ref: pypa/pip#5261

For 1.:

I'm currently just replacing the installation part with

message(FATAL_ERROR "Can't find python module \"${MODULE_NAME}\", please install it using your system package manager.")

Installation:

message(WARNING "Can't find python module \"${MODULE_NAME}\", install it using pip...")
execute_process(
COMMAND ${Python3_EXECUTABLE} -m pip install --user ${MODULE_NAME}
OUTPUT_STRIP_TRAILING_WHITESPACE
)

As a quick fix.

For 3)

I like poetry as a build backend: https://github.com/python-poetry/poetry-core

@Mizux Mizux moved this from To do to In progress in Feature Requests Oct 20, 2021
@Mizux Mizux modified the milestones: v9.3, v9.2 Nov 4, 2021
Mizux referenced this issue Nov 4, 2021
* Don't look for __version__ when unavailable
@Mizux Mizux modified the milestones: v9.2, v9.3 Nov 22, 2021
@Mizux Mizux modified the milestones: v9.3, v10.0 Feb 17, 2022
@Mizux Mizux moved this from In progress to To do in Feature Requests Feb 17, 2022
@Mizux Mizux moved this from To do to stall in Feature Requests Jun 10, 2022
@Mizux Mizux moved this from stall to To do in Feature Requests Oct 20, 2022
@Mizux Mizux modified the milestones: v10.0, Backlog Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build: CMake CMake based build issue Feature Request Missing Feature/Wrapper Lang: Python Python wrapper issue
2 participants