Skip to content

Commit 6f6aa7a

Browse files
chensuyuepre-commit-ci[bot]
authored andcommitted
refine release binary build for 3.0 API (#1336)
Signed-off-by: chensuyue <suyue.chen@intel.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Signed-off-by: bmyrcha <bartosz.myrcha@intel.com>
1 parent c6167d8 commit 6f6aa7a

File tree

2 files changed

+122
-58
lines changed

2 files changed

+122
-58
lines changed

setup.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[metadata]
2+
license_files =
3+
LICENSE
4+
third-party-programs.txt

setup.py

Lines changed: 118 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -17,68 +17,126 @@ def fetch_requirements(path):
1717
except Exception as error:
1818
assert False, "Error: Could not open '%s' due %s\n" % (filepath, error)
1919

20-
neural_insights = False
21-
if "neural_insights" in sys.argv:
22-
neural_insights = True
23-
sys.argv.remove("neural_insights")
20+
PKG_INSTALL_CFG = {
21+
"neural_compressor_2x": {
22+
"project_name": "neural_compressor",
23+
"include_packages": find_packages(
24+
include=["neural_compressor", "neural_compressor.*", "neural_coder", "neural_coder.*"],
25+
exclude=[
26+
"neural_compressor.template",
27+
"neural_compressor.common",
28+
"neural_compressor.common.*",
29+
"neural_compressor.torch",
30+
"neural_compressor.torch.*",
31+
"neural_compressor.tensorflow",
32+
"neural_compressor.tensorflow.*",
33+
],
34+
),
35+
"package_data": {"": ["*.yaml"]},
36+
"install_requires": fetch_requirements("requirements.txt"),
37+
"extras_require": {
38+
"pt": [f"neural_compressor_3x_pt=={__version__}"],
39+
"tf": [f"neural_compressor_3x_tf=={__version__}"],
40+
"ort": [f"neural_compressor_3x_ort=={__version__}"],
41+
},
42+
},
43+
"neural_compressor_3x_pt": {
44+
"project_name": "neural_compressor_3x_pt",
45+
"include_packages": find_packages(
46+
include=[
47+
"neural_compressor.common",
48+
"neural_compressor.common.*",
49+
"neural_compressor.version.py",
50+
"neural_compressor.torch",
51+
"neural_compressor.torch.*",
52+
],
53+
),
54+
},
55+
"neural_compressor_3x_tf": {
56+
"project_name": "neural_compressor_3x_tf",
57+
"include_packages": find_packages(
58+
include=[
59+
"neural_compressor.common",
60+
"neural_compressor.common.*",
61+
"neural_compressor.version.py",
62+
"neural_compressor.tensorflow",
63+
"neural_compressor.tensorflow.*",
64+
],
65+
),
66+
},
67+
"neural_compressor_3x_ort": {
68+
"project_name": "neural_compressor_3x_ort",
69+
"include_packages": find_packages(
70+
include=[
71+
"neural_compressor.common",
72+
"neural_compressor.common.*",
73+
"neural_compressor.version.py",
74+
"neural_compressor.onnxrt",
75+
"neural_compressor.onnxrt.*",
76+
],
77+
),
78+
},
79+
"neural_insights": {
80+
"project_name": "neural_insights",
81+
"include_packages": find_packages(include=["neural_insights", "neural_insights.*"], exclude=["test.*", "test"]),
82+
"package_data": {
83+
"neural_insights": [
84+
"bin/*",
85+
"*.yaml",
86+
"web/app/*.*",
87+
"web/app/static/css/*",
88+
"web/app/static/js/*",
89+
"web/app/static/media/*",
90+
"web/app/icons/*",
91+
]
92+
},
93+
"install_requires": fetch_requirements("neural_insights/requirements.txt"),
94+
"entry_points": {"console_scripts": ["neural_insights = neural_insights.bin.neural_insights:execute"]},
95+
},
96+
"neural_solution": {
97+
"project_name": "neural_solution",
98+
"include_packages": find_packages(include=["neural_solution", "neural_solution.*"]),
99+
"package_data": {
100+
"neural_solution": [
101+
"scripts/*.*",
102+
"frontend/*.json",
103+
]
104+
},
105+
"install_requires": fetch_requirements("neural_solution/requirements.txt"),
106+
"entry_points": {"console_scripts": ["neural_solution = neural_solution.bin.neural_solution:exec"]},
107+
},
108+
}
24109

25-
neural_solution = False
26-
if "neural_solution" in sys.argv:
27-
neural_solution = True
28-
sys.argv.remove("neural_solution")
29110

30-
# define include packages
31-
include_packages = find_packages(
32-
include=["neural_compressor", "neural_compressor.*", "neural_coder", "neural_coder.*"],
33-
exclude=["neural_compressor.template"],
34-
)
35-
neural_insights_packages = find_packages(include=["neural_insights", "neural_insights.*"], exclude=["test.*", "test"])
36-
neural_solution_packages = find_packages(include=["neural_solution", "neural_solution.*"])
111+
if __name__ == "__main__":
112+
cfg_key = "neural_compressor_2x"
113+
if "neural_insights" in sys.argv:
114+
sys.argv.remove("neural_insights")
115+
cfg_key = "neural_insights"
37116

38-
# define package data
39-
package_data = {"": ["*.yaml"]}
40-
neural_insights_data = {
41-
"neural_insights": [
42-
"bin/*",
43-
"*.yaml",
44-
"web/app/*.*",
45-
"web/app/static/css/*",
46-
"web/app/static/js/*",
47-
"web/app/static/media/*",
48-
"web/app/icons/*",
49-
]
50-
}
51-
neural_solution_data = {
52-
"neural_solution": [
53-
"scripts/*.*",
54-
"frontend/*.json",
55-
]
56-
}
117+
if "neural_solution" in sys.argv:
118+
sys.argv.remove("neural_solution")
119+
cfg_key = "neural_solution"
57120

58-
# define install requirements
59-
install_requires_list = fetch_requirements("requirements.txt")
60-
neural_insights_requires = fetch_requirements("neural_insights/requirements.txt")
61-
neural_solution_requires = fetch_requirements("neural_solution/requirements.txt")
121+
if "pt" in sys.argv:
122+
sys.argv.remove("pt")
123+
cfg_key = "neural_compressor_3x_pt"
62124

63-
# define entry points
64-
entry_points = {}
125+
if "tf" in sys.argv:
126+
sys.argv.remove("tf")
127+
cfg_key = "neural_compressor_3x_tf"
65128

66-
if neural_insights:
67-
project_name = "neural_insights"
68-
package_data = neural_insights_data
69-
install_requires_list = neural_insights_requires
70-
include_packages = neural_insights_packages
71-
entry_points = {"console_scripts": ["neural_insights = neural_insights.bin.neural_insights:execute"]}
72-
elif neural_solution:
73-
project_name = "neural_solution"
74-
package_data = neural_solution_data
75-
install_requires_list = neural_solution_requires
76-
include_packages = neural_solution_packages
77-
entry_points = {"console_scripts": ["neural_solution = neural_solution.bin.neural_solution:exec"]}
78-
else:
79-
project_name = "neural_compressor"
129+
if "ort" in sys.argv:
130+
sys.argv.remove("ort")
131+
cfg_key = "neural_compressor_3x_ort"
132+
133+
project_name = PKG_INSTALL_CFG[cfg_key].get("project_name")
134+
include_packages = PKG_INSTALL_CFG[cfg_key].get("include_packages") or {}
135+
package_data = PKG_INSTALL_CFG[cfg_key].get("package_data") or {}
136+
install_requires = PKG_INSTALL_CFG[cfg_key].get("install_requires") or []
137+
entry_points = PKG_INSTALL_CFG[cfg_key].get("entry_points") or {}
138+
extras_require = PKG_INSTALL_CFG[cfg_key].get("extras_require") or {}
80139

81-
if __name__ == "__main__":
82140
setup(
83141
name=project_name,
84142
version=__version__,
@@ -87,15 +145,17 @@ def fetch_requirements(path):
87145
description="Repository of Intel® Neural Compressor",
88146
long_description=open("README.md", "r", encoding="utf-8").read(),
89147
long_description_content_type="text/markdown",
90-
keywords="quantization, auto-tuning, post-training static quantization, post-training dynamic quantization, quantization-aware training",
148+
keywords="quantization,auto-tuning,post-training static quantization,"
149+
"post-training dynamic quantization,quantization-aware training",
91150
license="Apache 2.0",
92151
url="https://github.com/intel/neural-compressor",
93152
packages=include_packages,
94153
include_package_data=True,
95154
package_data=package_data,
96-
install_requires=install_requires_list,
155+
install_requires=install_requires,
97156
entry_points=entry_points,
98-
python_requires=">=3.6.0",
157+
extras_require=extras_require,
158+
python_requires=">=3.7.0",
99159
classifiers=[
100160
"Intended Audience :: Science/Research",
101161
"Programming Language :: Python :: 3",

0 commit comments

Comments
 (0)