Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ea48a09

Browse files
authored
Merge branch 'master' into master
2 parents 9bea24d + 1bcbeb5 commit ea48a09

21 files changed

+809
-304
lines changed

.travis.yml

Lines changed: 17 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,17 @@
1-
dist: trusty
1+
dist: xenial
22
sudo: false
33
language: python
4-
5-
matrix:
6-
include:
7-
# --------------------- XPLAT builds ------------------------
8-
- python: 2.7
9-
env: &xplat-env
10-
- BUILD_OPTS=--xplat
11-
- NUNIT_PATH=~/.nuget/packages/nunit.consolerunner/3.*/tools/nunit3-console.exe
12-
addons: &xplat-addons
13-
apt:
14-
sources:
15-
- sourceline: deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main
16-
key_url: https://packages.microsoft.com/keys/microsoft.asc
17-
- sourceline: deb http://download.mono-project.com/repo/ubuntu trusty main
18-
key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF
19-
packages:
20-
- mono-devel
21-
- ca-certificates-mono
22-
- dotnet-hostfxr-2.0.0
23-
- dotnet-runtime-2.0.0
24-
- dotnet-sdk-2.0.0
25-
26-
- python: 3.5
27-
env: *xplat-env
28-
addons: *xplat-addons
29-
30-
- python: 3.6
31-
env: *xplat-env
32-
addons: *xplat-addons
33-
34-
- python: 3.7
35-
env: *xplat-env
36-
dist: xenial
37-
sudo: true
38-
addons: &xplat-addons-xenial
39-
apt:
40-
sources:
41-
- sourceline: deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main
42-
key_url: https://packages.microsoft.com/keys/microsoft.asc
43-
- sourceline: deb https://download.mono-project.com/repo/ubuntu stable-xenial main
44-
key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF
45-
packages:
46-
- mono-devel
47-
- ca-certificates-mono
48-
- dotnet-hostfxr-2.0.0
49-
- dotnet-runtime-2.0.0
50-
- dotnet-sdk-2.0.0
51-
52-
# --------------------- Classic builds ------------------------
53-
- python: 2.7
54-
env: &classic-env
55-
- BUILD_OPTS=
56-
- NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe
57-
58-
- python: 3.5
59-
env: *classic-env
60-
61-
- python: 3.6
62-
env: *classic-env
63-
64-
- python: 3.7
65-
env: *classic-env
66-
dist: xenial
67-
sudo: true
68-
addons:
69-
apt:
70-
sources:
71-
- sourceline: deb http://download.mono-project.com/repo/ubuntu xenial main
72-
key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF
73-
packages:
74-
- mono-devel
75-
- ca-certificates-mono
4+
python:
5+
- 2.7
6+
- 3.5
7+
- 3.6
8+
- 3.7
769

7710
env:
11+
matrix:
12+
- BUILD_OPTS=--xplat NUNIT_PATH="~/.nuget/packages/nunit.consolerunner/3.*/tools/nunit3-console.exe" RUN_TESTS=dotnet EMBED_TESTS_PATH=netcoreapp2.0_publish/
13+
- BUILD_OPTS="" NUNIT_PATH="./packages/NUnit.*/tools/nunit3-console.exe" RUN_TESTS="mono $NUNIT_PATH" EMBED_TESTS_PATH=""
14+
7815
global:
7916
- LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so
8017
- SEGFAULT_SIGNALS=all
@@ -84,11 +21,16 @@ env:
8421
addons:
8522
apt:
8623
sources:
87-
- sourceline: deb http://download.mono-project.com/repo/ubuntu trusty main
24+
- sourceline: deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main
25+
key_url: https://packages.microsoft.com/keys/microsoft.asc
26+
- sourceline: deb http://download.mono-project.com/repo/ubuntu stable-xenial/snapshots/5.20 main
8827
key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF
8928
packages:
9029
- mono-devel
9130
- ca-certificates-mono
31+
- dotnet-hostfxr-2.2
32+
- dotnet-runtime-2.2
33+
- dotnet-sdk-2.2
9234

9335
before_install:
9436
# Set-up dll path for embedded tests
@@ -102,13 +44,9 @@ install:
10244

