Tim Hall | 79d07d2 | 2020-04-27 18:20:16 +0100 | [diff] [blame] | 1 | # Copyright (C) 2020 Arm Limited or its affiliates. All rights reserved. |
| 2 | # |
| 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. |
Tim Hall | 79d07d2 | 2020-04-27 18:20:16 +0100 | [diff] [blame] | 16 | # Description: |
| 17 | # Packaging for the Vela compiler |
Michael McGeagh | 1e05afa | 2020-12-03 13:08:32 +0000 | [diff] [blame] | 18 | import os |
Michael McGeagh | 3adc1e4 | 2020-11-25 14:23:08 +0000 | [diff] [blame] | 19 | import re |
Diego Russo | e8a1045 | 2020-04-21 17:39:10 +0100 | [diff] [blame] | 20 | |
| 21 | from setuptools import Extension |
Diego Russo | e8a1045 | 2020-04-21 17:39:10 +0100 | [diff] [blame] | 22 | from setuptools import setup |
Dwight Lidman | e917cdc | 2021-05-12 18:58:05 +0200 | [diff] [blame] | 23 | from setuptools.command.build_ext import build_ext |
| 24 | |
| 25 | |
| 26 | class BuildExtension(build_ext): |
| 27 | def finalize_options(self): |
| 28 | build_ext.finalize_options(self) |
| 29 | import builtins |
| 30 | |
| 31 | # tell numpy it's not in setup anymore |
| 32 | builtins.__NUMPY_SETUP__ = False |
| 33 | import numpy as np |
| 34 | |
| 35 | # add the numpy headers to the mlw_codec extension |
| 36 | self.include_dirs.append(np.get_include()) |
| 37 | |
Tim Hall | 79d07d2 | 2020-04-27 18:20:16 +0100 | [diff] [blame] | 38 | |
| 39 | # Read the contents of README.md file |
Michael McGeagh | 1e05afa | 2020-12-03 13:08:32 +0000 | [diff] [blame] | 40 | this_directory = os.path.abspath(os.path.dirname(__file__)) |
| 41 | with open(os.path.join(this_directory, "README.md"), encoding="utf-8") as f: |
Tim Hall | 79d07d2 | 2020-04-27 18:20:16 +0100 | [diff] [blame] | 42 | long_description = f.read() |
James Peet | 51bb337 | 2022-02-11 12:21:44 +0000 | [diff] [blame] | 43 | tag = "3.3.0" |
Michael McGeagh | 3adc1e4 | 2020-11-25 14:23:08 +0000 | [diff] [blame] | 44 | url = f"https://review.mlplatform.org/plugins/gitiles/ml/ethos-u/ethos-u-vela/+/refs/tags/{tag}/" |
Michael McGeagh | 1e05afa | 2020-12-03 13:08:32 +0000 | [diff] [blame] | 45 | # Find all markdown links that match the format: [text](link) |
| 46 | for match, link in re.findall(r"(\[.+?\]\((.+?)\))", long_description): |
| 47 | # If the link is a file that exists, replace it with the web link to the file instead |
| 48 | if os.path.exists(os.path.join(this_directory, link)): |
| 49 | url_link = match.replace(link, url + link) |
| 50 | long_description = long_description.replace(match, url_link) |
| 51 | if os.getenv("ETHOSU_VELA_DEBUG"): |
| 52 | # Verify the contents of the modifications made in a markdown renderer |
| 53 | with open(os.path.join(this_directory, "PYPI.md"), "wt", encoding="utf-8") as fout: |
| 54 | fout.write(long_description) |
Tim Hall | 79d07d2 | 2020-04-27 18:20:16 +0100 | [diff] [blame] | 55 | |
| 56 | mlw_module = Extension( |
| 57 | "ethosu.mlw_codec", |
| 58 | ["ethosu/mlw_codec/mlw_encode.c", "ethosu/mlw_codec/mlw_decode.c", "ethosu/mlw_codec/mlw_codecmodule.c"], |
Fredrik Svedberg | 93d5c35 | 2021-05-11 13:51:47 +0200 | [diff] [blame] | 59 | define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_9_API_VERSION")], |
Tim Hall | 79d07d2 | 2020-04-27 18:20:16 +0100 | [diff] [blame] | 60 | ) |
| 61 | |
| 62 | setup( |
| 63 | name="ethos-u-vela", |
Tim Hall | 1793e2f | 2022-01-25 18:17:10 +0000 | [diff] [blame] | 64 | use_scm_version=True, |
Tim Hall | d13bd06 | 2020-11-12 23:29:25 +0000 | [diff] [blame] | 65 | description="Neural network model compiler for Arm Ethos-U NPUs", |
Tim Hall | 79d07d2 | 2020-04-27 18:20:16 +0100 | [diff] [blame] | 66 | long_description=long_description, |
| 67 | long_description_content_type="text/markdown", |
| 68 | url="https://git.mlplatform.org/ml/ethos-u/ethos-u-vela.git/", |
| 69 | author="Arm Ltd.", |
Dwight Lidman | f88771b | 2021-11-22 16:30:57 +0100 | [diff] [blame] | 70 | author_email="mlg-vela@arm.com", |
Tim Hall | 79d07d2 | 2020-04-27 18:20:16 +0100 | [diff] [blame] | 71 | license="Apache License 2.0", |
| 72 | classifiers=[ |
Tim Hall | e76a533 | 2020-06-23 09:52:07 +0100 | [diff] [blame] | 73 | "Development Status :: 5 - Production/Stable", |
Tim Hall | 79d07d2 | 2020-04-27 18:20:16 +0100 | [diff] [blame] | 74 | "Intended Audience :: Developers", |
| 75 | "License :: OSI Approved :: Apache Software License", |
| 76 | "Operating System :: POSIX :: Linux", |
Tim Hall | 7562bdf | 2021-02-25 14:28:06 +0000 | [diff] [blame] | 77 | "Operating System :: Microsoft :: Windows :: Windows 10", |
Tim Hall | 79d07d2 | 2020-04-27 18:20:16 +0100 | [diff] [blame] | 78 | "Programming Language :: C", |
| 79 | "Programming Language :: Python :: 3", |
Dwight Lidman | f018a68 | 2022-05-11 12:17:45 +0200 | [diff] [blame] | 80 | "Programming Language :: Python :: 3.7", |
Tim Hall | 79d07d2 | 2020-04-27 18:20:16 +0100 | [diff] [blame] | 81 | "Topic :: Scientific/Engineering :: Artificial Intelligence", |
| 82 | "Topic :: Software Development :: Compilers", |
| 83 | ], |
| 84 | keywords=["ethos-u", "vela compiler", "tflite", "npu"], |
James Peet | a8c0039 | 2021-07-15 13:38:57 +0100 | [diff] [blame] | 85 | packages=[ |
Rickard Bolin | 1538dce | 2022-04-25 11:07:56 +0000 | [diff] [blame] | 86 | "ethosu", |
James Peet | a8c0039 | 2021-07-15 13:38:57 +0100 | [diff] [blame] | 87 | "ethosu.vela", |
| 88 | "ethosu.vela.ethos_u55_regs", |
| 89 | "ethosu.vela.tflite", |
| 90 | "ethosu.vela.tosa", |
| 91 | "ethosu.mlw_codec", |
| 92 | ], |
Rickard Bolin | 1538dce | 2022-04-25 11:07:56 +0000 | [diff] [blame] | 93 | package_data={"ethosu": ["config_files/*/*.ini"]}, |
Dwight Lidman | f018a68 | 2022-05-11 12:17:45 +0200 | [diff] [blame] | 94 | python_requires="~=3.7", |
Fredrik Svedberg | 5b51388 | 2020-12-11 13:42:22 +0100 | [diff] [blame] | 95 | install_requires=[ |
Tim Hall | 42abec1 | 2021-02-04 21:31:57 +0000 | [diff] [blame] | 96 | "flatbuffers==1.12.0", |
Tim Hall | c3597d1 | 2022-05-23 11:31:07 +0100 | [diff] [blame] | 97 | "numpy<=1.21.6", |
Fredrik Svedberg | 5b51388 | 2020-12-11 13:42:22 +0100 | [diff] [blame] | 98 | "lxml>=4.5.1", |
| 99 | ], |
Tim Hall | 79d07d2 | 2020-04-27 18:20:16 +0100 | [diff] [blame] | 100 | entry_points={"console_scripts": ["vela = ethosu.vela.vela:main"]}, |
Louis Verhaard | d700252 | 2021-01-20 17:23:54 +0100 | [diff] [blame] | 101 | ext_modules=[mlw_module], |
Jonas Ohlsson | 845e232 | 2022-03-01 12:39:55 +0100 | [diff] [blame] | 102 | cmdclass={"build_ext": BuildExtension}, # type: ignore[dict-item] |
Tim Hall | c3597d1 | 2022-05-23 11:31:07 +0100 | [diff] [blame] | 103 | setup_requires=["numpy<=1.21.6", "setuptools_scm"], |
Tim Hall | 79d07d2 | 2020-04-27 18:20:16 +0100 | [diff] [blame] | 104 | ) |