conda-forge / cmake-feedstock

A conda-smithy repository for cmake.
BSD 3-Clause "New" or "Revised" License
4 stars 43 forks source link

On windows FindPython3.cmake will find global installs #196

Open tony-p opened 1 year ago

tony-p commented 1 year ago

Solution to issue cannot be found in the documentation.

Issue

On windows if using python 3.10. in the env and have python 3.11. installed globally, no matter what I do (disabling managed aliases etc) FindPython3.cmake will find/prefer the global Python 3.11 install over the environment installed python 3.10 which eventually leads to package version conflicts in builds. The only thing that solves it is removing all global python installs.

Note I am using this within a pixi environment (https://prefix.dev/docs/pixi/overview) However I don't believe this would affect this behaviour

Installed packages

From pixi lock file

- name: cmake
  version: 3.27.4
  manager: conda
  platform: win-64
  dependencies:
    ucrt: '>=10.0.20348.0'
    vc14_runtime: '>=14.29.30139'
    vs2015_runtime: '*'
  url: https://conda.anaconda.org/conda-forge/win-64/cmake-3.27.4-h1537add_0.conda
  hash:
    md5: 4344adf2b563f4ffb36390ca26f0de18
    sha256: 813503025152a11f648ddc50a4716f5b6ddd3ea02a746ada6cc8a3f2cbaab2b6

- name: python
  version: 3.10.12
  manager: conda
  platform: win-64
  dependencies:
    bzip2: '>=1.0.8,<2.0a0'
    libffi: '>=3.4,<4.0a0'
    libsqlite: '>=3.42.0,<4.0a0'
    libzlib: '>=1.2.13,<1.3.0a0'
    openssl: '>=3.1.1,<4.0a0'
    tk: '>=8.6.12,<8.7.0a0'
    tzdata: '*'
    vc: '>=14.1,<15'
    vc14_runtime: '>=14.16.27033'
    xz: '>=5.2.6,<6.0a0'
  url: https://conda.anaconda.org/conda-forge/win-64/python-3.10.12-h4de0772_0_cpython.conda
  hash:
    md5: 14273454ca348a123ce09ab9d39c1a6e
    sha256: 02ee08f3f27488b76155535e43fc99ef491ccc21f28001c3cde9b134e8aa0b94

Environment info

$ pixi info
pixi 0.3.0

Platform            : win-64
Virtual packages    : __win=0=0
                    : __cuda=12.0=0
                    : __archspec=1=x86_64
Cache dir           : C:\Users\me\AppData\Local\rattler/cache
Auth storage        : C:\Users\me\.rattler

Project
------------

Manifest file       : C:\...\pixi.toml
Dependency count    : 16
Last updated        : 18-09-2023 11:21:36
Target platforms    : win-64
                    : linux-64
Tasks               : linter
                    : test
                    : build
                    : clean
                    : format
Tobias-Fischer commented 11 months ago

We've had reports of this issue on both Linux and MacOS as well https://github.com/RoboStack/robostack.github.io/issues/27 (Linux; particular distributions only!) https://github.com/RoboStack/robostack.github.io/issues/35 MacOS (osx-arm64)

/cc @traversaro

traversaro commented 11 months ago

On windows if using python 3.10. in the env and have python 3.11. installed globally, no matter what I do (disabling managed aliases etc) FindPython3.cmake will find/prefer the global Python 3.11 install over the environment installed python 3.10 which eventually leads to package version conflicts in builds.

The global Python3 is found even if you specify the Python3_EXECUTABLE location via -DPython3_EXECUTABLE=? Probably it may be worth to also try to set Python3_FIND_STRATEGY to LOCATION, see https://cmake.org/cmake/help/latest/module/FindPython3.html#hints . If you control the project you are building, making sure that policy CMP0094 is set to NEW, could also help.