-
Notifications
You must be signed in to change notification settings - Fork 228
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
pyproject.toml #2981
base: develop
Are you sure you want to change the base?
pyproject.toml #2981
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,8 +39,9 @@ jobs: | |
env: | ||
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | ||
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | ||
NNCF_RELEASE_BUILD: "1" | ||
run: | | ||
python -m build -C--global-option=--release | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no way to pass global option to control format of version, that used env variable instead There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was more convenient to pass this option into CLI. |
||
python -m build | ||
|
||
# Disallow uploading dev packages | ||
for file in dist/*; do | ||
|
This file was deleted.
This file was deleted.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From my perspective, it is not correct to place helper-like files named with |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Copyright (c) 2024 Intel Corporation | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
# NOTE 1: This module generates the dynamic version for the package during the build process. | ||
# It provides the version attribute for setuptools as specified in pyproject.toml: | ||
# [tool.setuptools.dynamic] | ||
# version = { attr = "_version_helper.version" } | ||
Comment on lines
+13
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
# NOTE 2: To generate a release package without including the commit hash in the version, | ||
# set the NNCF_RELEASE_BUILD environment variable. | ||
|
||
from __future__ import annotations | ||
|
||
import contextlib | ||
import os | ||
import re | ||
from pathlib import Path | ||
|
||
NNCF_VERSION_FILE = "nncf/version.py" | ||
|
||
|
||
def get_custom_version() -> str: | ||
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", Path(NNCF_VERSION_FILE).read_text(), re.M) | ||
if not version_match: | ||
raise RuntimeError("Unable to find version string.") | ||
version_value = version_match.group(1) | ||
is_building_release = "NNCF_RELEASE_BUILD" in os.environ | ||
|
||
if not is_building_release: | ||
|
||
import subprocess # nosec | ||
|
||
dev_version_id = "unknown_version" | ||
repo_root = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
# Get commit hash | ||
with contextlib.suppress(subprocess.CalledProcessError): | ||
dev_version_id = ( | ||
subprocess.check_output(["git", "rev-parse", "--short", "HEAD"], cwd=repo_root) # nosec | ||
.strip() | ||
.decode() | ||
) | ||
|
||
# Detect modified files | ||
with contextlib.suppress(subprocess.CalledProcessError): | ||
repo_root = os.path.dirname(os.path.realpath(__file__)) | ||
run = subprocess.run(["git", "diff-index", "--quiet", "HEAD"], cwd=repo_root) # nosec | ||
if run.returncode == 1: | ||
dev_version_id += "dirty" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Detect editable mode There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous |
||
|
||
return version_value + f".dev0+{dev_version_id}" | ||
|
||
return version_value | ||
|
||
|
||
version: str | ||
|
||
|
||
def __getattr__(name: str) -> str: | ||
if name == "version": | ||
global version | ||
version = get_custom_version() | ||
return version | ||
raise AttributeError(name) |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
[build-system] | ||
requires = ["setuptools>=61.0"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the recommended |
||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "nncf" | ||
description = "Neural Networks Compression Framework" | ||
readme = "README.md" | ||
license = { text = "Apache-2.0" } | ||
authors = [{ name = "Intel" }, { email = "alexander.kozlov@intel.com" }] | ||
requires-python = ">=3.8" | ||
dynamic = ["version"] | ||
keywords = [ | ||
"bert", | ||
"classification", | ||
"compression", | ||
"hawq", | ||
"mixed-precision-training", | ||
"mmdetection", | ||
"nas", | ||
"nlp", | ||
"object-detection", | ||
"pruning", | ||
"quantization", | ||
"quantization-aware-training", | ||
"semantic-segmentation", | ||
"sparsity", | ||
"transformers", | ||
] | ||
classifiers = [ | ||
"License :: OSI Approved :: Apache Software License", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python :: 3", | ||
] | ||
dependencies = [ | ||
"jsonschema>=3.2.0", | ||
"jstyleson>=0.0.2", | ||
"natsort>=7.1.0", | ||
"networkx>=2.6, <=3.3", | ||
"ninja>=1.10.0.post2, <1.12", | ||
"numpy>=1.19.1, <1.27", | ||
"openvino-telemetry>=2023.2.0", | ||
"packaging>=20.0", | ||
"pandas>=1.1.5,<2.3", | ||
"psutil", | ||
"pydot>=1.4.1, <3.0.0", | ||
"pymoo>=0.6.0.1", | ||
"rich>=13.5.2", | ||
"scikit-learn>=0.24.0", | ||
"scipy>=1.3.2", | ||
"tabulate>=0.9.0", | ||
"tqdm>=4.54.1", | ||
] | ||
|
||
[project.optional-dependencies] | ||
plots = [ | ||
"kaleido>=0.2.1", | ||
"matplotlib>=3.3.4, <3.6", | ||
"pillow>=9.0.0", | ||
"plotly-express>=0.4.1", | ||
] | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/openvinotoolkit/nncf" | ||
|
||
[tool.setuptools.dynamic] | ||
version = { attr = "_version_helper.version" } | ||
|
||
[tool.setuptools.packages.find] | ||
where = ["."] | ||
exclude = ["tests", "tests.*", "examples", "examples.*", "tools", "tools.*"] | ||
namespaces = false | ||
|
||
[tool.black] | ||
line-length = 120 | ||
|
||
[tool.md_dead_link_check] | ||
exclude_files = ["ReleaseNotes.md"] | ||
|
||
[tool.isort] | ||
line_length = 120 | ||
force_single_line = true | ||
profile = "black" | ||
single_line_exclusions = "typing" | ||
skip_glob = "examples/post_training_quantization/torch/ssd300_vgg16/main.py" | ||
|
||
[tool.mypy] | ||
follow_imports = "silent" | ||
strict = true | ||
# should be removed later | ||
# mypy recommends the following tool as an autofix: | ||
# https://github.com/hauntsaninja/no_implicit_optional | ||
implicit_optional = true | ||
files = [ | ||
"nncf/common/sparsity", | ||
"nncf/common/graph", | ||
"nncf/common/accuracy_aware_training/", | ||
"nncf/common/utils/", | ||
"nncf/common/tensor_statistics", | ||
] | ||
|
||
[tool.ruff] | ||
line-length = 120 | ||
exclude = ["nncf/tensorflow/__init__.py"] | ||
|
||
[tool.ruff.lint] | ||
preview = true | ||
ignore-init-module-imports = true | ||
ignore = [ | ||
"E201", # whitespace-after-open-bracket | ||
"E203", # whitespace-before-punctuation | ||
"E231", # missing-whitespace | ||
"E251", # unexpected-spaces-around-keyword-parameter-equals | ||
"E731", # lambda-assignment | ||
"SIM108", # if-else-block-instead-of-if-exp | ||
"SIM110", # reimplemented-builtin | ||
"SIM117", # multiple-with-statements | ||
"SIM103", # needless-bool | ||
"NPY002", # numpy-legacy-random | ||
] | ||
select = [ | ||
"E", # pycodestyle rules | ||
"F", # pyflakes rules | ||
"CPY001", # copyright check | ||
"NPY", # numpy rules | ||
] | ||
extend-select = [ | ||
"SIM", # https://pypi.org/project/flake8-simplify | ||
] | ||
|
||
[tool.ruff.lint.per-file-ignores] | ||
"nncf/experimental/torch/nas/bootstrapNAS/__init__.py" = ["F401"] | ||
"nncf/torch/__init__.py" = ["F401", "E402"] | ||
"tests/**/*.py" = ["F403"] | ||
"tests/**/__init__.py" = ["F401"] | ||
"examples/**/*.py" = ["F403"] | ||
|
||
[tool.ruff.lint.flake8-copyright] | ||
notice-rgx = """\ | ||
# Copyright \\(c\\) (\\d{4}|\\d{4}-\\d{4}) Intel Corporation | ||
# Licensed under the Apache License, Version 2.0 \\(the "License"\\); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
""" |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes need to be placed in our release procedure documentation.