-
Notifications
You must be signed in to change notification settings - Fork 747
Initial coreclr and build tooling #612
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
Conversation
Can load .NET Core into python Pass clr PyObject back to Python
@denfromufa @djoyce82 @dmitriyse |
src/coreclr/coreutils.c
Outdated
|
||
// Walk the directory for each extension separately so that we first get files with .ni.dll extension, | ||
// then files with .dll extension, etc. | ||
for (size_t extIndex = 0; extIndex < sizeof(tpaExtensions) / sizeof(tpaExtensions[0]); extIndex++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Declare the variable outside the loop to avoid a compiler warning:
size_t extIndex;
for (extIndex = 0; extIndex < sizeof(tpaExtensions) / sizeof(tpaExtensions[0]); extIndex++)
src/coreclr/pynetinit.c
Outdated
const char *slash = "/"; | ||
int found = 0; | ||
|
||
for (int ii = 0; ii < PyList_Size(syspath); ++ii) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Declare the variable outside the loop to avoid a compiler warning:
int ii;
for (ii = 0; ii < PyList_Size(syspath); ++ii)
@djoyce82 Are you able to get it all working correctly in Linux? |
@Cronan pythonnet works on Linux for my use case, which admittedly is a subset of the functionality provided by the library (e.g. no delegates/events), though it is a reasonable sized project with non-trivial dependencies. I suspect that the test failures are the same as the issues tracked in #590, which may or may not be related to https://github.com/dotnet/corefx/issues/24229 (I encountered this issue when loading my project via pythonnet). It seems that a lot of this tooling is still in a state of flux and hopefully things will improve with .NET Core 2.1. Alternatively, some of the APIs used by pythonnet may have changed or may just be missing in .NET Core. As it stands, this pull request only resolves the issue of hosting the .NET Core CLR within the python process, but doesn't fully address all of the compatibility issues between .NET Framework and .NET Core. |
@Cronan @denfromufa I am able to get a bit further (past the System.Reflection.Emit.TypeBuilder test failures) by having Python.Runtime.dll target netcoreapp2.0 instead of netstandard2.0:
Though I don't really understand why this causes the dependencies to be resolved differently...
|
Probably I can figure out why it behaves so. I spent too much time on netcoreapp2.0 vs netstandard2.0 differencies. I will try at this weekend. |
@denfromufa @dmitriyse @djoyce82 Some progressThere are types in I'm able to replicate what @djoyce82 is seeing, where the delegate tests all work correctly now, by doing the following:
elif DEVTOOLS == "dotnet":
_xbuild = 'dotnet msbuild'
_config = "{0}Mono".format(CONFIG)
_solution_file = 'pythonnet.15.sln'
_custom_define_constants = True,
_target_framework = 'netcoreapp2.0' if _target_framework:
cmd.append('/p:TargetFramework="{}"'.format(_target_framework)) Once this was all done, I was able to build and run the tests, with all the delegate tests succeeding. The first hard failure was in test_enum.py, which I'm still trying to work out. |
Changing NetStandard 2.0 to NetCoreApp 2.0 in Python.Runtime.15.csproj is a very wrong solution. For example I have solution with graph of 100+ NetStandard 2.0 assemblies. |
So we needs to solve this problem somehow staying Python.Runtime.dll with netstandard2.0 |
I faced with this problem on my commercial project already. Other developers would not allow me to change project type in whole solution. |
Also all python tests should be passed when I run them from "dotnet nPython.dll" through pytest.main() command. |
@dmitriyse Also, I understand what you mean about netstandard2.0, but the build currently seems very messy to me, especially if netstandard2.0 is the goal:
Also, as I pointed out, if you actually do a netstandard2.0 build across the board, TypeBuilder.CreateType won't actually compile, as it's not in the standard ... |
@dmitriyse @denfromufa I think this proposed PR is a great piece of work, but I agree not ready for merge. I think the actual code on adding the coreclr C api shouldn't be lost. |
@dmitriyse @Cronan this PR should be merged as soon as it has been shown to embed .net core in pythonnet, at least on one platform - Linux or Windows. All other failures can be addressed in later PRs, especially with regards to .netcoreapp vs .netstandard 2.0. let me know what you think. I plan to test this PR this week. |
I meant all other failures in .net core, all tests should still be passing in CI. |
Give me a chance to fight with netcoreapp 2.0 and netstandard 2.0 differenceies this evening. If I would fail, than it's ok merge this PR even in master. (But personally I prefer ".Net standard 2.0 brainstorm promising branch" for this changes as they are also too damaging). |
@dmitriyse What I didn't appreciate before this week is that netstandard2.0 is a subset - netcoreapp2.0 actually supports more methods/overloads and even whole types than is in netstandard2.0 |
Codecov Report
@@ Coverage Diff @@
## master #612 +/- ##
==========================================
- Coverage 77% 76.93% -0.07%
==========================================
Files 64 64
Lines 5909 5940 +31
Branches 974 976 +2
==========================================
+ Hits 4550 4570 +20
- Misses 1032 1040 +8
- Partials 327 330 +3
Continue to review full report at Codecov.
|
@Cronan @dmitriyse here is .netstandard repository, doesn't look like TypeBuilder is going to be extended soon. so we have to switch to .netcoreapp. |
Ok, we can merge it. But we should keep in mind that with the .NetCoreApp
we will have "Show stopper issue" for most of projects.
2018-02-10 10:31 GMT+04:00 Denis Akhiyarov <notifications@github.com>:
… @Cronan <https://github.com/cronan> @dmitriyse
<https://github.com/dmitriyse> here is .netstandard repository, doesn't
look like TypeBuilder is going to be extended soon. so we have to switch to
.netcoreapp.
https://github.com/dotnet/standard
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#612 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJ2BJ4uPPLuztRwkyT6zteGWJORI88wRks5tTTe-gaJpZM4R0ZX3>
.
|
I have bad news about .NetCoreApp 2.0 and .NetStandard 2.0. In typical modern solution, reusable class libraries should targets .NetStandard2.0, but terminal points (executable projects, UT projects, Web App projects, etc.) should targets to multiple runtimes: If we want to use in .NetStandard 2.0 library some special method from some special runtime (in our case .NetCoreApp 2.0.0+), than we have two options:
Of cource we should pick the second approach.
|
That all sounds good. Over the weekend I was also thinking of implementing assembly binding redirect - did anyone ever have a go at this, or any ideas?
… On 11 Feb 2018, at 01:12, dmitriyse ***@***.***> wrote:
I have bad news about .NetCoreApp 2.0 and .NetStandard 2.0.
The idea of .NetStandard 2.0 that is API intersection between multiple .Net CLR implementation (.NetCore 2.0 , .Net Framework 4.6+ , hypotetic WinRT.WebAssembly CLR 1.0)
.NetStandard 2.0 will disallow of direct usage (in compile time) of some API, even them will be available in a particular platform.
.NetCoreApp 2.0.X is a version of CLR runtime, we have a net462( and in theory we should have mono548 for example).
If we want to use in .NetStandard 2.0 library some special method from some special runtime (in our case .NetCoreApp 2.0.0+), than we have two options:
Split Python.Runtime.dll into two libraries:
a) Python.Runtime.dll (NetStandard 2.0) and declare extension points
b) Python.Runtime.CoreApp.dll that will polifill extension points exactly for .NetCoreApp 2.0
this is an idealistic approach, with many backward compatibility problems.
Search required API through reflection at runtime, make API delegates and call them.
(or fail fast with exception NotSupported("You runtime does not provides required API set."))
Of cource we should pick the second approach.
This trick should not take much time.
Searching required methods and obtaining MethodInfo(s);
Creating delegates through MethodInfo.CreateDelegate (call to this delegetes have near the same speed as compiled call to API)
Switching missing API calls to saved in vars delegate calls (or to dynamically compiled code with calls to dynamically discoverd API - for super performance critical places) .
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@dmitriyse @djoyce82 @Cronan have you tried this coreclr embedding on windows, so that I don't waste time if this has already been done? As I understand this PR is only addressing Linux .NET Core, but my primary platform is Windows. |
I am trying to test this PR for our use case (calling functionality implemented in .NET Standard 2.0 DLLs from Python 3.x). We currently manage to do this on Linux by using Mono and the master, but are trying to avoid the dependency on Mono going forward. I am running:
I built the wheel using "python3 setup.py bdist_wheel --xplat" as recommended, and then installed pythonnet (pip3 install ...). Only tweak I had to do before being able to build was to copy interop36.cs to interop36m.cs (anyone else experiencing this?). So far so good, the problem I'm running into is that when I call "import clr", the error message is:
Any thoughts, also on interop36m.cs? |
@rlordcardano I'm afraid you cannot just "hack" by renaming interop36.cs file. It has to be generated by installing clang/pycparser and then letting setup.py do its job of generating the correct interop structs to be used in pythonnet via geninterop.py. Another issue is that this PR does not include some fixes from the latest master branch wrt to interop generation, so I just updated this branch. |
@denfromufa thanks, I do have both clang and pycparser installed. Appears I'm running into a similar issue as #609 before. Any suggestions?
|
@rlordcardano this is not the full error traceback - there should be more detailed error. but anyway open a separate issue for it or even better - comment on related issue with the same underlying error if there is one. |
Thanks - I did a |
FYI, this PR and djoyce82#1 from @jgoday allowed me to build against core 2.2 targeting windows server nano. I don't see recent activity here ... is this PR dead? I can pick it up @djoyce82 is no longer moving it forward. |
This is not dead, I'm just currently trying to simplify the build, and an additional highly platform dependent compiled dependency doesn't help with that. I have a working prototype of a Python loader using CFFI and will try to push it as soon as possible. |
I tried the loader from your gist in #857 and it caused a hard crash on windows nano server w/ .net core 2.2 and miniconda. |
It works, but |
@filmor @spinwards I managed to get this working in .NET Core 2.1 / Centos 7 / Python 2.7, with a few minor build tweaks. However, I can't for the life of me get it working in the same environment, but using Python 3.6 - I get a hard segfault immediately. Is there anyone still interested in working through this and getting it merged? |
This one is superseded. |
Can load .NET Core into python
Pass clr PyObject back to Python
What does this implement/fix? Explain your changes.
Allows Python.Runtime to be embedded in python via the .NET Core CLR
...
Does this close any currently open issues?
Partially addresses #96
...
Any other comments?
...
Checklist
Check all those that are applicable and complete.
AUTHORS
CHANGELOG