ai-edge-litert-sdk-qualcomm-nightly 0.1.0.dev20250515__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ai-edge-litert-sdk-qualcomm-nightly might be problematic. Click here for more details.

@@ -0,0 +1,2 @@
1
+ graft ai_edge_litert_sdk_qualcomm/data
2
+ include ai_edge_litert_sdk_qualcomm/__init__.py
@@ -0,0 +1,25 @@
1
+ Metadata-Version: 2.1
2
+ Name: ai-edge-litert-sdk-qualcomm-nightly
3
+ Version: 0.1.0.dev20250515
4
+ Summary: Qualcomm SDK for AI Edge LiteRT
5
+ Home-page: https://www.tensorflow.org/lite/
6
+ Author: Google AI Edge Authors
7
+ Author-email: packages@tensorflow.org
8
+ License: Apache 2.0
9
+ Keywords: litert tflite tensorflow tensor machine learning
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Education
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Topic :: Scientific/Engineering
21
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Classifier: Topic :: Software Development
24
+ Classifier: Topic :: Software Development :: Libraries
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
@@ -0,0 +1,59 @@
1
+ # Copyright 2025 The LiteRT Authors. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # ==============================================================================
15
+
16
+ """Qualcomm SDK for AI Edge LiteRT."""
17
+
18
+ __version__ = "0.1.0.dev20250515"
19
+
20
+ import os
21
+ import pathlib
22
+ import platform
23
+ import sys
24
+ from typing import Optional
25
+
26
+ _SDK_FILES_SUBDIR = "data"
27
+
28
+
29
+ def path_to_sdk_libs() -> Optional[pathlib.Path]:
30
+ sdk_path = get_sdk_path()
31
+ if not sdk_path:
32
+ return None
33
+ # Currently we only support linux x86 architecture.
34
+ return get_sdk_path() / "lib/x86_64-linux-clang"
35
+
36
+
37
+ def get_sdk_path() -> Optional[pathlib.Path]:
38
+ """Returns the absolute path to the root of the downloaded SDK files."""
39
+ is_linux = sys.platform == "linux"
40
+ is_x86_architecture = platform.machine() in ("x86_64", "i386", "i686")
41
+ if not (is_linux and is_x86_architecture):
42
+ raise NotImplementedError(
43
+ "Currently LiteRT NPU AOT for Qualcomm is only supported on Linux x86"
44
+ " architecture."
45
+ )
46
+ try:
47
+ package_dir = pathlib.Path(__file__).parent.resolve()
48
+ sdk_path = package_dir / _SDK_FILES_SUBDIR
49
+ if sdk_path.is_dir():
50
+ return sdk_path
51
+ else:
52
+ print(
53
+ f"Warning: SDK files directory not found at {sdk_path}",
54
+ file=sys.stderr,
55
+ )
56
+ return None
57
+ except Exception as e: # pylint: disable=broad-exception-caught
58
+ print(f"Error determining SDK path: {e}", file=sys.stderr)
59
+ return None
@@ -0,0 +1,25 @@
1
+ Metadata-Version: 2.1
2
+ Name: ai-edge-litert-sdk-qualcomm-nightly
3
+ Version: 0.1.0.dev20250515
4
+ Summary: Qualcomm SDK for AI Edge LiteRT
5
+ Home-page: https://www.tensorflow.org/lite/
6
+ Author: Google AI Edge Authors
7
+ Author-email: packages@tensorflow.org
8
+ License: Apache 2.0
9
+ Keywords: litert tflite tensorflow tensor machine learning
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Education
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Topic :: Scientific/Engineering
21
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Classifier: Topic :: Software Development
24
+ Classifier: Topic :: Software Development :: Libraries
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
@@ -0,0 +1,8 @@
1
+ MANIFEST.in
2
+ setup.py
3
+ ai_edge_litert_sdk_qualcomm/__init__.py
4
+ ai_edge_litert_sdk_qualcomm_nightly.egg-info/PKG-INFO
5
+ ai_edge_litert_sdk_qualcomm_nightly.egg-info/SOURCES.txt
6
+ ai_edge_litert_sdk_qualcomm_nightly.egg-info/dependency_links.txt
7
+ ai_edge_litert_sdk_qualcomm_nightly.egg-info/not-zip-safe
8
+ ai_edge_litert_sdk_qualcomm_nightly.egg-info/top_level.txt
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,230 @@
1
+ # Copyright 2025 The AI Edge LiteRT Authors.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # ==============================================================================
15
+ """LiteRT is for mobile and embedded devices.
16
+
17
+ LiteRT is the official solution for running machine learning models on mobile
18
+ and embedded devices. It enables on-device machine learning inference with low
19
+ latency and a small binary size on Android, iOS, and other operating systems.
20
+ """
21
+
22
+ import os
23
+ import platform
24
+ import sys
25
+ import tarfile
26
+ import tempfile
27
+ import urllib.request
28
+ import zipfile
29
+
30
+ import setuptools
31
+ from setuptools.command.build_py import build_py as _build_py # pylint: disable=g-importing-member
32
+
33
+ PACKAGE_NAME = 'ai_edge_litert_sdk_qualcomm_nightly'
34
+ PACKAGE_VERSION = '0.1.0.dev20250515'
35
+
36
+ SKIP_SDK_DOWNLOAD = os.environ.get('SKIP_SDK_DOWNLOAD', False)
37
+
38
+
39
+ # Platform information
40
+ IS_LINUX = sys.platform == 'linux'
41
+ IS_X86_ARCHITECTURE = platform.machine() in ('x86_64', 'i386', 'i686')
42
+
43
+
44
+ # --- Configuration for Qualcomm SDK Download ---
45
+ # Qairt version doesn't not necessarily match the SDK version though.
46
+ QAIRT_URL = 'https://softwarecenter.qualcomm.com/api/download/software/sdks/Qualcomm_AI_Runtime_Community/All/2.34.0.250424/v2.34.0.250424.zip'
47
+ QAIRT_CONTENT_DIR = 'qairt/2.34.0.250424'
48
+ QAIRT_TARGET_DIR = 'ai_edge_litert_sdk_qualcomm/data'
49
+ # ---
50
+
51
+
52
+ def _download_and_extract(
53
+ tarball_url: str, prefix_to_strip: str, target_dir: str
54
+ ):
55
+ """Download archive, extracts and copy."""
56
+ if not (IS_LINUX and IS_X86_ARCHITECTURE):
57
+ print(
58
+ 'IGNORED: Currently LiteRT NPU AOT for Qualcomm is only supported on'
59
+ ' Linux x86 architecture.'
60
+ )
61
+ return
62
+
63
+ os.makedirs(target_dir, exist_ok=True)
64
+
65
+ with tempfile.TemporaryDirectory() as tmpdir:
66
+ archive_name_local = os.path.join(tmpdir, os.path.basename(tarball_url))
67
+
68
+ print(f'Downloading SDK from {tarball_url}...')
69
+ try:
70
+ urllib.request.urlretrieve(tarball_url, archive_name_local)
71
+ except Exception as e: # pylint: disable=broad-exception-caught
72
+ print(f'ERROR: Failed to download SDK: {e}', file=sys.stderr)
73
+ print(
74
+ 'Please ensure you have an active internet connection.',
75
+ file=sys.stderr,
76
+ )
77
+ return
78
+
79
+ print('Extracting SDK files...')
80
+ try:
81
+ if tarball_url.endswith('.zip'):
82
+ archive_type = 'zip'
83
+ elif tarball_url.endswith('.tar.gz') or tarball_url.endswith('.tgz'):
84
+ archive_type = 'tar.gz'
85
+ else:
86
+ print(
87
+ f'ERROR: Unsupported archive type for URL: {tarball_url}',
88
+ file=sys.stderr,
89
+ )
90
+ return
91
+
92
+ if archive_type == 'zip':
93
+ with zipfile.ZipFile(archive_name_local, 'r') as zipf:
94
+ for member_info in zipf.infolist():
95
+ original_name = member_info.filename
96
+ # Ensure paths are normalized and secure (prevent path traversal)
97
+ if (
98
+ original_name.startswith(prefix_to_strip + '/')
99
+ and original_name != prefix_to_strip + '/'
100
+ ):
101
+ path_inside_subdir = original_name[len(prefix_to_strip) + 1 :]
102
+
103
+ if not path_inside_subdir:
104
+ continue
105
+
106
+ normalized_path = os.path.normpath(path_inside_subdir)
107
+ if normalized_path.startswith('..') or os.path.isabs(
108
+ normalized_path
109
+ ):
110
+ print(
111
+ 'WARNING: Skipping potentially malicious path:'
112
+ f' {original_name}',
113
+ file=sys.stderr,
114
+ )
115
+ continue
116
+
117
+ target_path_for_member = os.path.join(target_dir, normalized_path)
118
+
119
+ if member_info.is_dir():
120
+ os.makedirs(target_path_for_member, exist_ok=True)
121
+ else: # It's a file
122
+ os.makedirs(
123
+ os.path.dirname(target_path_for_member), exist_ok=True
124
+ )
125
+ with zipf.open(member_info) as source, open(
126
+ target_path_for_member, 'wb'
127
+ ) as target:
128
+ target.write(source.read())
129
+
130
+ elif archive_type == 'tar.gz':
131
+ with tarfile.open(archive_name_local, 'r:gz') as tar:
132
+ members_to_extract = []
133
+ for member in tar.getmembers():
134
+ if (
135
+ member.name.startswith(prefix_to_strip + '/')
136
+ and member.name != prefix_to_strip + '/'
137
+ ):
138
+ path_inside_subdir = member.name[len(prefix_to_strip) + 1 :]
139
+
140
+ if not path_inside_subdir: # Skip if it's empty after stripping
141
+ continue
142
+
143
+ normalized_path = os.path.normpath(path_inside_subdir)
144
+ if normalized_path.startswith('..') or os.path.isabs(
145
+ normalized_path
146
+ ):
147
+ print(
148
+ 'WARNING: Skipping potentially malicious path:'
149
+ f' {member.name}',
150
+ file=sys.stderr,
151
+ )
152
+ continue
153
+
154
+ member_copy = tar.getmember(member.name)
155
+ member_copy.name = normalized_path
156
+ members_to_extract.append(member_copy)
157
+
158
+ if members_to_extract:
159
+ tar.extractall(path=target_dir, members=members_to_extract)
160
+ print(
161
+ f"SDK files from '{prefix_to_strip}/' extracted to {target_dir}"
162
+ )
163
+ else:
164
+ print(f"No files found under '{prefix_to_strip}/' in the tarball.")
165
+
166
+ except (
167
+ zipfile.BadZipFile,
168
+ tarfile.TarError,
169
+ ) as e: # Catch both zipfile and tarfile specific errors
170
+ print(f'ERROR: Failed to extract archive: {e}', file=sys.stderr)
171
+ return
172
+ except Exception as e: # pylint: disable=broad-exception-caught
173
+ print(
174
+ f'ERROR: An unexpected error occurred during SDK extraction: {e}',
175
+ file=sys.stderr,
176
+ )
177
+ raise SystemExit('Install SDK failed. Aborting installation.') from e
178
+
179
+
180
+ class CustomBuildPy(_build_py):
181
+ """Command to replace import statements."""
182
+
183
+ def run(self):
184
+
185
+ print('Preparing SDK...')
186
+ if SKIP_SDK_DOWNLOAD:
187
+ print('Skipping SDK download...')
188
+ else:
189
+ _download_and_extract(QAIRT_URL, QAIRT_CONTENT_DIR, QAIRT_TARGET_DIR)
190
+
191
+ super().run()
192
+
193
+
194
+ setuptools.setup(
195
+ name=PACKAGE_NAME.replace('_', '-'),
196
+ version=PACKAGE_VERSION,
197
+ description='Qualcomm SDK for AI Edge LiteRT',
198
+ url='https://www.tensorflow.org/lite/',
199
+ author='Google AI Edge Authors',
200
+ author_email='packages@tensorflow.org',
201
+ license='Apache 2.0',
202
+ include_package_data=True,
203
+ has_ext_modules=lambda: True,
204
+ keywords='litert tflite tensorflow tensor machine learning',
205
+ classifiers=[
206
+ 'Development Status :: 5 - Production/Stable',
207
+ 'Intended Audience :: Developers',
208
+ 'Intended Audience :: Education',
209
+ 'Intended Audience :: Science/Research',
210
+ 'License :: OSI Approved :: Apache Software License',
211
+ 'Programming Language :: Python :: 3',
212
+ 'Programming Language :: Python :: 3.8',
213
+ 'Programming Language :: Python :: 3.9',
214
+ 'Programming Language :: Python :: 3.10',
215
+ 'Programming Language :: Python :: 3.11',
216
+ 'Topic :: Scientific/Engineering',
217
+ 'Topic :: Scientific/Engineering :: Mathematics',
218
+ 'Topic :: Scientific/Engineering :: Artificial Intelligence',
219
+ 'Topic :: Software Development',
220
+ 'Topic :: Software Development :: Libraries',
221
+ 'Topic :: Software Development :: Libraries :: Python Modules',
222
+ ],
223
+ packages=['ai_edge_litert_sdk_qualcomm'],
224
+ package_dir={'ai_edge_litert_sdk_qualcomm': 'ai_edge_litert_sdk_qualcomm'},
225
+ # Use the custom command for the build_py step
226
+ cmdclass={
227
+ 'build_py': CustomBuildPy,
228
+ },
229
+ zip_safe=False,
230
+ )