Skip to content
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
6 changes: 2 additions & 4 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:
CIBW_BEFORE_BUILD_LINUX: pip install protobuf
CIBW_BEFORE_BUILD_WINDOWS: python -m pip install protobuf
CIBW_BEFORE_BUILD_MACOS: pip install protobuf
CIBW_TEST_REQUIRES_LINUX: pytest pytest-xdist flake8 mypy onnxruntime
CIBW_TEST_REQUIRES_LINUX: pytest pytest-xdist flake8-pyproject mypy onnxruntime
CIBW_TEST_REQUIRES_MACOS: pytest pytest-xdist
CIBW_TEST_REQUIRES_WINDOWS: pytest pytest-xdist
CIBW_BEFORE_TEST_LINUX: pip install torch==2.6.0+cpu torchvision==0.21.0+cpu --index-url https://download.pytorch.org/whl/cpu
CIBW_TEST_COMMAND: pytest {project}/onnxoptimizer/test
CIBW_TEST_COMMAND_LINUX: cd {project} && flake8 && pytest
CIBW_TEST_COMMAND_LINUX: cd {project} && flake8p && pytest
CIBW_TEST_SKIP: " *_arm64"
CIBW_ENVIRONMENT: CMAKE_ARGS="-DONNX_USE_PROTOBUF_SHARED_LIBS=OFF -DProtobuf_USE_STATIC_LIBS=ON -DONNX_USE_LITE_PROTO=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5"
CIBW_ENVIRONMENT_WINDOWS: USE_MSVC_STATIC_RUNTIME=0 CMAKE_ARGS="-DONNX_USE_PROTOBUF_SHARED_LIBS=OFF -DProtobuf_USE_STATIC_LIBS=ON -DONNX_USE_LITE_PROTO=ON"
Expand Down Expand Up @@ -64,8 +64,6 @@ jobs:
with:
submodules: recursive

- run: python3 -m pip install protobuf

- name: Build sdist
run: pipx run build --sdist

Expand Down
4 changes: 3 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
recursive-include onnxoptimizer *.h *.c *.cc *.proto
recursive-include onnxoptimizer *.h *.cc
recursive-include examples *
recursive-include cmake *
recursive-include tools *
recursive-include third_party *
include VERSION_NUMBER
include CMakeLists.txt

recursive-exclude third_party *.onnx *.pb *.cs *.rs
110 changes: 110 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
[project]
dynamic = ["version"]
name = "onnxoptimizer"
description = "ONNX Optimizer"
license = 'Apache-2.0'
license-files = [
"LICENSE"
]
authors = [
{name = 'ONNX Optimizer Authors', email = "[email protected]"},
]
readme = "README.md"
keywords = [
"deep-learning",
"ONNX",
]
dependencies = [
"onnx",
]

[project.urls]
Homepage = 'https://github.com/onnx/optimizer'

[console_scripts]
onnxoptimizer = "onnxoptimizer:main"

[build-system]
requires = [
"setuptools>=68",
"wheel",
"cmake>=3.22",
"protobuf>=4.25.1"
]
build-backend = "setuptools.build_meta"

[tool.pytest.ini_options]
# addopts = --nbval --current-env
addopts = "-n auto"
testpaths = [
"onnxoptimizer/test/"
]

[[tool.mypy]]
# follow-imports = silent # TODO remove this
mypy_path = "stubs:third_party/onnx/third_party/pybind11"
strict_optional = true
warn_return_any = true
warn_no_return = true
# TODO warn_unused_ignores = true
warn_redundant_casts = true
warn_incomplete_stub = true
# TODO disallow_untyped_calls = true
check_untyped_defs = true
disallow_any_generics = true
no_implicit_optional = true
# TODO disallow_incomplete_defs = true
# TODO disallow_subclassing_any = true
disallow_untyped_decorators = true
warn_unused_configs = true

[[tool.mypy.overrides]]
module = "onnxoptimizer.*"
disallow_untyped_defs = true

[[tool.mypy.overrides]]
module = "onnx_opt_cpp2py_export"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "onnx.*"
disallow_untyped_defs = true
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "tools.*"
disallow_untyped_defs = true

# Ignore errors in setup.py
[[tool.mypy.overrides]]
module = "setup"
ignore_errors = true

[tool.flake8]
select = ["B","C","E","F","P","T4","W","B9"]
max-line-length = 80
### DEFAULT IGNORES FOR 4-space INDENTED PROJECTS ###
# E127, E128 are hard to silence in certain nested formatting situations.
# E265, E266 talk about comment formatting which is too opinionated.
# E402 warns on imports coming after statements. There are important use cases
# like demandimport (https://fburl.com/demandimport) that require statements
# before imports.
# E501 is not flexible enough, we're using B950 instead.
# E722 is a duplicate of B001.
# F405 is hard to silence since we indeed do star import
# P207 is a duplicate of B003.
# P208 is a duplicate of C403.
# W503 talks about operator formatting which is too opinionated.
# F401 clashes with PEP484 requiring us to import types that are only used in
# type comments.
ignore = ["E127", "E128", "E265", "E266", "E402", "E501", "E722", "F405", "P207", "P208", "W503", "F401"]
exclude = [
".git",
"__pycache__",
"build/*",
"third_party/*",
"*_pb2.py",
".cache/*",
".eggs",
".setuptools-cmake-build*/*",
]
76 changes: 0 additions & 76 deletions setup.cfg

This file was deleted.

41 changes: 0 additions & 41 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@

CMAKE = shutil.which('cmake')

install_requires = []
setup_requires = []
extras_require = {}

################################################################################
# Global variables for controlling the build variant
################################################################################
Expand Down Expand Up @@ -312,52 +308,15 @@ def run(self):
# no need to do fancy stuff so far
packages = setuptools.find_packages()

install_requires.extend([
'onnx'
])

################################################################################
# Test
################################################################################

setup_requires.append('pytest-runner')
setup_requires.append('protobuf')

if sys.version_info[0] == 3:
# Mypy doesn't work with Python 2
extras_require['mypy'] = ['mypy==0.600']

################################################################################
# Final
################################################################################

# read the contents of your README file
from pathlib import Path
this_directory = Path(__file__).parent
long_description = (this_directory / "README.md").read_text()

setuptools.setup(
name="onnxoptimizer",
version=VersionInfo.version,
description="ONNX Optimizer",
ext_modules=ext_modules,
cmdclass=cmdclass,
packages=packages,
license='Apache License v2.0',
include_package_data=True,
install_requires=install_requires,
setup_requires=setup_requires,
extras_require=extras_require,
author='ONNX Optimizer Authors',
author_email='[email protected]',
url='https://github.com/onnx/optimizer',
keywords='deep-learning ONNX',
long_description=long_description,
long_description_content_type='text/markdown',
entry_points={
'console_scripts': [
'onnxoptimizer=onnxoptimizer:main',
],
},
options=setup_opts,
)