Skip to content

Move to modern setuptools with pyproject.toml #1793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?xml version="1.0"?>
<Project>
<PropertyGroup>
<VersionPrefix>3.0.0</VersionPrefix>
<AssemblyCopyright>Copyright (c) 2006-2021 The Contributors of the Python.NET Project</AssemblyCopyright>
<AssemblyCopyright>Copyright (c) 2006-2022 The Contributors of the Python.NET Project</AssemblyCopyright>
<AssemblyCompany>pythonnet</AssemblyCompany>
<AssemblyProduct>Python.NET</AssemblyProduct>
<LangVersion>10.0</LangVersion>
<IsPackable>false</IsPackable>
<FullVersion>$([System.IO.File]::ReadAllText("version.txt"))</FullVersion>
<VersionPrefix>$(FullVersion.Split('-', 2)[0])</VersionPrefix>
<VersionSuffix Condition="$(FullVersion.Contains('-'))">$(FullVersion.Split('-', 2)[1])</VersionSuffix>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
recursive-include src/ *
include Directory.Build.*
include pythonnet.sln
include version.txt
global-exclude **/obj/* **/bin/*
48 changes: 47 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
53 changes: 7 additions & 46 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)]

Expand Down Expand Up @@ -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",
Expand All @@ -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,
)
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0.0-dev1