ABI.Initialize gives a helpful message when the TypeOffset interop class is not configured correctly by tminka · Pull Request #1340 · pythonnet/pythonnet · GitHub
Skip to content

ABI.Initialize gives a helpful message when the TypeOffset interop class is not configured correctly#1340

Merged
lostmsu merged 7 commits intopythonnet:masterfrom
tminka:initialize
Jan 4, 2021
Merged

ABI.Initialize gives a helpful message when the TypeOffset interop class is not configured correctly#1340
lostmsu merged 7 commits intopythonnet:masterfrom
tminka:initialize

Conversation

@tminka
Copy link
Copy Markdown
Contributor

@tminka tminka commented Dec 30, 2020

What does this implement/fix? Explain your changes.

When changing Python versions, it is easy to put Python.NET into a misconfigured state. This PR provides a helpful error message in that case.

Does this close any currently open issues?

No

Any other comments?

This change can be tested by manually editing configured.props to have an incorrect PythonInteropFile

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Add yourself to AUTHORS
  • Updated the CHANGELOG

@lostmsu
Copy link
Copy Markdown
Member

lostmsu commented Dec 31, 2020

@filmor
Copy link
Copy Markdown
Member

filmor commented Dec 31, 2020

@lostmsu Well, that one doesn't do much, I don't see what that would bring. Adding version and ABI flags to the interop classes and comparing against those should be more stable.

@tminka The advice should be to run python setup.py configure.

Python.Runtime.csproj includes all interopXX.cs files
@tminka
Copy link
Copy Markdown
Contributor Author

tminka commented Dec 31, 2020

@filmor I have changed the advice as directed.

@lostmsu Your suggestion works. If Python.Runtime.csproj includes all interopXX.cs files, then an incorrect value of PythonInteropFile does not break the build. This seems like a useful robustness to have, so I added it.

Comment thread src/runtime/Python.Runtime.csproj
@tminka
Copy link
Copy Markdown
Contributor Author

tminka commented Jan 1, 2021

The test failures imply that NativeTypeOffset is in fact not generated on some non-Windows platforms. I'm not sure what to do about that.

@lostmsu
Copy link
Copy Markdown
Member

lostmsu commented Jan 1, 2021

It seems to be a temporary fluke, the test failures are identical between this and your other PR, which are unrelated.

@lostmsu
Copy link
Copy Markdown
Member

lostmsu commented Jan 1, 2021

Oh @tminka , you meant this failure: f59e5d0

I think this is because you must keep

  <ItemGroup Condition=" '$(PythonInteropFile)' != '' ">	
    <Compile Include="$(PythonInteropFile)" />	
  </ItemGroup>

I believe the file is generated outside src\runtime folder, and thus is not included into default compile items.

@tminka
Copy link
Copy Markdown
Contributor Author

tminka commented Jan 3, 2021

@lostmsu lostmsu merged commit cac82a6 into pythonnet:master Jan 4, 2021
@tminka tminka deleted the initialize branch January 4, 2021 23:09
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.

3 participants