Skip to content

Linux compilation ignores Python virtual environments (and may fail to compile as a result) #134

@alexhroom

Description

@alexhroom

In the file CMakeFiles/target.dir/build.make created by CMake I have:

build/timestamp:
	@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --blue --bold --progress-dir=/home/rec93639/Code/RALFit/libRALFit/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Generating build/timestamp"
	/usr/bin/python3 -m pip install .
	/usr/bin/cmake -E touch /home/rec93639/Code/RALFit/libRALFit/build/build/timestamp

As /usr/bin/python3 is specified, this will always use the system-wide Python 3. However, on many Linux distributions (e.g. Ubuntu), the system-wide Python 3 is 'externally managed' meaning that Python packages cannot be installed via pip into the global environment. This means the compilation fails at this step.

The recommended solution for usual Python packages is to create a virtual environment and install the packages into them, but the compilation doesn't support this.

To reproduce: Attempt to build RALFit when the Python environment is externally managed.
Workaround: For now, I can make the package compile if I replace /usr/bin/python3 with [PATH TO MY VENV]/python3, but obviously this means I'm fiddling with files that I'm not supposed to manually edit!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions