Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfda9499

Browse files
authored
Merge branch 'master' into PR/PyArgConverter
2 parents7f8c6c3 +817fe61 commitfda9499

26 files changed

+1137
-351
lines changed

‎AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
- ([@civilx64](https://github.com/civilx64))
5656
- ([@GSPP](https://github.com/GSPP))
5757
- ([@omnicognate](https://github.com/omnicognate))
58+
- ([@OneBlue](https://github.com/OneBlue))
5859
- ([@rico-chet](https://github.com/rico-chet))
5960
- ([@rmadsen-ks](https://github.com/rmadsen-ks))
6061
- ([@stonebig](https://github.com/stonebig))

‎CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
2121
- Catches exceptions thrown in C# iterators (yield returns) and rethrows them in python ([#475][i475])([#693][p693])
2222
- Implemented GetDynamicMemberNames() for PyObject to allow dynamic object members to be visible in the debugger ([#443][i443])([#690][p690])
2323
- Incorporated reference-style links to issues and pull requests in the CHANGELOG ([#608][i608])
24+
- Added PyObject finalizer support, Python objects referred by C# can be auto collect now ([#692][p692]).
2425
- Added detailed comments about aproaches and dangers to handle multi-app-domains ([#625][p625])
2526
- Python 3.7 support, builds and testing added. Defaults changed from Python 3.6 to 3.7 ([#698][p698])
2627

2728
###Changed
2829

30+
- PythonException included C# call stack
2931
- Reattach python exception traceback information (#545)
3032
- PythonEngine.Intialize will now call`Py_InitializeEx` with a default value of 0, so signals will not be configured by default on embedding. This is different from the previous behaviour, where`Py_Initialize` was called instead, which sets initSigs to 1. ([#449][i449])
3133
- Refactored MethodBinder.Bind in preparation to make it extensible (#829)
3234
- Added`IPyArgumentConverter` interface and`PyArgConverter` attribute, that control custom argument marshaling from Python to .NET (#835)
35+
- Look for installed Windows 10 sdk's during installation instead of relying on specific versions.
3336

3437
###Fixed
3538

‎LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2006-2017 the contributors of the "Python for .NET" project
3+
Copyright (c) 2006-2019 the contributors of the "Python for .NET" project
44

55
Permission is hereby granted, free of charge, to any person obtaining a
66
copy of this software and associated documentation files (the "Software"),

‎README.md

Lines changed: 0 additions & 112 deletions
This file was deleted.

‎README.rst

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
pythonnet - Python for .NET
2+
===========================
3+
4+
|Join the chat at https://gitter.im/pythonnet/pythonnet|
5+
6+
|appveyor shield| |travis shield| |codecov shield|
7+
8+
|license shield| |pypi package version| |python supported shield|
9+
|stackexchange shield|
10+
11+
Python for .NET is a package that gives Python programmers nearly
12+
seamless integration with the .NET Common Language Runtime (CLR) and
13+
provides a powerful application scripting tool for .NET developers. It
14+
allows Python code to interact with the CLR, and may also be used to
15+
embed Python into a .NET application.
16+
17+
Calling .NET code from Python
18+
-----------------------------
19+
20+
Python for .NET allows CLR namespaces to be treated essentially as
21+
Python packages.
22+
23+
..code-block::
24+
25+
import clr
26+
from System import String
27+
from System.Collections import *
28+
29+
To load an assembly, use the ``AddReference`` function in the ``clr``
30+
module:
31+
32+
..code-block::
33+
34+
import clr
35+
clr.AddReference("System.Windows.Forms")
36+
from System.Windows.Forms import Form
37+
38+
Embedding Python in .NET
39+
------------------------
40+
41+
- All calls to python should be inside a
42+
``using (Py.GIL()) {/* Your code here */}`` block.
43+
- Import python modules using ``dynamic mod = Py.Import("mod")``, then
44+
you can call functions as normal, eg ``mod.func(args)``.
45+
- Use ``mod.func(args, Py.kw("keywordargname", keywordargvalue))`` or
46+
``mod.func(args, keywordargname: keywordargvalue)`` to apply keyword
47+
arguments.
48+
- All python objects should be declared as ``dynamic`` type.
49+
- Mathematical operations involving python and literal/managed types
50+
must have the python object first, eg. ``np.pi * 2`` works,
51+
``2 * np.pi`` doesn't.
52+
53+
Example
54+
~~~~~~~
55+
56+
..code-block::csharp
57+
58+
staticvoidMain(string[]args)
59+
{
60+
using (Py.GIL())
61+
{
62+
dynamicnp=Py.Import("numpy");
63+
Console.WriteLine(np.cos(np.pi*2));
64+
65+
dynamicsin=np.sin;
66+
Console.WriteLine(sin(5));
67+
68+
doublec=np.cos(5)+sin(5);
69+
Console.WriteLine(c);
70+
71+
dynamica=np.array(newList<float> {1,2,3 });
72+
Console.WriteLine(a.dtype);
73+
74+
dynamicb=np.array(newList<float> {6,5,4 },dtype:np.int32);
75+
Console.WriteLine(b.dtype);
76+
77+
Console.WriteLine(a*b);
78+
Console.ReadKey();
79+
}
80+
}
81+
82+
Output:
83+
84+
..code::
85+
86+
1.0
87+
-0.958924274663
88+
-0.6752620892
89+
float64
90+
int32
91+
[ 6. 10. 12.]
92+
93+
Information on installation, FAQ, troubleshooting, debugging, and
94+
projects using pythonnet can be found in the Wiki:
95+
96+
https://github.com/pythonnet/pythonnet/wiki
97+
98+
.. |Join the chat at https://gitter.im/pythonnet/pythonnet|image::https://badges.gitter.im/pythonnet/pythonnet.svg
99+
:target:https://gitter.im/pythonnet/pythonnet?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
100+
.. |appveyor shield|image::https://img.shields.io/appveyor/ci/pythonnet/pythonnet/master.svg?label=AppVeyor
101+
:target:https://ci.appveyor.com/project/pythonnet/pythonnet/branch/master
102+
.. |travis shield|image::https://img.shields.io/travis/pythonnet/pythonnet/master.svg?label=Travis
103+
:target:https://travis-ci.org/pythonnet/pythonnet
104+
.. |codecov shield|image::https://img.shields.io/codecov/c/github/pythonnet/pythonnet/master.svg?label=Codecov
105+
:target:https://codecov.io/github/pythonnet/pythonnet
106+
.. |license shield|image::https://img.shields.io/badge/license-MIT-blue.svg?maxAge=3600
107+
:target:./LICENSE
108+
.. |pypi package version|image::https://img.shields.io/pypi/v/pythonnet.svg
109+
:target:https://pypi.python.org/pypi/pythonnet
110+
.. |python supported shield|image::https://img.shields.io/pypi/pyversions/pythonnet.svg
111+
:target:https://pypi.python.org/pypi/pythonnet
112+
.. |stackexchange shield|image::https://img.shields.io/badge/StackOverflow-python.net-blue.svg
113+
:target:http://stackoverflow.com/questions/tagged/python.net

‎conda.recipe/meta.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package:
22
name:pythonnet
3-
version:"2.4.0.dev0"
3+
version:{{ GIT_DESCRIBE_VERSION }}
44

55
build:
66
skip:True# [not win]
7-
number:{{environ.get('GIT_DESCRIBE_NUMBER', 0) }}
7+
number:{{ GIT_DESCRIBE_NUMBER }}
88
{% if environ.get('GIT_DESCRIBE_NUMBER', '0') == '0' %}string: py{{ environ.get('PY_VER').replace('.', '') }}_0
99
{% else %}string: py{{ environ.get('PY_VER').replace('.', '') }}_{{ environ.get('GIT_BUILD_STR', 'GIT_STUB') }}{% endif %}
1010

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp