| @@ -132,7 +132,7 @@ jobs: | |||||
| run: | | run: | | ||||
| export PYTHONUSERBASE=${{ci.workspace}}/torch-${{matrix.torch-version}} | export PYTHONUSERBASE=${{ci.workspace}}/torch-${{matrix.torch-version}} | ||||
| export PNNX_WHEEL_WITHOUT_BUILD=ON | export PNNX_WHEEL_WITHOUT_BUILD=ON | ||||
| cd tools/pnnx | |||||
| cp build/src/pnnx python/pnnx/ | |||||
| cd tools/pnnx/python | |||||
| cp ../build/src/pnnx pnnx/ | |||||
| python3 setup.py install --user | python3 setup.py install --user | ||||
| pytest python/tests/ | |||||
| pytest tests | |||||
| @@ -54,10 +54,9 @@ __pycache__ | |||||
| *.pyd | *.pyd | ||||
| *.egg-info/ | *.egg-info/ | ||||
| python/setup.py | python/setup.py | ||||
| tools/pnnx/python/setup.py | |||||
| # Clangd | # Clangd | ||||
| .cache/ | .cache/ | ||||
| # Xmake | # Xmake | ||||
| .xmake/ | |||||
| .xmake/ | |||||
| @@ -42,7 +42,7 @@ conda install pytorch | |||||
| ``` | ``` | ||||
| 3. install | 3. install | ||||
| ```bash | ```bash | ||||
| cd /pathto/ncnntools/pnnx | |||||
| cd /pathto/ncnntools/pnnx/python | |||||
| python setup.py install | python setup.py install | ||||
| ``` | ``` | ||||
| @@ -61,8 +61,8 @@ python setup.py install | |||||
| ## Tests | ## Tests | ||||
| ```bash | ```bash | ||||
| cd /pathto/ncnn/tools/pnnx | |||||
| pytest python/tests/ | |||||
| cd /pathto/ncnn/tools/pnnx/python | |||||
| pytest tests | |||||
| ``` | ``` | ||||
| ## Usage | ## Usage | ||||
| @@ -13,7 +13,10 @@ | |||||
| # specific language governing permissions and limitations under the License. | # specific language governing permissions and limitations under the License. | ||||
| import os | import os | ||||
| import sys | |||||
| import platform | import platform | ||||
| import subprocess | |||||
| EXEC_DIR_PATH = os.path.dirname(os.path.abspath(__file__)) | EXEC_DIR_PATH = os.path.dirname(os.path.abspath(__file__)) | ||||
| if platform.system() == 'Linux' or platform.system() == "Darwin": | if platform.system() == 'Linux' or platform.system() == "Darwin": | ||||
| EXEC_PATH = EXEC_DIR_PATH + "/pnnx" | EXEC_PATH = EXEC_DIR_PATH + "/pnnx" | ||||
| @@ -31,3 +34,5 @@ try: | |||||
| except: | except: | ||||
| pass | pass | ||||
| def pnnx(): | |||||
| raise SystemExit(subprocess.call([EXEC_PATH] + sys.argv[1:], close_fds=False)) | |||||
| @@ -156,10 +156,11 @@ setup( | |||||
| ], | ], | ||||
| license="BSD-3", | license="BSD-3", | ||||
| python_requires=">=3.7", | python_requires=">=3.7", | ||||
| packages=find_packages("python"), | |||||
| packages=find_packages(), | |||||
| package_data={"pnnx": ["pnnx", "pnnx.exe"]}, | package_data={"pnnx": ["pnnx", "pnnx.exe"]}, | ||||
| package_dir={"": "python"}, | |||||
| package_dir={"": "."}, | |||||
| install_requires=requirements, | install_requires=requirements, | ||||
| ext_modules=[CMakeExtension("pnnx")], | |||||
| ext_modules=None if PNNX_WHEEL_WITHOUT_BUILD == 'ON' else [CMakeExtension("pnnx", "..")], | |||||
| cmdclass={"build_ext": CMakeBuild}, | cmdclass={"build_ext": CMakeBuild}, | ||||
| entry_points={"console_scripts": ["pnnx=pnnx:pnnx"]}, | |||||
| ) | ) | ||||
| @@ -1,45 +0,0 @@ | |||||
| import sys | |||||
| from setuptools import setup, find_packages | |||||
| try: | |||||
| from wheel.bdist_wheel import bdist_wheel as _bdist_wheel | |||||
| class bdist_wheel(_bdist_wheel): | |||||
| def finalize_options(self): | |||||
| _bdist_wheel.finalize_options(self) | |||||
| self.root_is_pure = False | |||||
| except ImportError: | |||||
| bdist_wheel = None | |||||
| if sys.version_info < (3, 0): | |||||
| sys.exit("Sorry, Python < 3.0 is not supported") | |||||
| requirements = ["torch"] | |||||
| setup( | |||||
| name="pnnx", | |||||
| version="${PACKAGE_VERSION}", | |||||
| author="nihui", | |||||
| author_email="nihuini@tencent.com", | |||||
| description="pnnx is an open standard for PyTorch model interoperability.", | |||||
| url="https://github.com/Tencent/ncnn/tree/master/tools/pnnx", | |||||
| classifiers=[ | |||||
| "Programming Language :: C++", | |||||
| "Programming Language :: Python :: 3", | |||||
| "Programming Language :: Python :: 3.7", | |||||
| "Programming Language :: Python :: 3.8", | |||||
| "Programming Language :: Python :: 3.9", | |||||
| "Programming Language :: Python :: 3.10", | |||||
| "Programming Language :: Python :: 3.11", | |||||
| "License :: OSI Approved :: BSD License", | |||||
| "Operating System :: OS Independent", | |||||
| ], | |||||
| license="BSD-3", | |||||
| python_requires=">=3.6", | |||||
| packages=find_packages(), | |||||
| package_dir={"": "."}, | |||||
| package_data={"pnnx": ["pnnx${PYTHON_MODULE_PREFIX}${PYTHON_MODULE_EXTENSION}"]}, | |||||
| install_requires=requirements, | |||||
| cmdclass={"bdist_wheel": bdist_wheel}, | |||||
| ) | |||||