Skip to content

Commit f5c76b0

Browse files
authored
Merge pull request #1209 from filmor/sdk-style
Convert projects to SDK style
2 parents f8c27a1 + e3f8c20 commit f5c76b0

Some content is hidden

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

46 files changed

+691
-2874
lines changed

.github/workflows/main.yml

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,23 @@ on: [ pull_request, push ]
55
jobs:
66
build-test:
77
name: Build and Test
8-
runs-on: ubuntu-16.04
8+
runs-on: ubuntu-latest
99

1010
strategy:
11+
fail-fast: false
1112
matrix:
12-
python: [3.6,3.7,3.8,3.9]
13-
shutdown_mode: [Normal,Soft]
14-
toolset: [Mono,.NET]
15-
include:
16-
- toolset: .NET
17-
BUILD_OPTS: --xplat
18-
RUN_TESTS: dotnet
19-
EMBED_TESTS_PATH: netcoreapp3.1_publish/
20-
PERF_TESTS_PATH: net461/
21-
- toolset: Mono
22-
BUILD_OPTS: ""
23-
RUN_TESTS: "mono ./packages/NUnit.*/tools/nunit3-console.exe"
24-
EMBED_TESTS_PATH: ""
25-
PERF_TESTS_PATH: ""
26-
13+
python: [3.6, 3.7, 3.8, 3.9]
14+
shutdown_mode: [Normal, Soft]
15+
2716
env:
28-
BUILD_OPTS: ${{ matrix.BUILD_OPTS }}
29-
RUN_TESTS: ${{ matrix.RUN_TESTS }}
30-
EMBED_TESTS_PATH: ${{ matrix.EMBED_TESTS_PATH }}
31-
PERF_TESTS_PATH: ${{ matrix.PERF_TESTS_PATH }}
3217
PYTHONNET_SHUTDOWN_MODE: ${{ matrix.SHUTDOWN_MODE }}
3318

3419
steps:
3520
- name: Checkout code
3621
uses: actions/checkout@v2
3722

38-
- name: Install Mono
39-
if: ${{ matrix.toolset == 'Mono' }}
40-
run: |
41-
sudo apt update
42-
sudo apt install mono-devel ca-certificates-mono -y
43-
44-
- name: Install .NET
45-
if: ${{ matrix.toolset == '.NET' }}
23+
- name: Setup .NET
4624
uses: actions/setup-dotnet@v1
47-
with:
48-
dotnet-version: 3.1.x
4925

5026
- name: Set up Python ${{ matrix.python }}
5127
uses: actions/setup-python@v2
@@ -54,16 +30,19 @@ jobs:
5430

5531
- name: Install dependencies
5632
run: |
57-
pip install --upgrade setuptools # TEMP - due to setuptools 36.2.0 bug
5833
pip install --upgrade -r requirements.txt
5934
60-
- name: Install
35+
- name: Build and Install
6136
run: |
62-
echo $BUILD_OPTS
63-
python setup.py install $BUILD_OPTS
37+
python setup.py configure
38+
pip install -v .
6439
6540
- name: Python Tests
6641
run: pytest
6742

68-
- name: .NET Tests
69-
run: $RUN_TESTS src/embed_tests/bin/$EMBED_TESTS_PATH/Python.EmbeddingTest.dll --labels=All
43+
- name: Run Embedding tests
44+
run: dotnet test src/embed_tests/
45+
46+
# TODO: Run perf tests
47+
# TODO: Run tests on macos and windows as well
48+
# TODO: Run tests on Windows on .NET Framework

.gitignore

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

3+
# Configuration data
4+
configured.props
5+
36
# General binaries and Build results
47
*.dll
58
*.exe
@@ -17,6 +20,7 @@ __pycache__/
1720
build/
1821
dist/
1922
*.egg-info/
23+
.eggs/
2024

2125
# Unit test / coverage reports
2226
htmlcov/

