From 04cea3dc9cc013b18f44caa4e7d56af4ef38ea07 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Sun, 22 May 2022 21:04:21 +0200 Subject: [PATCH 1/2] Move to modern setuptools with pyproject.toml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also moves the version to a common ̀`version.txt` that is read by both the .NET and Python builds. --- Directory.Build.props | 5 ++-- MANIFEST.in | 1 + pyproject.toml | 48 ++++++++++++++++++++++++++++++++++++++- setup.py | 53 ++++++------------------------------------- version.txt | 1 + 5 files changed, 59 insertions(+), 49 deletions(-) create mode 100644 version.txt diff --git a/Directory.Build.props b/Directory.Build.props index 496060877..af1381a28 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,11 +1,12 @@ + - 3.0.0 - Copyright (c) 2006-2021 The Contributors of the Python.NET Project + Copyright (c) 2006-2022 The Contributors of the Python.NET Project pythonnet Python.NET 10.0 false + $([System.IO.File]::ReadAllText("version.txt")) diff --git a/MANIFEST.in b/MANIFEST.in index 01f4156ca..4763ae70f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ recursive-include src/ * include Directory.Build.* include pythonnet.sln +include version.txt global-exclude **/obj/* **/bin/* diff --git a/pyproject.toml b/pyproject.toml index b6df82f71..5ee89d3b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,53 @@ [build-system] -requires = ["setuptools>=42", "wheel", "pycparser"] +requires = ["setuptools>=61", "wheel"] build-backend = "setuptools.build_meta" +[project] +name = "pythonnet" +description = ".NET and Mono integration for Python" +license = {text = "MIT"} + +readme = "README.rst" + +dependencies = [ + "clr_loader>=0.1.7" +] + +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: C#", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX :: Linux", + "Operating System :: MacOS :: MacOS X", +] + +dynamic = ["version"] + +[[project.authors]] +name = "The Contributors of the Python.NET Project" +email = "pythonnet@python.org" + +[project.urls] +Homepage = "https://pythonnet.github.io/" +Sources = "https://github.com/pythonnet/pythonnet" + +[tool.setuptools] +zip-safe = false +py-modules = ["clr"] + +[tool.setuptools.dynamic.version] +file = "version.txt" + +[tool.setuptools.packages.find] +include = ["pythonnet*"] + [tool.pytest.ini_options] xfail_strict = true testpaths = [ diff --git a/setup.py b/setup.py index 84f6f3ad2..7c02b7710 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,18 @@ #!/usr/bin/env python -from setuptools import setup, Command, Extension -from setuptools.command.build_ext import build_ext import distutils -from distutils.command import build -from subprocess import check_output, check_call +from distutils.command.build import build as _build +from setuptools.command.develop import develop as _develop +from wheel.bdist_wheel import bdist_wheel as _bdist_wheel +from setuptools import Distribution +from setuptools import setup, Command -import sys, os +import os # Disable SourceLink during the build until it can read repo-format v1, #1613 os.environ["EnableSourceControlManagerQueries"] = "false" + class DotnetLib: def __init__(self, name, path, **kwargs): self.name = name @@ -91,13 +93,6 @@ def run(self): # Add build_dotnet to the build tasks: -from distutils.command.build import build as _build -from setuptools.command.develop import develop as _develop -from wheel.bdist_wheel import bdist_wheel as _bdist_wheel -from setuptools import Distribution -import setuptools - - class build(_build): sub_commands = _build.sub_commands + [("build_dotnet", None)] @@ -129,10 +124,6 @@ def finalize_options(self): "bdist_wheel": bdist_wheel, } - -with open("README.rst", "r") as f: - long_description = f.read() - dotnet_libs = [ DotnetLib( "python-runtime", @@ -143,35 +134,5 @@ def finalize_options(self): setup( cmdclass=cmdclass, - name="pythonnet", - version="3.0.0.dev1", - description=".Net and Mono integration for Python", - url="https://pythonnet.github.io/", - project_urls={ - "Source": "https://github.com/pythonnet/pythonnet", - }, - license="MIT", - author="The Contributors of the Python.NET Project", - author_email="pythonnet@python.org", - packages=["pythonnet", "pythonnet.find_libpython"], - install_requires=["clr_loader >= 0.1.7"], - long_description=long_description, - long_description_content_type="text/x-rst", - py_modules=["clr"], dotnet_libs=dotnet_libs, - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Programming Language :: C#", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX :: Linux", - "Operating System :: MacOS :: MacOS X", - ], - zip_safe=False, ) diff --git a/version.txt b/version.txt new file mode 100644 index 000000000..e16bcc8be --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +3.0.0-dev1 From 34507c17652f1064cdb6fabede1788c1a45b8d09 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Mon, 23 May 2022 08:38:01 +0200 Subject: [PATCH 2/2] Allow explicitly overriding the version suffix for .NET builds --- Directory.Build.props | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index af1381a28..8c5b53685 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -6,7 +6,9 @@ Python.NET 10.0 false - $([System.IO.File]::ReadAllText("version.txt")) + $([System.IO.File]::ReadAllText("version.txt")) + $(FullVersion.Split('-', 2)[0]) + $(FullVersion.Split('-', 2)[1])