🌐 AI搜索 & 代理 主页
Skip to content

Commit ea3d47a

Browse files
committed
Merge branch 'master' into weakref-support
2 parents ff35e6d + 707ef36 commit ea3d47a

File tree

91 files changed

+1816
-1001
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+1816
-1001
lines changed

.github/workflows/main.yml

Lines changed: 22 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,9 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
os: [windows, ubuntu, macos]
15-
pyver_minor: [6, 7, 8, 9]
15+
python: ["3.6", "3.7", "3.8", "3.9"]
1616
platform: [x64]
1717
shutdown_mode: [Normal, Soft]
18-
include:
19-
- os: ubuntu
20-
pyver_minor: 6
21-
dll_suffix: m
22-
- os: ubuntu
23-
pyver_minor: 7
24-
dll_suffix: m
25-
26-
- os: macos
27-
dll_prefix: lib
28-
dll_pyver_major: '3.'
29-
dll_suffix: m
30-
- os: ubuntu
31-
dll_prefix: lib
32-
dll_pyver_major: '3.'
33-
- os: windows
34-
dll_pyver_major: '3'
35-
36-
- os: ubuntu
37-
dll_ext: .so
38-
- os: windows
39-
dll_ext: .dll
40-
- os: macos
41-
dll_ext: .dylib
4218

4319
env:
4420
PYTHONNET_SHUTDOWN_MODE: ${{ matrix.SHUTDOWN_MODE }}
@@ -56,10 +32,10 @@ jobs:
5632
- name: Setup .NET
5733
uses: actions/setup-dotnet@v1
5834

59-
- name: Set up Python 3.${{ matrix.pyver_minor }}
35+
- name: Set up Python ${{ matrix.python }}
6036
uses: actions/setup-python@v2
6137
with:
62-
python-version: 3.${{ matrix.pyver_minor }}
38+
python-version: ${{ matrix.python }}
6339
architecture: ${{ matrix.platform }}
6440

6541
- name: Install dependencies
@@ -68,31 +44,34 @@ jobs:
6844
6945
- name: Build and Install
7046
run: |
71-
python setup.py configure
7247
pip install -v .
7348
74-
# TODO this should be gone once clr module sets PythonDLL or preloads it
75-
- name: Python Tests
76-
run: pytest
77-
if: ${{ matrix.os != 'macos' }}
78-
env:
79-
PYTHONNET_PYDLL: ${{ matrix.DLL_PREFIX }}python${{matrix.DLL_PYVER_MAJOR}}${{matrix.PYVER_MINOR}}${{matrix.DLL_SUFFIX}}${{matrix.DLL_EXT}}
49+
- name: Set Python DLL path (non Windows)
50+
if: ${{ matrix.os != 'windows' }}
51+
run: |
52+
python -m pythonnet.find_libpython --export >> $GITHUB_ENV
8053
81-
- name: Python Tests
82-
run: pytest
83-
if: ${{ matrix.os == 'macos' }}
54+
- name: Set Python DLL path (Windows)
55+
if: ${{ matrix.os == 'windows' }}
56+
run: |
57+
python -m pythonnet.find_libpython --export | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
58+
59+
- name: Python Tests (Mono)
60+
if: ${{ matrix.os != 'windows' }}
61+
run: pytest --runtime mono
62+
63+
- name: Python Tests (.NET Core)
64+
run: pytest --runtime netcore
65+
66+
- name: Python Tests (.NET Framework)
67+
if: ${{ matrix.os == 'windows' }}
68+
run: pytest --runtime netfx
8469

8570
- name: Embedding tests
8671
run: dotnet test --runtime any-${{ matrix.platform }} src/embed_tests/
87-
if: ${{ matrix.os != 'macos' }} # Not working right now, doesn't find libpython
88-
env:
89-
PYTHONNET_PYDLL: ${{ matrix.DLL_PREFIX }}python${{matrix.DLL_PYVER_MAJOR}}${{matrix.PYVER_MINOR}}${{matrix.DLL_SUFFIX}}${{matrix.DLL_EXT}}
9072

9173
- name: Python tests run from .NET
9274
run: dotnet test --runtime any-${{ matrix.platform }} src/python_tests_runner/
93-
if: ${{ matrix.os == 'windows' }} # Not working for others right now
94-
env:
95-
PYTHONNET_PYDLL: ${{ matrix.DLL_PREFIX }}python${{matrix.DLL_PYVER_MAJOR}}${{matrix.PYVER_MINOR}}${{matrix.DLL_SUFFIX}}${{matrix.DLL_EXT}}
9675