Directory.Build.props

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project>
2+
<PropertyGroup>
3+
<VersionPrefix>3.0.0</VersionPrefix>
4+
<AssemblyCopyright>Copyright (c) 2006-2020 The Contributors of the Python.NET Project</AssemblyCopyright>
5+
<AssemblyCompany>pythonnet</AssemblyCompany>
6+
<AssemblyProduct>Python.NET</AssemblyProduct>
7+
<LangVersion>7.3</LangVersion>
8+
</PropertyGroup>
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
11+
<PackageReference Include="NonCopyableAnalyzer" Version="0.6.0">
12+
<PrivateAssets>all</PrivateAssets>
13+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
14+
</PackageReference>
15+
</ItemGroup>
16+
<Import Project="$(MSBuildThisFileDirectory)configured.props" Condition="Exists('$(MSBuildThisFileDirectory)configured.props')" />
17+
</Project>

NuGet.config

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

appveyor.yml

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,11 @@ platform:
1010

1111
environment:
1212
global:
13-
PYTHONUNBUFFERED: True
13+
PYTHONUNBUFFERED: 'True'
1414
PYTHONWARNINGS: 'ignore:::wheel.pep425tags:'
1515
CODECOV_ENV: PYTHON_VERSION, PLATFORM
1616

1717
matrix:
18-
- PYTHON_VERSION: 3.9
19-
BUILD_OPTS: --xplat
20-
- PYTHON_VERSION: 3.8
21-
BUILD_OPTS: --xplat
22-
- PYTHON_VERSION: 3.7
23-
BUILD_OPTS: --xplat
24-
- PYTHON_VERSION: 3.6
25-
BUILD_OPTS: --xplat
2618
- PYTHON_VERSION: 3.9
2719
- PYTHON_VERSION: 3.8
2820
- PYTHON_VERSION: 3.7
@@ -47,35 +39,18 @@ init:
4739
install:
4840
- python -m pip install -U pip
4941
- pip install --upgrade -r requirements.txt --quiet
50-
- pip install pycparser --quiet
51-
52-
# Install OpenCover. Can't put on `packages.config`, not Mono compatible
53-
- .\tools\nuget\nuget.exe install OpenCover -OutputDirectory packages -Verbosity quiet
5442

5543
build_script:
44+
- python setup.py configure
5645
# Create clean `sdist`. Only used for releases
5746
- python setup.py --quiet sdist
58-
# Build `wheel` with coverage of `setup.py`
59-
- coverage run setup.py bdist_wheel %BUILD_OPTS%
47+
- python setup.py bdist_wheel
6048

6149
test_script:
6250
- pip install --no-index --find-links=.\dist\ pythonnet
63-
- ps: .\ci\appveyor_run_tests.ps1
64-
65-
on_finish:
66-
# Temporary disable multiple upload due to codecov limit of 20 per commit.
67-
# https://docs.codecov.io/blog/week-8-2017
68-
- coverage xml -i
69-
# - codecov --file coverage.xml --flags setup_windows
70-
# - codecov --file py.coverage --flags python_tests
71-
# - codecov --file cs.coverage --flags embedded_tests
72-
- codecov --file py.coverage cs.coverage coverage.xml --flags setup_windows
51+
#- ps: .\ci\appveyor_run_tests.ps1
52+
- pytest
53+
- dotnet test src/embed_tests/
7354

7455
artifacts:
7556
- path: dist\*
76-
- path: '.\src\runtime\bin\*.nupkg'
77-
78-
notifications:
79-
- provider: Slack
80-
incoming_webhook:
81-
secure: 2S/t6rGHdbwoxehnvn5KgfsHrBFEtwnPD7M5olGErmz70oWFVpqoWd/EvDwh7rKZGdOTjDmpwcukc2xi5VRaGHbBAqFYS3tAdgAMrcaTNWs=

clr.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""
2+
Legacy Python.NET loader for backwards compatibility
3+
"""
4+
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()

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4", "pycparser"]
3+
build-backend = "setuptools.build_meta"

0 commit comments

Comments
 (0)