Browse Source

upload wheel to pypi (#2633) (#2638)

Co-authored-by: Cai Shanli <caishanli25@gmail.com>
tags/20210322
nihui GitHub 5 years ago
parent
commit
329e2eeae8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 17 deletions
  1. +12
    -3
      .github/workflows/windows-x64-cpu-vs2019-python.yml
  2. +1
    -1
      python/CMakeLists.txt
  3. +34
    -13
      python/setup.py.i

+ 12
- 3
.github/workflows/windows-x64-cpu-vs2019-python.yml View File

@@ -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/*

+ 1
- 1
python/CMakeLists.txt View File

@@ -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 )


+ 34
- 13
python/setup.py.i View File

@@ -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},
)

Loading…
Cancel
Save