diff --git a/.github/workflows/windows-x64-cpu-vs2019-python.yml b/.github/workflows/windows-x64-cpu-vs2019-python.yml index 834dfe8a3..802f235e9 100644 --- a/.github/workflows/windows-x64-cpu-vs2019-python.yml +++ b/.github/workflows/windows-x64-cpu-vs2019-python.yml @@ -5,7 +5,7 @@ jobs: runs-on: windows-latest strategy: matrix: - python-version: [3.5, 3.6, 3.7, 3.8] + python-version: [3.5, 3.6, 3.7, 3.8, 3.9] steps: - name: cancel-previous-runs uses: styfle/cancel-workflow-action@0.7.0 @@ -21,7 +21,7 @@ jobs: - name: install dependencies run: | python -m pip install --upgrade pip - pip install pytest + pip install pytest setuptools wheel twine - name: cache-protobuf id: cache-protobuf uses: actions/cache@v1 @@ -40,9 +40,18 @@ jobs: - name: build run: | mkdir build; cd build - cmake -DProtobuf_INCLUDE_DIR="$env:GITHUB_WORKSPACE\protobuf-install\include" -DProtobuf_LIBRARIES="$env:GITHUB_WORKSPACE\protobuf-install\lib\libprotobuf.lib" -DProtobuf_PROTOC_EXECUTABLE="$env:GITHUB_WORKSPACE\protobuf-install\bin\protoc.exe" -DNCNN_PYTHON=ON .. + cmake -DProtobuf_INCLUDE_DIR="$env:GITHUB_WORKSPACE\protobuf-install\include" -DProtobuf_LIBRARIES="$env:GITHUB_WORKSPACE\protobuf-install\lib\libprotobuf.lib" -DProtobuf_PROTOC_EXECUTABLE="$env:GITHUB_WORKSPACE\protobuf-install\bin\protoc.exe" -DNCNN_PYTHON=ON -DNCNN_BUILD_BENCHMARK=OFF -DNCNN_BUILD_EXAMPLES=OFF -DNCNN_BUILD_TOOLS=OFF .. cmake --build . --config Release -j 2 - name: install python run: cd python && pip install . - name: test run: cd python && pytest tests + - name: build and publish + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} + TWINE_REPOSITORY_URL: "https://test.pypi.org/legacy/" + run: | + cd python + python setup.py bdist_wheel + twine upload dist/* \ No newline at end of file diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index e6d2bbb40..8566bc2cd 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.4) project(pyncnn) -set(PACKAGE_VERSION "0.0.2") +set(PACKAGE_VERSION ${NCNN_VERSION_STRING}) add_definitions(-DVERSION_INFO="${PACKAGE_VERSION}") set( CMAKE_CXX_STANDARD 11 ) diff --git a/python/setup.py.i b/python/setup.py.i index 7bcd2cf5e..962c0935c 100644 --- a/python/setup.py.i +++ b/python/setup.py.i @@ -2,22 +2,43 @@ from setuptools import setup, find_packages import sys if sys.version_info < (3,0): - sys.exit('Sorry, Python < 3.0 is not supported') + sys.exit("Sorry, Python < 3.0 is not supported") + +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 requirements = [ - 'numpy', - #'tqdm', - #'requests', - #'portalocker', - #'opencv-python' + "numpy", + #"tqdm", + #"requests", + #"portalocker", + #"opencv-python" ] setup( - name = 'ncnn', - version = '${PACKAGE_VERSION}', - url = 'https://github.com/Tencent/ncnn', - packages = find_packages(), - package_dir = {'': '.'}, - package_data = {'ncnn': ['ncnn${PYTHON_MODULE_PREFIX}${PYTHON_MODULE_EXTENSION}']}, - install_requires = requirements + name = "ncnn", + version = "${PACKAGE_VERSION}", + author = "nihui", + author_email = "nihuini@tencent.com", + maintainer = "caishanli", + maintainer_email = "caishanli25@gmail.com", + description = "ncnn is a high-performance neural network inference framework optimized for the mobile platform", + url = "https://github.com/Tencent/ncnn", + classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + ], + python_requires = ">=3.5", + packages = find_packages(), + package_dir = {"": "."}, + package_data = {"ncnn": ["ncnn${PYTHON_MODULE_PREFIX}${PYTHON_MODULE_EXTENSION}"]}, + install_requires = requirements, + cmdclass = {"bdist_wheel": bdist_wheel}, )