Skip to content

Commit

Permalink
python: move remaining projects to pyproject.toml (#2905)
Browse files Browse the repository at this point in the history
Move Python projects to pyproject.toml. Removes the legacy
behavior of calling python on setup.py, which is no longer the
advised way of creating python packages, per PEP 517.

Signed-off-by: Tim Whisonant <tim.whisonant@intel.com>
  • Loading branch information
tswhison committed Apr 10, 2023
1 parent d2028fd commit 12116f5
Show file tree
Hide file tree
Showing 31 changed files with 612 additions and 234 deletions.
36 changes: 22 additions & 14 deletions binaries/fpgadiag/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,32 +92,40 @@ if (OPAE_WITH_PYBIND11)
set(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/timestamp)
file(GLOB_RECURSE PKG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/opae/*)

set(INCLUDE_DIRS "${OPAE_INCLUDE_PATH}:${pybind11_ROOT}/include")
set(LINK_DIRS "${LIBRARY_OUTPUT_PATH}")
set(PYFILES
pyproject.toml
setup.py
mux.json
nlb0.json
nlb3.json
nlb7.json
)

set(PYDIST_STAGE_DIR ${CMAKE_CURRENT_BINARY_DIR}/stage)

foreach(pyfile ${PYFILES})
configure_file(${pyfile} ${PYDIST_STAGE_DIR}/${pyfile} @ONLY)
endforeach(pyfile ${PYFILES})

file(COPY opae DESTINATION ${PYDIST_STAGE_DIR})
file(COPY src DESTINATION ${PYDIST_STAGE_DIR})

add_custom_command(
OUTPUT ${OUTPUT}
COMMAND ${PYTHON_EXECUTABLE} setup.py build_ext -I ${INCLUDE_DIRS} -L ${LINK_DIRS}
COMMAND ${PYTHON_EXECUTABLE} setup.py build
COMMAND ${PYTHON_EXECUTABLE} -m pip install --root=${PYDIST_STAGE_DIR}/build --no-warn-script-location .
COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS setup.py ${PKG_FILES}
)

set_property(DIRECTORY PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/build"
"${CMAKE_CURRENT_SOURCE_DIR}/dist"
WORKING_DIRECTORY ${PYDIST_STAGE_DIR}
DEPENDS pyproject.toml setup.py ${PKG_FILES}
)

pybind11_add_module(eth_group THIN_LTO src/eth_group.cpp)
pybind11_add_module(eth_group THIN_LTO ${PYDIST_STAGE_DIR}/src/eth_group.cpp)
target_link_libraries(eth_group PRIVATE opaeuio)

add_custom_target(opae.diag-build ALL DEPENDS nlb0 nlb3 nlb7 ${OUTPUT})
opae_python_install(
COMPONENT toolfpgadiagapps
RECORD_FILE fpgadiag-install.txt
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
SOURCE_DIR ${PYDIST_STAGE_DIR}
RPM_PACKAGE tools-extra
)
endif(OPAE_WITH_PYBIND11)
58 changes: 58 additions & 0 deletions binaries/fpgadiag/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright(c) 2023, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Intel Corporation nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

[build-system]
requires = ["setuptools>=59.6", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "opae.diag"
version = "2.0.1"
description = "eth group provides python bindings for ethernet mdev"
#readme = ""
license = {text = "BSD-3-Clause"}
requires-python = ">=3.6"

[tool.setuptools]
packages = [
"opae",
"opae.diag",
]

[tool.setuptools.package-data]
"*" = ["*.json"]

[project.scripts]
fpgadiag = "opae.diag.fpgadiag:main"
fvlbypass = "opae.diag.fvlbypass:main"
fpgalpbk = "opae.diag.fpgalpbk:main"
mactest = "opae.diag.mactest:main"
fpgastats = "opae.diag.fpgastats:main"
fpgamac = "opae.diag.fpgamac:main"
fecmode = "opae.diag.fecmode:main"

[project.urls]
Homepage = "https://opae.github.io"
30 changes: 8 additions & 22 deletions binaries/fpgadiag/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

from setuptools import setup, find_namespace_packages
from setuptools.command.build_ext import build_ext
from distutils.ccompiler import new_compiler
from distutils.extension import Extension
from distutils.errors import CompileError, DistutilsExecError

# get the original build_extensions method
original_build_extensions = build_ext.build_extensions
Expand All @@ -45,16 +44,6 @@ def override_build_extensions(self):
build_ext.build_extensions = override_build_extensions


class pybind_include_dirs(object):
def __init__(self, user=False):
self.user = user

def __str__(self):
import pybind11
return pybind11.get_include(self.user)



def extensions():
ext = []

Expand All @@ -64,17 +53,20 @@ def extensions():
language="c++",
extra_compile_args=["-std=c++11"],
extra_link_args=["-std=c++11"],
include_dirs=[
"@OPAE_INCLUDE_PATH@",
"@pybind11_ROOT@/include",
],
libraries=['opaeuio'],
)
library_dirs=["@LIBRARY_OUTPUT_PATH@"])
)
return ext


setup(
name='opae.diag',
version="2.0",
name="opae.diag",
version="2.0.1",
packages=find_namespace_packages(include=['opae.*']),
include_dirs=[pybind_include_dirs()],
entry_points={
'console_scripts': [
'fpgadiag = opae.diag.fpgadiag:main',
Expand All @@ -86,11 +78,5 @@ def extensions():
'fecmode = opae.diag.fecmode:main',
]
},
description="eth group provides python bindings"
"for ethernet mdev",
license="BSD3",
keywords="OPAE eth group bindings",
url="https://opae.github.io",
ext_modules=extensions(),
include_package_data=True,
)
15 changes: 7 additions & 8 deletions binaries/hssi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Copyright(c) 2021, Intel Corporation
## Copyright(c) 2021-2023, Intel Corporation
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions are met:
Expand All @@ -25,25 +25,24 @@
## POSSIBILITY OF SUCH DAMAGE.

set(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/timestamp)
file(GLOB_RECURSE PKG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.py)

set(LINK_DIRS "${LIBRARY_OUTPUT_PATH}")
file(GLOB_RECURSE PKG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/ethernet/*.py)

add_custom_command(
OUTPUT ${OUTPUT}
COMMAND ${PYTHON_EXECUTABLE} setup.py build_ext -L ${LINK_DIRS}
COMMAND ${PYTHON_EXECUTABLE} setup.py build
COMMAND ${PYTHON_EXECUTABLE} -m pip install --root=${CMAKE_CURRENT_SOURCE_DIR}/build --no-warn-script-location .
COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS setup.py ${PKG_FILES}
DEPENDS pyproject.toml ${PKG_FILES}
)

set_property(DIRECTORY PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/build"
"${CMAKE_CURRENT_SOURCE_DIR}/dist"
)
add_custom_target(build ALL DEPENDS ${OUTPUT})

add_custom_target(build ALL DEPENDS ${OUTPUT})

opae_python_install(
COMPONENT toolhssi
RECORD_FILE hssi-install.txt
Expand Down
50 changes: 50 additions & 0 deletions binaries/hssi/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright(c) 2023, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Intel Corporation nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

[build-system]
requires = ["setuptools>=59.6", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "hssi_ethernet"
version = "2.0.1"
description = "hssi ethernet tools"
#readme = ""
license = {text = "BSD-3-Clause"}
requires-python = ">=3.6"

[tool.setuptools]
packages = [
"ethernet"
]

[project.scripts]
hssistats = "ethernet.hssistats:main"
hssimac = "ethernet.hssimac:main"
hssiloopback = "ethernet.hssiloopback:main"

[project.urls]
Homepage = "https://opae.github.io"
10 changes: 3 additions & 7 deletions binaries/hssi/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

from setuptools import setup, find_packages

setup(
name='hssi ethernet',
version="2.0",
name='hssi_ethernet',
version="2.0.1",
packages=find_packages(include=['*']),
entry_points={
'console_scripts': [
Expand All @@ -36,9 +37,4 @@
'hssiloopback = ethernet.hssiloopback:main'
]
},
description="hssi ethernet tools",
license="BSD3",
keywords="OPAE hssi tools ",
url="https://opae.github.io",
include_package_data=True,
)
15 changes: 5 additions & 10 deletions binaries/ofs.uio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Copyright(c) 2022, Intel Corporation
## Copyright(c) 2022-2023, Intel Corporation
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions are met:
Expand All @@ -24,20 +24,14 @@
## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
## POSSIBILITY OF SUCH DAMAGE.

# Build and install ofs.uio Python package

set(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/timestamp)
file(GLOB_RECURSE PKG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/uio/*)

set(LINK_DIRS "${LIBRARY_OUTPUT_PATH}")

add_custom_command(
OUTPUT ${OUTPUT}
COMMAND ${PYTHON_EXECUTABLE} setup.py build_ext -L ${LINK_DIRS}
COMMAND ${PYTHON_EXECUTABLE} setup.py build
COMMAND ${PYTHON_EXECUTABLE} -m pip install --root=${CMAKE_CURRENT_SOURCE_DIR}/build --no-warn-script-location .
COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS setup.py ${PKG_FILES}
DEPENDS pyproject.toml ${PKG_FILES}
)

set_property(DIRECTORY PROPERTY
Expand All @@ -46,7 +40,8 @@ set_property(DIRECTORY PROPERTY
"${CMAKE_CURRENT_SOURCE_DIR}/dist"
)

add_custom_target(ofs.uio-build ALL DEPENDS ${OUTPUT})
add_custom_target(ofs.uio-build ALL DEPENDS ${OUTPUT})

opae_python_install(
COMPONENT ofs.uio
RECORD_FILE ofs.uio-install.txt
Expand Down
48 changes: 48 additions & 0 deletions binaries/ofs.uio/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright(c) 2023, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Intel Corporation nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

[build-system]
requires = ["setuptools>=59.6", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "ofs.uio"
version = "1.0.1"
description = "tool to peek/poke and mailbox read/write csr"
#readme = ""
license = {text = "BSD-3-Clause"}
requires-python = ">=3.6"

[tool.setuptools]
packages = [
"uio"
]

[project.scripts]
"ofs.uio" = "uio.ofs_uio:main"

[project.urls]
Homepage = "https://opae.github.io"
Loading

0 comments on commit 12116f5

Please sign in to comment.