Skip to content

Commit 1b05008

Browse files
committed
fixed
1 parent 0e17359 commit 1b05008

File tree

6 files changed

+43
-43
lines changed

6 files changed

+43
-43
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ out
44
dist
55
build
66
pynvjpeg.egg-info
7-
pynvjpeg
7+
pynvjpeg
8+
MANIFEST

Makefile

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,41 @@ ifndef PYTHON_BIN
1515
PYTHON_BIN=python${PYTHON_VERSION}
1616
endif
1717

18-
ifndef PYTHON_INCLUDE_PATH
19-
PYTHON_INCLUDE_PATH=/usr/include/python${PYTHON_VERSION}
20-
endif
18+
# ifndef PYTHON_INCLUDE_PATH
19+
# PYTHON_INCLUDE_PATH=/usr/include/python${PYTHON_VERSION}
20+
# endif
2121

22-
ifndef PYTHON_LIB_PATH
23-
PYTHON_LIB_PATH=$(shell ldconfig -p | grep python${PYTHON_VERSION} | head -n 1 | xargs dirname | tail -n 1)
24-
endif
22+
# ifndef PYTHON_LIB_PATH
23+
# PYTHON_LIB_PATH=$(shell ldconfig -p | grep python${PYTHON_VERSION} | head -n 1 | xargs dirname | tail -n 1)
24+
# endif
2525

26-
ifndef PYTHON_DYNLOAD_PATH
27-
PYTHON_DYNLOAD_PATH=$(shell ${PYTHON_BIN} -c "import sys; print(list(filter(lambda x: 'lib-dynload' in x, sys.path))[0])")
28-
endif
26+
# ifndef PYTHON_DYNLOAD_PATH
27+
# PYTHON_DYNLOAD_PATH=$(shell ${PYTHON_BIN} -c "import sys; print(list(filter(lambda x: 'lib-dynload' in x, sys.path))[0])")
28+
# endif
2929

30-
PYTHON_LIB_NAME=$(shell ${PYTHON_BIN} -c "import sys; print('nvjpeg.cpython-%d%dm' % (sys.version_info.major, sys.version_info.minor,))")-x86_64-linux-gnu.so
30+
# PYTHON_LIB_NAME=$(shell ${PYTHON_BIN} -c "import sys; print('nvjpeg.cpython-%d%dm' % (sys.version_info.major, sys.version_info.minor,))")-x86_64-linux-gnu.so
3131

32-
all: out/nvjpeg-test out/${PYTHON_LIB_NAME}
32+
# all: out/nvjpeg-test out/${PYTHON_LIB_NAME}
33+
all: out/nvjpeg-test python-interface
3334
out:
3435
mkdir out
3536

3637
out/nvjpeg-test.o: out nvjpeg-python.c
37-
gcc -o out/nvjpeg-test.o -c nvjpeg-python.c -I${CUDA_PATH}/include -I${PYTHON_INCLUDE_PATH} -D BUILD_TEST ${CFLAGS}
38+
gcc -o out/nvjpeg-test.o -c nvjpeg-python.c -I${CUDA_PATH}/include -D BUILD_TEST ${CFLAGS}
3839

3940
out/nvjpeg-test: out/nvjpeg-test.o
40-
gcc -o out/nvjpeg-test out/nvjpeg-test.o -L${CUDA_PATH}/lib64 -lnvjpeg -lcudart -L${PYTHON_LIB_PATH} -lpython${PYTHON_VERSION}m ${CFLAGS}
41+
gcc -o out/nvjpeg-test out/nvjpeg-test.o -L${CUDA_PATH}/lib64 -lnvjpeg -lcudart ${CFLAGS}
4142

42-
out/nvjpeg-python.o: out nvjpeg-python.c
43-
gcc -fPIC -o out/nvjpeg-python.o -c nvjpeg-python.c -I${CUDA_PATH}/include -I${PYTHON_INCLUDE_PATH} ${CFLAGS}
43+
# out/nvjpeg-python.o: out nvjpeg-python.c
44+
# gcc -fPIC -o out/nvjpeg-python.o -c nvjpeg-python.c -I${CUDA_PATH}/include -I${PYTHON_INCLUDE_PATH} ${CFLAGS}
4445

