blob: ffa74e11d17e161ff6b94bd3d0c98899ad083282 [file] [log] [blame]
Rickard Bolinbc6ee582022-11-04 08:24:29 +00001# SPDX-FileCopyrightText: Copyright 2020-2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
Tim Hall79d07d22020-04-27 18:20:16 +01002#
3# SPDX-License-Identifier: Apache-2.0
4#
5# Licensed under the Apache License, Version 2.0 (the License); you may
6# not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an AS IS BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
Rickard Bolinbc6ee582022-11-04 08:24:29 +000016#
Tim Hall79d07d22020-04-27 18:20:16 +010017# Description:
18# Packaging for the Vela compiler
Michael McGeagh1e05afa2020-12-03 13:08:32 +000019import os
Michael McGeagh3adc1e42020-11-25 14:23:08 +000020import re
Diego Russoe8a10452020-04-21 17:39:10 +010021
22from setuptools import Extension
Diego Russoe8a10452020-04-21 17:39:10 +010023from setuptools import setup
Dwight Lidmane917cdc2021-05-12 18:58:05 +020024from setuptools.command.build_ext import build_ext
25
26
27class BuildExtension(build_ext):
28 def finalize_options(self):
29 build_ext.finalize_options(self)
30 import builtins
31
32 # tell numpy it's not in setup anymore
33 builtins.__NUMPY_SETUP__ = False
34 import numpy as np
35
36 # add the numpy headers to the mlw_codec extension
37 self.include_dirs.append(np.get_include())
38
Tim Hall79d07d22020-04-27 18:20:16 +010039
40# Read the contents of README.md file
Michael McGeagh1e05afa2020-12-03 13:08:32 +000041this_directory = os.path.abspath(os.path.dirname(__file__))
42with open(os.path.join(this_directory, "README.md"), encoding="utf-8") as f:
Tim Hall79d07d22020-04-27 18:20:16 +010043 long_description = f.read()
oliper0177f0e542022-08-16 11:21:17 +000044 tag = "3.5.0"
Michael McGeagh3adc1e42020-11-25 14:23:08 +000045 url = f"https://review.mlplatform.org/plugins/gitiles/ml/ethos-u/ethos-u-vela/+/refs/tags/{tag}/"
Michael McGeagh1e05afa2020-12-03 13:08:32 +000046 # Find all markdown links that match the format: [text](link)
47 for match, link in re.findall(r"(\[.+?\]\((.+?)\))", long_description):
48 # If the link is a file that exists, replace it with the web link to the file instead
49 if os.path.exists(os.path.join(this_directory, link)):
50 url_link = match.replace(link, url + link)
51 long_description = long_description.replace(match, url_link)
52 if os.getenv("ETHOSU_VELA_DEBUG"):
53 # Verify the contents of the modifications made in a markdown renderer
54 with open(os.path.join(this_directory, "PYPI.md"), "wt", encoding="utf-8") as fout:
55 fout.write(long_description)
Tim Hall79d07d22020-04-27 18:20:16 +010056
57mlw_module = Extension(
58 "ethosu.mlw_codec",
59 ["ethosu/mlw_codec/mlw_encode.c", "ethosu/mlw_codec/mlw_decode.c", "ethosu/mlw_codec/mlw_codecmodule.c"],
Fredrik Svedberg93d5c352021-05-11 13:51:47 +020060 define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_9_API_VERSION")],
Tim Hall79d07d22020-04-27 18:20:16 +010061)
62
63setup(
64 name="ethos-u-vela",
Tim Hall1793e2f2022-01-25 18:17:10 +000065 use_scm_version=True,
Tim Halld13bd062020-11-12 23:29:25 +000066 description="Neural network model compiler for Arm Ethos-U NPUs",
Tim Hall79d07d22020-04-27 18:20:16 +010067 long_description=long_description,
68 long_description_content_type="text/markdown",
69 url="https://git.mlplatform.org/ml/ethos-u/ethos-u-vela.git/",
70 author="Arm Ltd.",
Dwight Lidmanf88771b2021-11-22 16:30:57 +010071 author_email="mlg-vela@arm.com",
Tim Hall79d07d22020-04-27 18:20:16 +010072 license="Apache License 2.0",
73 classifiers=[
Tim Halle76a5332020-06-23 09:52:07 +010074 "Development Status :: 5 - Production/Stable",
Tim Hall79d07d22020-04-27 18:20:16 +010075 "Intended Audience :: Developers",
76 "License :: OSI Approved :: Apache Software License",
77 "Operating System :: POSIX :: Linux",
Tim Hall7562bdf2021-02-25 14:28:06 +000078 "Operating System :: Microsoft :: Windows :: Windows 10",
Tim Hall79d07d22020-04-27 18:20:16 +010079 "Programming Language :: C",
80 "Programming Language :: Python :: 3",
Dwight Lidmanf018a682022-05-11 12:17:45 +020081 "Programming Language :: Python :: 3.7",
Tim Hall79d07d22020-04-27 18:20:16 +010082 "Topic :: Scientific/Engineering :: Artificial Intelligence",
83 "Topic :: Software Development :: Compilers",
84 ],
85 keywords=["ethos-u", "vela compiler", "tflite", "npu"],
James Peeta8c00392021-07-15 13:38:57 +010086 packages=[
Rickard Bolin1538dce2022-04-25 11:07:56 +000087 "ethosu",
James Peeta8c00392021-07-15 13:38:57 +010088 "ethosu.vela",
89 "ethosu.vela.ethos_u55_regs",
90 "ethosu.vela.tflite",
91 "ethosu.vela.tosa",
92 "ethosu.mlw_codec",
93 ],
Rickard Bolin1538dce2022-04-25 11:07:56 +000094 package_data={"ethosu": ["config_files/*/*.ini"]},
Dwight Lidmanf018a682022-05-11 12:17:45 +020095 python_requires="~=3.7",
Fredrik Svedberg5b513882020-12-11 13:42:22 +010096 install_requires=[
erik.andersson@arm.com61f05d92022-09-27 12:06:32 +020097 "flatbuffers==2.0.7",
Tim Halldda4cae2022-09-28 12:47:54 +010098 "numpy<=1.21.3; python_version<='3.7'",
99 "numpy; python_version>'3.7'",
Fredrik Svedberg5b513882020-12-11 13:42:22 +0100100 "lxml>=4.5.1",
101 ],
Tim Hall79d07d22020-04-27 18:20:16 +0100102 entry_points={"console_scripts": ["vela = ethosu.vela.vela:main"]},
Louis Verhaardd7002522021-01-20 17:23:54 +0100103 ext_modules=[mlw_module],
Jonas Ohlsson845e2322022-03-01 12:39:55 +0100104 cmdclass={"build_ext": BuildExtension}, # type: ignore[dict-item]
Tim Halldda4cae2022-09-28 12:47:54 +0100105 setup_requires=["numpy<=1.21.3; python_version<='3.7'", "numpy; python_version>'3.7'", "setuptools_scm<6.0"],
Tim Hall79d07d22020-04-27 18:20:16 +0100106)