Skip to content

Commit

Permalink
build universal pnnx wheel and pnnx entrypoint script (#5331)
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui authored Feb 4, 2024
1 parent f5b55c6 commit f03c8f9
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 56 deletions.
6 changes: 3 additions & 3 deletions .ci/pnnx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ jobs:
run: |
export PYTHONUSERBASE=${{ci.workspace}}/torch-${{matrix.torch-version}}
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
pytest python/tests/
pytest tests
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ __pycache__
*.pyd
*.egg-info/
python/setup.py
tools/pnnx/python/setup.py

# Clangd
.cache/

# Xmake
.xmake/
.xmake/
6 changes: 3 additions & 3 deletions tools/pnnx/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ conda install pytorch
```
3. install
```bash
cd /pathto/ncnntools/pnnx
cd /pathto/ncnntools/pnnx/python
python setup.py install
```

Expand All @@ -61,8 +61,8 @@ python setup.py install
## Tests
```bash
cd /pathto/ncnn/tools/pnnx
pytest python/tests/
cd /pathto/ncnn/tools/pnnx/python
pytest tests
```
## Usage
Expand Down
5 changes: 5 additions & 0 deletions tools/pnnx/python/pnnx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
# specific language governing permissions and limitations under the License.

import os
import sys
import platform
import subprocess

EXEC_DIR_PATH = os.path.dirname(os.path.abspath(__file__))
if platform.system() == 'Linux' or platform.system() == "Darwin":
EXEC_PATH = EXEC_DIR_PATH + "/pnnx"
Expand All @@ -31,3 +34,5 @@
except:
pass

def pnnx():
raise SystemExit(subprocess.call([EXEC_PATH] + sys.argv[1:], close_fds=False))
7 changes: 4 additions & 3 deletions tools/pnnx/setup.py → tools/pnnx/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ def build_extension(self, ext):
],
license="BSD-3",
python_requires=">=3.7",
packages=find_packages("python"),
packages=find_packages(),
package_data={"pnnx": ["pnnx", "pnnx.exe"]},
package_dir={"": "python"},
package_dir={"": "."},
install_requires=requirements,
ext_modules=[CMakeExtension("pnnx")],
ext_modules=None if PNNX_WHEEL_WITHOUT_BUILD == 'ON' else [CMakeExtension("pnnx", "..")],
cmdclass={"build_ext": CMakeBuild},
entry_points={"console_scripts": ["pnnx=pnnx:pnnx"]},
)
45 changes: 0 additions & 45 deletions tools/pnnx/python/setup.py.i

This file was deleted.

0 comments on commit f03c8f9

Please sign in to comment.