45-
out/${PYTHON_LIB_NAME}: out/nvjpeg-python.o
46-
gcc --shared -fPIC -o out/${PYTHON_LIB_NAME} out/nvjpeg-python.o -L${CUDA_PATH}/lib64 -lnvjpeg -lcudart -L${PYTHON_LIB_PATH} -lpython${PYTHON_VERSION}m ${CFLAGS}
47-
mkdir -p pynvjpeg/lib
48-
cp -f out/${PYTHON_LIB_NAME} pynvjpeg/lib/${PYTHON_LIB_NAME}
46+
# out/${PYTHON_LIB_NAME}: out/nvjpeg-python.o
47+
# gcc --shared -fPIC -o out/${PYTHON_LIB_NAME} out/nvjpeg-python.o -L${CUDA_PATH}/lib64 -lnvjpeg -lcudart -L${PYTHON_LIB_PATH} -lpython${PYTHON_VERSION}m ${CFLAGS}
48+
python-interface:
49+
${PYTHON_BIN} setup.py build_ext
4950

5051
clean:
51-
rm -Rf out dist build out pynvjpeg.egg-info
52+
rm -Rf out build dist pynvjpeg.egg-info
5253

5354
# install: out/${PYTHON_LIB_NAME}
5455
# cp -f out/${PYTHON_LIB_NAME} ${PYTHON_DYNLOAD_PATH}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ make install
2222
```python
2323
#!/usr/bin/env python3
2424

25-
from pynvjpeg import NvJpeg
25+
from nvjpeg import NvJpeg
2626

2727
# read file
2828
fp = open("input-image.jpg", "rb")

nvjpeg-python.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
#include <malloc.h>
44
#include <sys/stat.h>
55
#include <sys/types.h>
6+
7+
#ifndef BUILD_TEST
68
#include <Python.h>
79
#include <structmember.h>
8-
910
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
1011
#include <numpy/arrayobject.h>
11-
12+
#endif
1213

1314
typedef struct
1415
{
@@ -241,7 +242,7 @@ int main(int args, char** argv){
241242
return 0;
242243
}
243244

244-
#endif
245+
#else
245246

246247
typedef struct
247248
{
@@ -404,3 +405,5 @@ PyInit_nvjpeg(void) {
404405
return pReturn;
405406
}
406407

408+
409+
#endif

setup.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1-
#!/usr/bin/env python3
2-
import setuptools
1+
#!/usr/bin/env python
32
import sys
43
import os
54
import glob
6-
7-
pwd = os.path.abspath(os.path.dirname(__file__))
8-
os.system("cd '%s'; make" % (pwd,))
5+
from setuptools import setup, find_packages, Extension
96

107
with open("README.md", "r", encoding="utf-8") as fh:
118
long_description = fh.read()
129

13-
setuptools.setup(
14-
name="pynvjpeg",
15-
version="0.0.1",
10+
from distutils.core import setup, Extension
11+
setup(name='pynvjpeg',
12+
version='0.0.2',
13+
ext_modules=[Extension('nvjpeg', ['nvjpeg-python.c'])],
1614
author="Usingnet",
17-
author_email="zengqinghui@usingnet.com",
15+
author_email="developer@usingnet.com",
1816
license="MIT",
1917
description="nvjpeg for python",
2018
long_description=long_description,
2119
long_description_content_type="text/markdown",
2220
url="https://github.com/UsingNet/nvjpeg-python",
23-
packages=setuptools.find_packages(),
21+
# packages=setuptools.find_packages(),
2422
classifiers=[
2523
"Development Status :: 4 - Beta",
2624
"Programming Language :: Python :: 3 :: Only",
@@ -35,10 +33,5 @@
3533
'Source': 'https://github.com/UsingNet/nvjpeg-python',
3634
'Tracker': 'https://github.com/UsingNet/nvjpeg-python/issues',
3735
},
38-
data_files=[
39-
('', ['nvjpeg-python.c', 'Makefile']),
40-
('pynvjpeg/lib', glob.glob('%s/pynvjpeg/lib/*.so' % pwd))
41-
],
42-
install_requires=['numpy']
36+
install_requires=['numpy>=1.17']
4337
)
44-

tests/test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
import os
55
import numpy as np
66
import cv2
7+
import glob
78

8-
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
9+
for lib in glob.glob(os.path.join(os.path.dirname(__file__), "../build/lib.*")):
10+
sys.path.append(lib)
911

10-
from pynvjpeg import NvJpeg
12+
from nvjpeg import NvJpeg
1113

1214
fp = open(os.path.join(os.path.dirname(__file__), "test.jpg"), "rb")
1315
img = fp.read()

0 commit comments

Comments
 (0)