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

Python Bindings on Windows VS2019+ #122

Merged
merged 3 commits into from
Oct 5, 2022
Merged

Conversation

fponta
Copy link
Contributor

@fponta fponta commented Jun 24, 2022

PR description

This PR facilitates the compilation of oofempy on Windows using VS2019+

PR changes

The changes on the codebase are limited and quite straightforward.

They mostly involve the addition of the export macro for matrix and vector assemblers.

Pybind is bumped to version 2.9.1 which drops support to old Python 2.7 and 3.5.

Note: It should still be possible to use version 2.9.0 as it's the first to fix a compatibility problem with the recent VC toolchains.

How to build oofempy on Windows, VS2019+, Python 3.6+

Prerequisite - Python debug symbols and binaries must NOT be installed.

Note: pybind/pybind11#3403

  1. Open Control Panel -> Programs -> Programs and Features
  2. Look for your Python 3 installation. Click it. On the bar above choose "Change"

image

  1. In the setup form, choose "Modify"

image

  1. Press "Next" until you reach the screen with the option to download debug symbols and binaries.
  • If they're unchecked you can cancel the setup.
  • Otherwise, uncheck them both and then press the "Install" button to apply the changes.

image

Setup your CMake

  1. Activate USE_PYBIND_BINDINGS
  2. It is recommended to also activate PYBIND11_FINDPYTHON to let CMake find the Python installation on your system.

Problems with Windows and its case insensitive file names

Context:

  • Oofem repository contains a VERSION file
  • Pybind's include chain reaches a point where the statement #include <version> appears, which includes the version file from the MSVC standard library.
  • MSVC standard library includes are picked up by the compiler through the INCLUDE environment variable.

This is not a problem when the filesystem is case sensitive. Windows, however, is case insensitive and, given how the compiler looks for include directories, it means that VERSION file is preferred over version thus breaking the compilation.

In order to overcome this issue, two solutions are possible:

  1. Temporarily remove/rename the VERSION file in oofem's repository. Remember not to commit this change!
  2. Let the MSVC include paths be the first to be searched by the compiler. Add /I "$(VC_IncludePath)" to the compiler flags in your CMake configuration:

image

@fponta fponta marked this pull request as ready for review June 26, 2022 09:19
@bpatzak bpatzak merged commit f8bc6b2 into oofem:master Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants