Skip to content

Commit 1efebe4

Browse files
committed
Move setuptools config to pyproject.toml
- Drop flake8 config - Reformat with black - Use .NET 6.0 for the example/test project
1 parent 6d6f7a1 commit 1efebe4

File tree

11 files changed

+61
-51
lines changed

11 files changed

+61
-51
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Benedikt Reinartz
3+
Copyright (c) 2019-2022 Benedikt Reinartz
44

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

clr_loader/ffi/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def load_netfx():
4141
raise RuntimeError(".NET Framework is only supported on Windows")
4242

4343
dirname = os.path.join(os.path.dirname(__file__), "dlls")
44-
if sys.maxsize > 2 ** 32:
44+
if sys.maxsize > 2**32:
4545
arch = "amd64"
4646
else:
4747
arch = "x86"

clr_loader/hostfxr.py

-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ def encode(string):
125125
def decode(char_ptr):
126126
return ffi.string(char_ptr)
127127

128-
129128
else:
130129

131130
def encode(string):

clr_loader/mono.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import atexit
22
import re
3-
from typing import Optional, Sequence
3+
from typing import Optional, Sequence, Dict, Any
44

55
from .ffi import load_mono, ffi
66

@@ -23,7 +23,7 @@ def __init__(
2323
config_file: Optional[str] = None,
2424
global_config_file: Optional[str] = None,
2525
):
26-
self._assemblies = {}
26+
self._assemblies: Dict[str, Any] = {}
2727

2828
initialize(
2929
config_file=config_file,
@@ -135,16 +135,21 @@ def initialize(
135135

136136
build = _MONO.mono_get_runtime_build_info()
137137
_check_result(build, "Failed to get Mono version")
138-
ver_str = ffi.string(build).decode('utf8') # e.g. '6.12.0.122 (tarball)'
138+
ver_str = ffi.string(build).decode("utf8") # e.g. '6.12.0.122 (tarball)'
139139

140-
ver = re.match(r'^(?P<major>\d+)\.(?P<minor>\d+)\.[\d.]+', ver_str)
140+
ver = re.match(r"^(?P<major>\d+)\.(?P<minor>\d+)\.[\d.]+", ver_str)
141141
if ver is not None:
142-
major = int(ver.group('major'))
143-
minor = int(ver.group('minor'))
142+
major = int(ver.group("major"))
143+
minor = int(ver.group("minor"))
144144

145145
if major < 6 or (major == 6 and minor < 12):
146146
import warnings
147-
warnings.warn('Hosting Mono versions before v6.12 is known to be problematic. If the process crashes shortly after you see this message, try updating Mono to at least v6.12.')
147+
148+
warnings.warn(
149+
"Hosting Mono versions before v6.12 is known to be problematic. "
150+
"If the process crashes shortly after you see this message, try "
151+
"updating Mono to at least v6.12."
152+
)
148153

149154
atexit.register(_release)
150155

clr_loader/netfx.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Optional, Any
33
from .ffi import ffi, load_netfx
44

5-
_FW: Optional[Any] = None
5+
_FW: Any = None
66

77

88
class NetFx:

clr_loader/util/find.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ def find_dotnet_root() -> str:
4646
def find_libmono(sgen: bool = True) -> str:
4747
unix_name = f"mono{'sgen' if sgen else ''}-2.0"
4848
if sys.platform == "win32":
49-
if sys.maxsize > 2 ** 32:
49+
if sys.maxsize > 2**32:
5050
prog_files = os.environ.get("ProgramFiles")
5151
else:
5252
prog_files = os.environ.get("ProgramFiles(x86)")
5353

5454
# Ignore sgen on Windows, the main installation only contains this DLL
55-
path = fr"{prog_files}\Mono\bin\mono-2.0-sgen.dll"
55+
path = rf"{prog_files}\Mono\bin\mono-2.0-sgen.dll"
5656

5757
elif sys.platform == "darwin":
5858
path = (

example/example.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>netcoreapp31;netstandard20</TargetFrameworks>
3+
<TargetFrameworks>net60;netstandard20</TargetFrameworks>
44
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
55
</PropertyGroup>
66
<ItemGroup>

pyproject.toml

+41-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
11
[build-system]
2-
requires = ["setuptools", "wheel"]
2+
requires = ["setuptools>=61", "wheel"]
33
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "clr_loader"
7+
description = "Generic pure Python loader for .NET runtimes"
8+
license = {text = "MIT"}
9+
version = "0.1.7"
10+
11+
readme = "README.md"
12+
13+
dependencies = ["cffi>=1.13"]
14+
15+
classifiers = [
16+
"Development Status :: 4 - Beta",
17+
"Intended Audience :: Developers",
18+
"License :: OSI Approved :: MIT License",
19+
"Programming Language :: Python :: 3",
20+
"Operating System :: Microsoft :: Windows",
21+
"Operating System :: POSIX :: Linux",
22+
"Operating System :: MacOS :: MacOS X",
23+
]
24+
25+
[[project.authors]]
26+
name = "Benedikt Reinartz"
27+
28+
29+
[project.urls]
30+
Sources = "https://github.com/pythonnet/clr-loader"
31+
32+
[tool.setuptools]
33+
zip-safe = false
34+
package-data = {"clr_loader.ffi" = ["dlls/x86/*.dll", "dlls/amd64/*.dll"]}
35+
36+
[tool.setuptools.packages.find]
37+
include = ["clr_loader*"]
38+
39+
[tool.pytest.ini_options]
40+
xfail_strict = true
41+
testpaths = [
42+
"tests"
43+
]

setup.cfg

-10
This file was deleted.

setup.py

+1-25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
from setuptools import setup, find_packages, Command, Extension
3+
from setuptools import setup, Command, Extension
44
from wheel.bdist_wheel import bdist_wheel
55

66

@@ -50,31 +50,7 @@ def finalize_options(self):
5050
self.root_is_pure = True
5151

5252

53-
with open("README.md", "r") as f:
54-
long_description = f.read()
55-
5653
setup(
57-
name="clr_loader",
58-
version="0.1.7",
59-
description="Generic pure Python loader for .NET runtimes",
60-
author="Benedikt Reinartz",
61-
author_email="[email protected]",
62-
long_description=long_description,
63-
long_description_content_type="text/markdown",
64-
license="MIT",
65-
python_requires=">=3.6",
66-
install_requires=["cffi>=1.13"],
67-
classifiers=[
68-
"Development Status :: 2 - Pre-Alpha",
69-
"Intended Audience :: Developers",
70-
"License :: OSI Approved :: MIT License",
71-
"Programming Language :: Python :: 3",
72-
"Operating System :: Microsoft :: Windows",
73-
"Operating System :: POSIX :: Linux",
74-
"Operating System :: MacOS :: MacOS X",
75-
],
76-
package_data={"clr_loader.ffi": ["dlls/x86/*.dll", "dlls/amd64/*.dll"]},
77-
packages=find_packages(),
7854
cmdclass={"build_ext": BuildDotnet, "bdist_wheel": bdist_wheel_patched},
7955
ext_modules={
8056
DotnetLib(

tests/test_common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def example_netstandard(tmpdir_factory):
1111

1212
@pytest.fixture(scope="session")
1313
def example_netcore(tmpdir_factory):
14-
return build_example(tmpdir_factory, "netcoreapp31")
14+
return build_example(tmpdir_factory, "net60")
1515

1616

1717
def build_example(tmpdir_factory, framework):

0 commit comments

Comments
 (0)