Skip to content

clingo: use python from spec#20139

Closed
severinstrobl wants to merge 3 commits intospack:developfrom
severinstrobl:clingo_python_spec
Closed

clingo: use python from spec#20139
severinstrobl wants to merge 3 commits intospack:developfrom
severinstrobl:clingo_python_spec

Conversation

@severinstrobl
Copy link
Copy Markdown
Contributor

Without explicitly providing the path to the Python executable, clingo is prone to pick up the wrong Python package. As a safeguard, the required version is set explicitly based on the spec.

Without explicitly providing the path to the Python executable, clingo
is prone to pick up the wrong Python package. As a safeguard, the
required version is set explicitly based on the spec.
@cosmicexplorer
Copy link
Copy Markdown
Contributor

This should probably go in before #20159, as it is more correct than the corresponding change there:

if '+python' in self.spec:
python = self.spec['python']
python_args = [
'-DCLINGO_REQUIRE_PYTHON=ON',
'-DCLINGO_BUILD_WITH_PYTHON=ON',
'-DCLINGO_BUILD_PY_SHARED=ON',
'-DPYCLINGO_USER_INSTALL=OFF',
'-DPYCLINGO_USE_INSTALL_PREFIX=ON',
'-DCMAKE_CXX_FLAGS=-I{0}'.format(
':'.join(python.headers.directories)),
'-DCLINGO_PYTHON_VERSION:LIST={0};EXACT'.format(
python.version.up_to(2)),
]
else:
python_args = []
args = base_args + python_args

cosmicexplorer added a commit to cosmicexplorer/spack that referenced this pull request Nov 30, 2020
cosmicexplorer added a commit to cosmicexplorer/spack that referenced this pull request Nov 30, 2020
fix python args in clingo package.py

bootstrap clingo in setup-env.sh

avoid setting concretizer: clingo in defaults

fix long lines

merge in spack#20139
cosmicexplorer added a commit to cosmicexplorer/spack that referenced this pull request Nov 30, 2020
fix python args in clingo package.py

bootstrap clingo in setup-env.sh

avoid setting concretizer: clingo in defaults

fix long lines

merge in spack#20139
cosmicexplorer added a commit to cosmicexplorer/spack that referenced this pull request Nov 30, 2020
fix python args in clingo package.py

bootstrap clingo in setup-env.sh

avoid setting concretizer: clingo in defaults

fix long lines

merge in spack#20139
cosmicexplorer added a commit that referenced this pull request Dec 2, 2020
fix python args in clingo package.py

bootstrap clingo in setup-env.sh

avoid setting concretizer: clingo in defaults

fix long lines

merge in #20139
cosmicexplorer added a commit that referenced this pull request Dec 2, 2020
fix python args in clingo package.py

bootstrap clingo in setup-env.sh

avoid setting concretizer: clingo in defaults

fix long lines

merge in #20139

give the interpreter selection a piece of my mind

revert setup-env.sh changes
cosmicexplorer added a commit that referenced this pull request Dec 2, 2020
fix python args in clingo package.py

bootstrap clingo in setup-env.sh

avoid setting concretizer: clingo in defaults

fix long lines

merge in #20139

give the interpreter selection a piece of my mind

revert setup-env.sh changes
cosmicexplorer added a commit that referenced this pull request Dec 3, 2020
fix python args in clingo package.py

bootstrap clingo in setup-env.sh

avoid setting concretizer: clingo in defaults

fix long lines

merge in #20139

give the interpreter selection a piece of my mind

revert setup-env.sh changes

remove extraneous cmake args
cosmicexplorer added a commit that referenced this pull request Dec 3, 2020
fix python args in clingo package.py

bootstrap clingo in setup-env.sh

avoid setting concretizer: clingo in defaults

fix long lines

merge in #20139

give the interpreter selection a piece of my mind

revert setup-env.sh changes

remove extraneous cmake args
cosmicexplorer added a commit that referenced this pull request Dec 3, 2020
fix python args in clingo package.py

bootstrap clingo in setup-env.sh

avoid setting concretizer: clingo in defaults

fix long lines

merge in #20139

give the interpreter selection a piece of my mind

revert setup-env.sh changes

remove extraneous cmake args
cosmicexplorer added a commit that referenced this pull request Dec 5, 2020
update clingo package.py

fix python args in clingo package.py

bootstrap clingo in setup-env.sh

avoid setting concretizer: clingo in defaults

fix long lines

merge in #20139

give the interpreter selection a piece of my mind

revert setup-env.sh changes

remove extraneous cmake args

make clingo build on spack/centos6 via bootstrapping python and gcc
cosmicexplorer added a commit to cosmicexplorer/spack that referenced this pull request Dec 22, 2020
update clingo package.py

fix python args in clingo package.py

bootstrap clingo in setup-env.sh

avoid setting concretizer: clingo in defaults

fix long lines

merge in spack#20139

give the interpreter selection a piece of my mind

revert setup-env.sh changes

remove extraneous cmake args

make clingo build on spack/centos6 via bootstrapping python and gcc
Copy link
Copy Markdown
Member

@adamjstewart adamjstewart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python is not in the spec unless +python, you need an if-statement to check this before adding the flags.

@severinstrobl
Copy link
Copy Markdown
Contributor Author

Good point about the +python, somehow I overlooked that Python is (somewhat?) optional. Unless I'm mistaken, also the original version does not handle this correctly, as all the other CMake arguments regarding the Python bindings do not consider the variant at all. Do you want me to fix this in this merge request as well or should this be addressed separately?

@adamjstewart
Copy link
Copy Markdown
Member

Please fix it in this PR.

@severinstrobl
Copy link
Copy Markdown
Contributor Author

The support for the option CLINGO_PYTHON_VERSION is only available in the master branch, not any of the releases. Is it acceptable for a package to specify CMake options based on the check self.version == Version('master') or is this considered bad practice?

@adamjstewart
Copy link
Copy Markdown
Member

That's fine, as long as it's reasonable to expect that it will be present in future versions. master is a moving target, so we don't want to get too specific about what flags it can and can't accept. If you know what the next feature release number is going to be, you can also say @5.5: or something like that.

Clingo can be configured without Python bindings, yet the CMake
configure step has to explicitly handle this. Additionally, for CMake
versions <= 3.15.0 the path to the Python binary is set explicitly based
on the spec to ensure CMake picks up the correct Python installation.
args += [
'-DCLINGO_BUILD_WITH_PYTHON=ON',
'-DCLINGO_REQUIRE_PYTHON=ON',
'-DCLINGO_BUILD_PY_SHARED=ON',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this flag control? Does it depend on whether '+shared' in spec['python']?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, unfortunately I'm not that familiar with the internals of the library, maybe the original author of this package can shed some light. There seems to be an additional library libpyclingo that uses this flag. As far as I can tell, this library is not used by the Python module, which links against libclingo.so directly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, maybe @tgamblin knows

Explicitly specifying the path to the Python executable to use is
necessary independent of the CMake version to avoid issues with multiple
Python versions.
@severinstrobl
Copy link
Copy Markdown
Contributor Author

With the recent changes to the package when using CMake >= 3.16.0 this is not an issue any more, so I'll close this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants