Move setuptools config to pyproject.toml

- Drop flake8 config
- Reformat with black
- Use .NET 6.0 for the example/test project
This commit is contained in:
Benedikt Reinartz 2022-07-08 01:28:02 +02:00
Родитель 6d6f7a1047
Коммит 1efebe4dc3
11 изменённых файлов: 61 добавлений и 51 удалений

Просмотреть файл

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2019 Benedikt Reinartz
Copyright (c) 2019-2022 Benedikt Reinartz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

Просмотреть файл

@ -41,7 +41,7 @@ def load_netfx():
raise RuntimeError(".NET Framework is only supported on Windows")
dirname = os.path.join(os.path.dirname(__file__), "dlls")
if sys.maxsize > 2 ** 32:
if sys.maxsize > 2**32:
arch = "amd64"
else:
arch = "x86"

Просмотреть файл

@ -125,7 +125,6 @@ if sys.platform == "win32":
def decode(char_ptr):
return ffi.string(char_ptr)
else:
def encode(string):

Просмотреть файл

@ -1,6 +1,6 @@
import atexit
import re
from typing import Optional, Sequence
from typing import Optional, Sequence, Dict, Any
from .ffi import load_mono, ffi
@ -23,7 +23,7 @@ class Mono:
config_file: Optional[str] = None,
global_config_file: Optional[str] = None,
):
self._assemblies = {}
self._assemblies: Dict[str, Any] = {}
initialize(
config_file=config_file,
@ -135,16 +135,21 @@ def initialize(
build = _MONO.mono_get_runtime_build_info()
_check_result(build, "Failed to get Mono version")
ver_str = ffi.string(build).decode('utf8') # e.g. '6.12.0.122 (tarball)'
ver_str = ffi.string(build).decode("utf8") # e.g. '6.12.0.122 (tarball)'
ver = re.match(r'^(?P<major>\d+)\.(?P<minor>\d+)\.[\d.]+', ver_str)
ver = re.match(r"^(?P<major>\d+)\.(?P<minor>\d+)\.[\d.]+", ver_str)
if ver is not None:
major = int(ver.group('major'))
minor = int(ver.group('minor'))
major = int(ver.group("major"))
minor = int(ver.group("minor"))
if major < 6 or (major == 6 and minor < 12):
import warnings
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.')
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."
)
atexit.register(_release)

Просмотреть файл

@ -2,7 +2,7 @@ import atexit
from typing import Optional, Any
from .ffi import ffi, load_netfx
_FW: Optional[Any] = None
_FW: Any = None
class NetFx:

Просмотреть файл

@ -46,13 +46,13 @@ def find_dotnet_root() -> str:
def find_libmono(sgen: bool = True) -> str:
unix_name = f"mono{'sgen' if sgen else ''}-2.0"
if sys.platform == "win32":
if sys.maxsize > 2 ** 32:
if sys.maxsize > 2**32:
prog_files = os.environ.get("ProgramFiles")
else:
prog_files = os.environ.get("ProgramFiles(x86)")
# Ignore sgen on Windows, the main installation only contains this DLL
path = fr"{prog_files}\Mono\bin\mono-2.0-sgen.dll"
path = rf"{prog_files}\Mono\bin\mono-2.0-sgen.dll"
elif sys.platform == "darwin":
path = (

Просмотреть файл

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp31;netstandard20</TargetFrameworks>
<TargetFrameworks>net60;netstandard20</TargetFrameworks>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
</PropertyGroup>
<ItemGroup>

Просмотреть файл

@ -1,3 +1,43 @@
[build-system]
requires = ["setuptools", "wheel"]
requires = ["setuptools>=61", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "clr_loader"
description = "Generic pure Python loader for .NET runtimes"
license = {text = "MIT"}
version = "0.1.7"
readme = "README.md"
dependencies = ["cffi>=1.13"]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
]
[[project.authors]]
name = "Benedikt Reinartz"
email = "filmor@gmail.com"
[project.urls]
Sources = "https://github.com/pythonnet/clr-loader"
[tool.setuptools]
zip-safe = false
package-data = {"clr_loader.ffi" = ["dlls/x86/*.dll", "dlls/amd64/*.dll"]}
[tool.setuptools.packages.find]
include = ["clr_loader*"]
[tool.pytest.ini_options]
xfail_strict = true
testpaths = [
"tests"
]

Просмотреть файл

@ -1,10 +0,0 @@
[metadata]
license_file = LICENSE
[flake8]
# Recommend matching the black line length (default 88),
# rather than using the flake8 default of 79:
max-line-length = 88
extend-ignore =
# See https://github.com/PyCQA/pycodestyle/issues/373
E203,

Просмотреть файл

@ -1,6 +1,6 @@
#!/usr/bin/env python
from setuptools import setup, find_packages, Command, Extension
from setuptools import setup, Command, Extension
from wheel.bdist_wheel import bdist_wheel
@ -50,31 +50,7 @@ class bdist_wheel_patched(bdist_wheel):
self.root_is_pure = True
with open("README.md", "r") as f:
long_description = f.read()
setup(
name="clr_loader",
version="0.1.7",
description="Generic pure Python loader for .NET runtimes",
author="Benedikt Reinartz",
author_email="filmor@gmail.com",
long_description=long_description,
long_description_content_type="text/markdown",
license="MIT",
python_requires=">=3.6",
install_requires=["cffi>=1.13"],
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
],
package_data={"clr_loader.ffi": ["dlls/x86/*.dll", "dlls/amd64/*.dll"]},
packages=find_packages(),
cmdclass={"build_ext": BuildDotnet, "bdist_wheel": bdist_wheel_patched},
ext_modules={
DotnetLib(

Просмотреть файл

@ -11,7 +11,7 @@ def example_netstandard(tmpdir_factory):
@pytest.fixture(scope="session")
def example_netcore(tmpdir_factory):
return build_example(tmpdir_factory, "netcoreapp31")
return build_example(tmpdir_factory, "net60")
def build_example(tmpdir_factory, framework):