10345
script:
10446
- python -m pytest
105-
- mono $NUNIT_PATH src/embed_tests/bin/Python.EmbeddingTest.dll
106-
- if [[ $BUILD_OPTS == --xplat ]]; then dotnet src/embed_tests/bin/netcoreapp2.0_publish/Python.EmbeddingTest.dll; fi
47+
- $RUN_TESTS src/embed_tests/bin/$EMBED_TESTS_PATH/Python.EmbeddingTest.dll
10748

10849
after_script:
109-
# Uncomment if need to geninterop, ie. py37 final
110-
# - python tools/geninterop/geninterop.py
111-
11250
# Waiting on mono-coverage, SharpCover or xr.Baboon
11351
- coverage xml -i
11452
- codecov --file coverage.xml --flags setup_linux

AUTHORS.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,23 @@
1919
- Callum Noble ([@callumnoble](https://github.com/callumnoble))
2020
- Christian Heimes ([@tiran](https://github.com/tiran))
2121
- Christoph Gohlke ([@cgohlke](https://github.com/cgohlke))
22+
- Christopher Bremner ([@chrisjbremner](https://github.com/chrisjbremner))
2223
- Christopher Pow ([@christopherpow](https://github.com/christopherpow))
2324
- Daniel Fernandez ([@fdanny](https://github.com/fdanny))
2425
- Daniel Santana ([@dgsantana](https://github.com/dgsantana))
2526
- Dave Hirschfeld ([@dhirschfeld](https://github.com/dhirschfeld))
2627
- David Lassonde ([@lassond](https://github.com/lassond))
2728
- David Lechner ([@dlech](https://github.com/dlech))
2829
- Dmitriy Se ([@dmitriyse](https://github.com/dmitriyse))
30+
- Florian Treurniet ([@ftreurni](https://github.com/ftreurni))
2931
- He-chien Tsai ([@t3476](https://github.com/t3476))
30-
-   Ivan Cronyn ([@cronan](https://github.com/cronan))
32+
- Inna Wiesel ([@inna-w](https://github.com/inna-w))
33+
- Ivan Cronyn ([@cronan](https://github.com/cronan))
3134
- Jan Krivanek ([@jakrivan](https://github.com/jakrivan))
32-
-   Jeff Reback ([@jreback](https://github.com/jreback))
35+
- Jeff Reback ([@jreback](https://github.com/jreback))
3336
- Joe Frayne ([@jfrayne](https://github.com/jfrayne))
37+
- Joe Lidbetter ([@jmlidbetter](https://github.com/jmlidbetter))
38+
- Joe Savage ([@s4v4g3](https://github.com/s4v4g3))
3439
- John Burnett ([@johnburnett](https://github.com/johnburnett))
3540
- John Wilkes ([@jbw3](https://github.com/jbw3))
3641
- Luke Stratman ([@lstratman](https://github.com/lstratman))

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,23 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
99

1010
### Added
1111

12+
- Added automatic NuGet package generation in appveyor and local builds
13+
1214
### Changed
1315

16+
- Added argument types information to "No method matches given arguments" message
17+
- Moved wheel import in setup.py inside of a try/except to prevent pip collection failures
18+
- Removes PyLong_GetMax and PyClass_New when targetting Python3
19+
- Added support for converting python iterators to C# arrays
20+
- Changed usage of obselete function GetDelegateForFunctionPointer(IntPtr, Type) to GetDelegateForFunctionPointer<TDelegate>(IntPtr)
21+
- Added support for kwarg parameters when calling .NET methods from Python
22+
1423
### Fixed
1524

25+
- Fixed runtime that fails loading when using pythonnet in an environment
26+
together with Nuitka
27+
- Fixes bug where delegates get casts (dotnetcore)
28+
1629
## [2.4.0][]
1730

1831
### Added
@@ -55,7 +68,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
5568
- Fixed conversion of 'float' and 'double' values ([#486][i486])
5669
- Fixed 'clrmethod' for python 2 ([#492][i492])
5770
- Fixed double calling of constructor when deriving from .NET class ([#495][i495])
58-
- Fixed `clr.GetClrType` when iterating over `System` members ([#607][p607])
71+
- Fixed `clr.GetClrType` when iterating over `System` members ([#607][p607])
5972
- Fixed `LockRecursionException` when loading assemblies ([#627][i627])
6073
- Fixed errors breaking .NET Remoting on method invoke ([#276][i276])
6174
- Fixed PyObject.GetHashCode ([#676][i676])

README.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pythonnet - Python for .NET
55

66
|appveyor shield| |travis shield| |codecov shield|
77

8-
|license shield| |pypi package version| |python supported shield|
8+
|license shield| |pypi package version| |conda-forge version| |python supported shield|
99
|stackexchange shield|
1010

1111
Python for .NET is a package that gives Python programmers nearly
@@ -111,3 +111,5 @@ https://github.com/pythonnet/pythonnet/wiki
111111
:target: https://pypi.python.org/pypi/pythonnet
112112
.. |stackexchange shield| image:: https://img.shields.io/badge/StackOverflow-python.net-blue.svg
113113
:target: http://stackoverflow.com/questions/tagged/python.net
114+
.. |conda-forge version| image:: https://img.shields.io/conda/vn/conda-forge/pythonnet.svg
115+
:target: https://anaconda.org/conda-forge/pythonnet

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ on_finish:
7272

7373
artifacts:
7474
- path: dist\*
75+
- path: '.\src\runtime\bin\*.nupkg'
7576

7677
notifications:
7778
- provider: Slack

setup.py

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@
1515
import sysconfig
1616
from distutils import spawn
1717
from distutils.command import install, build, build_ext, install_data, install_lib
18-
from wheel import bdist_wheel
1918

2019
from setuptools import Extension, setup
2120

21+
try:
22+
from wheel import bdist_wheel
23+
except ImportError:
24+
bdist_wheel = None
25+
2226
# Allow config/verbosity to be set from cli
2327
# http://stackoverflow.com/a/4792601/5208670
2428
CONFIG = "Release" # Release or Debug
@@ -334,6 +338,7 @@ def build_extension(self, ext):
334338
),
335339
'/p:PythonBuildDir="{}"'.format(os.path.abspath(dest_dir)),
336340
'/p:PythonInteropFile="{}"'.format(os.path.basename(interop_file)),
341+
"/p:PackageId=pythonnet_py{0}{1}_{2}".format(PY_MAJOR, PY_MINOR, ARCH),
337342
"/verbosity:{}".format(VERBOSITY),
338343
]
339344

@@ -608,21 +613,21 @@ def run(self):
608613
_update_xlat_devtools()
609614
return install.install.run(self)
610615

616+
if bdist_wheel:
617+
class BDistWheelPythonnet(bdist_wheel.bdist_wheel):
618+
user_options = bdist_wheel.bdist_wheel.user_options + [("xplat", None, None)]
611619

612-
class BDistWheelPythonnet(bdist_wheel.bdist_wheel):
613-
user_options = bdist_wheel.bdist_wheel.user_options + [("xplat", None, None)]
620+
def initialize_options(self):
621+
bdist_wheel.bdist_wheel.initialize_options(self)
622+
self.xplat = None
614623

615-
def initialize_options(self):
616-
bdist_wheel.bdist_wheel.initialize_options(self)
617-
self.xplat = None
624+
def finalize_options(self):
625+
bdist_wheel.bdist_wheel.finalize_options(self)
618626

619-
def finalize_options(self):
620-
bdist_wheel.bdist_wheel.finalize_options(self)
621-
622-
def run(self):
623-
if self.xplat:
624-
_update_xlat_devtools()
625-
return bdist_wheel.bdist_wheel.run(self)
627+
def run(self):
628+
if self.xplat:
629+
_update_xlat_devtools()
630+
return bdist_wheel.bdist_wheel.run(self)
626631

627632
###############################################################################
628633

@@ -635,6 +640,15 @@ def run(self):
635640
if not os.path.exists(_get_interop_filename()):
636641
setup_requires.append("pycparser")
637642

643+
cmdclass={
644+
"install": InstallPythonnet,
645+
"build_ext": BuildExtPythonnet,
646+
"install_lib": InstallLibPythonnet,
647+
"install_data": InstallDataPythonnet,
648+
}
649+
if bdist_wheel:
650+
cmdclass["bdist_wheel"] = BDistWheelPythonnet
651+
638652
setup(
639653
name="pythonnet",
640654
version="2.4.1-dev",
@@ -647,13 +661,7 @@ def run(self):
647661
long_description=_get_long_description(),
648662
ext_modules=[Extension("clr", sources=list(_get_source_files()))],
649663
data_files=[("{install_platlib}", ["{build_lib}/Python.Runtime.dll"])],
650-
cmdclass={
651-
"install": InstallPythonnet,
652-
"build_ext": BuildExtPythonnet,
653-
"install_lib": InstallLibPythonnet,
654-
"install_data": InstallDataPythonnet,
655-
"bdist_wheel": BDistWheelPythonnet,
656-
},
664+
cmdclass=cmdclass,
657665
classifiers=[
658666
"Development Status :: 5 - Production/Stable",
659667
"Intended Audience :: Developers",

src/embed_tests/TestCallbacks.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
3+
using NUnit.Framework;
4+
using Python.Runtime;
5+
6+
namespace Python.EmbeddingTest {
7+
using Runtime = Python.Runtime.Runtime;
8+
9+
public class TestCallbacks {
10+
[OneTimeSetUp]
11+
public void SetUp() {
12+
PythonEngine.Initialize();
13+
}
14+
15+
[OneTimeTearDown]
16+
public void Dispose() {
17+
PythonEngine.Shutdown();
18+
}
19+
20+
[Test]
21+
public void TestNoOverloadException() {
22+
int passed = 0;
23+
var aFunctionThatCallsIntoPython = new Action<int>(value => passed = value);
24+
using (Py.GIL()) {
25+
dynamic callWith42 = PythonEngine.Eval("lambda f: f([42])");
26+
var error = Assert.Throws<PythonException>(() => callWith42(aFunctionThatCallsIntoPython.ToPython()));
27+
Assert.AreEqual("TypeError", error.PythonTypeName);
28+
string expectedArgTypes = Runtime.IsPython2
29+
? "(<type 'list'>)"
30+
: "(<class 'list'>)";
31+
StringAssert.EndsWith(expectedArgTypes, error.Message);
32+
}
33+
}
34+
}
35+
}

src/embed_tests/TestFinalizer.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void CollectBasicObject()
4545
called = true;
4646
};
4747

48-
Assert.IsFalse(called);
48+
Assert.IsFalse(called, "The event handler was called before it was installed");
4949
Finalizer.Instance.CollectOnce += handler;
5050

5151
WeakReference shortWeak;
@@ -55,13 +55,25 @@ public void CollectBasicObject()
5555
}
5656
FullGCCollect();
5757
// The object has been resurrected
58-
Assert.IsFalse(shortWeak.IsAlive);
59-
Assert.IsTrue(longWeak.IsAlive);
58+
Warn.If(
59+
shortWeak.IsAlive,
60+
"The referenced object is alive although it should have been collected",
61+
shortWeak
62+
);
63+
Assert.IsTrue(
64+
longWeak.IsAlive,
65+
"The reference object is not alive although it should still be",
66+
longWeak
67+
);
6068

6169
{
6270
var garbage = Finalizer.Instance.GetCollectedObjects();
63-
Assert.NotZero(garbage.Count);
64-
Assert.IsTrue(garbage.Any(T => ReferenceEquals(T.Target, longWeak.Target)));
71+
Assert.NotZero(garbage.Count, "There should still be garbage around");
72+
Warn.Unless(
73+
garbage.Any(T => ReferenceEquals(T.Target, longWeak.Target)),
74+
$"The {nameof(longWeak)} reference doesn't show up in the garbage list",
75+
garbage
76+
);
6577
}
6678
try
6779
{
@@ -71,7 +83,7 @@ public void CollectBasicObject()
7183
{
7284
Finalizer.Instance.CollectOnce -= handler;
7385
}
74-
Assert.IsTrue(called);
86+
Assert.IsTrue(called, "The event handler was not called during finalization");
7587
Assert.GreaterOrEqual(objectCount, 1);
7688
}
7789

0 commit comments

Comments
 (0)