9776
# TODO: Run perf tests
9877
# TODO: Run mono tests on Windows?
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: NuGet Preview Release
2+
3+
on:
4+
schedule:
5+
- cron: "5 4 3 */1 *" # once a month, at 4:05 on 3rd
6+
workflow_dispatch:
7+
8+
jobs:
9+
release:
10+
name: Release Preview
11+
runs-on: ubuntu-latest
12+
environment: NuGet
13+
timeout-minutes: 10
14+
15+
env:
16+
PYTHONNET_SHUTDOWN_MODE: Normal
17+
18+
steps:
19+
- name: Get Date
20+
run: |
21+
echo "DATE_VER=$(date "+%Y-%m-%d")" >> $GITHUB_ENV
22+
23+
- name: Checkout code
24+
uses: actions/checkout@v2
25+
26+
- name: Setup .NET
27+
uses: actions/setup-dotnet@v1
28+
29+
- name: Set up Python 3.8
30+
uses: actions/setup-python@v2
31+
with:
32+
python-version: 3.8
33+
architecture: x64
34+
35+
- name: Install dependencies
36+
run: |
37+
pip install --upgrade -r requirements.txt
38+
39+
- name: Build and Install
40+
run: |
41+
pip install -v .
42+
43+
- name: Python Tests
44+
run: pytest
45+
env:
46+
PYTHONNET_PYDLL: libpython3.8.so
47+
48+
- name: Embedding tests
49+
run: dotnet test --runtime any-ubuntu src/embed_tests/
50+
env:
51+
PYTHONNET_PYDLL: libpython3.8.so
52+
53+
- name: Pack
54+
run: dotnet pack --configuration Release --version-suffix preview${{env.DATE_VER}} --output "Release-Preview"
55+
56+
- name: Publish NuGet
57+
run: dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_MONTHLY }} Release-Preview/*.nupkg
58+
59+
# TODO: Run perf tests
60+
# TODO: Run mono tests on Windows?

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
/src/runtime/interopNative.cs
22

3-
# Configuration data
4-
configured.props
5-
63
# General binaries and Build results
74
*.dll
85
*.exe

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ when .NET expects an integer [#1342][i1342]
3636
- BREAKING: Methods with `ref` or `out` parameters and void return type return a tuple of only the `ref` and `out` parameters.
3737
- BREAKING: to call Python from .NET `Runtime.PythonDLL` property must be set to Python DLL name
3838
or the DLL must be loaded in advance. This must be done before calling any other Python.NET functions.
39+
- Sign Runtime DLL with a strong name
40+
- Implement loading through `clr_loader` instead of the included `ClrModule`, enables
41+
support for .NET Core
3942

4043
### Fixed
4144

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<AssemblyCompany>pythonnet</AssemblyCompany>
66
<AssemblyProduct>Python.NET</AssemblyProduct>
77
<LangVersion>7.3</LangVersion>
8+
<IsPackable>false</IsPackable>
89
</PropertyGroup>
910
<ItemGroup>
1011
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
@@ -17,5 +18,4 @@
1718
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1819
</PackageReference>
1920
</ItemGroup>
20-
<Import Project="$(MSBuildThisFileDirectory)configured.props" Condition="Exists('$(MSBuildThisFileDirectory)configured.props')" />
2121
</Project>

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-2020 the contributors of the Python.NET project
3+
Copyright (c) 2006-2021 the contributors of the Python.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"),

appveyor.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ environment:
3030
init:
3131
# Update Environment Variables based on matrix/platform
3232
- set PY_VER=%PYTHON_VERSION:.=%
33-
- set PYTHONNET_PYDLL=python%PY_VER%.dll
3433
- set PYTHON=C:\PYTHON%PY_VER%
3534
- if %PLATFORM%==x64 (set PYTHON=%PYTHON%-x64)
35+
- set PYTHONNET_PYDLL=%PYTHON%\python%PY_VER%.dll
3636

3737
# Put desired Python version first in PATH
3838
- set PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
@@ -42,7 +42,6 @@ install:
4242
- pip install --upgrade -r requirements.txt --quiet
4343

4444
build_script:
45-
- python setup.py configure
4645
# Create clean `sdist`. Only used for releases
4746
- python setup.py --quiet sdist
4847
- python setup.py bdist_wheel

clr.py

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,5 @@
22
Legacy Python.NET loader for backwards compatibility
33
"""
44

5-
def _get_netfx_path():
6-
import os, sys
7-
8-
if sys.maxsize > 2 ** 32:
9-
arch = "amd64"
10-
else:
11-
arch = "x86"
12-
13-
return os.path.join(os.path.dirname(__file__), "pythonnet", "netfx", arch, "clr.pyd")
14-
15-
16-
def _get_mono_path():
17-
import os, glob
18-
19-
paths = glob.glob(os.path.join(os.path.dirname(__file__), "pythonnet", "mono", "clr.*so"))
20-
return paths[0]
21-
22-
23-
def _load_clr():
24-
import sys
25-
from importlib import util
26-
27-
if sys.platform == "win32":
28-
path = _get_netfx_path()
29-
else:
30-
path = _get_mono_path()
31-
32-
del sys.modules[__name__]
33-
34-
spec = util.spec_from_file_location("clr", path)
35-
clr = util.module_from_spec(spec)
36-
spec.loader.exec_module(clr)
37-
38-
sys.modules[__name__] = clr
39-
40-
41-
_load_clr()
5+
from pythonnet import load
6+
load()

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
[build-system]
22
requires = ["setuptools>=42", "wheel", "pycparser"]
33
build-backend = "setuptools.build_meta"
4+
5+
[tool.pytest.ini_options]
6+
xfail_strict = true
7+
testpaths = [
8+
"tests",
9+
]

pythonnet.sln

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Runtime", "src\runti
66
EndProject
77
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Console", "src\console\Console.csproj", "{E6B01706-00BA-4144-9029-186AC42FBE9A}"
88
EndProject
9-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "clrmodule", "src\clrmodule\clrmodule.csproj", "{F9F5FA13-BC52-4C0B-BC1C-FE3C0B8FCCDD}"
10-
EndProject
119
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.EmbeddingTest", "src\embed_tests\Python.EmbeddingTest.csproj", "{819E089B-4770-400E-93C6-4F7A35F0EA12}"
1210
EndProject
1311
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Test", "src\testing\Python.Test.csproj", "{14EF9518-5BB7-4F83-8686-015BD2CC788E}"
@@ -21,6 +19,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Repo", "Repo", "{441A0123-F
2119
.editorconfig = .editorconfig
2220
.gitignore = .gitignore
2321
CHANGELOG.md = CHANGELOG.md
22+
LICENSE = LICENSE
2423
README.rst = README.rst
2524
EndProjectSection
2625
EndProject
@@ -30,6 +29,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CI", "CI", "{D301657F-5EAF-
3029
ci\appveyor_build_recipe.ps1 = ci\appveyor_build_recipe.ps1
3130
ci\appveyor_run_tests.ps1 = ci\appveyor_run_tests.ps1
3231
.github\workflows\main.yml = .github\workflows\main.yml
32+
.github\workflows\nuget-preview.yml = .github\workflows\nuget-preview.yml
3333
EndProjectSection
3434
EndProject
3535
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{57F5D701-F265-4736-A5A2-07249E7A4DA3}"
@@ -51,6 +51,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{BC426F42
5151
EndProject
5252
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.PythonTestsRunner", "src\python_tests_runner\Python.PythonTestsRunner.csproj", "{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}"
5353
EndProject
54+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{142A6752-C2C2-4F95-B982-193418001B65}"
55+
ProjectSection(SolutionItems) = preProject
56+
Directory.Build.props = Directory.Build.props
57+
EndProjectSection
58+
EndProject
5459
Global
5560
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5661
Debug|Any CPU = Debug|Any CPU
@@ -145,18 +150,6 @@ Global
145150
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Release|x64.Build.0 = Release|Any CPU
146151
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Release|x86.ActiveCfg = Release|Any CPU
147152
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Release|x86.Build.0 = Release|Any CPU
148-
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
149-
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Debug|Any CPU.Build.0 = Debug|Any CPU
150-
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Debug|x64.ActiveCfg = Debug|Any CPU
151-
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Debug|x64.Build.0 = Debug|Any CPU
152-
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Debug|x86.ActiveCfg = Debug|Any CPU
153-
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Debug|x86.Build.0 = Debug|Any CPU
154-
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Release|Any CPU.ActiveCfg = Release|Any CPU
155-
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Release|Any CPU.Build.0 = Release|Any CPU
156-
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Release|x64.ActiveCfg = Release|Any CPU
157-
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Release|x64.Build.0 = Release|Any CPU
158-
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Release|x86.ActiveCfg = Release|Any CPU
159-
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Release|x86.Build.0 = Release|Any CPU
160153
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
161154
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Debug|Any CPU.Build.0 = Debug|Any CPU
162155
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Debug|x64.ActiveCfg = Debug|Any CPU

0 commit comments

Comments
 (0)