-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsetup.py
103 lines (93 loc) · 4.18 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!python
# -*- coding: UTF-8 -*-
'''
################################################################
# Compiliation file for mpegCoder
# @ FFMpeg encoder and decoder.
# Yuchen Jin @ cainmagi@gmail.com
# Requirements: (Pay attention to version)
# python 3.3+
# urllib3 1.26.2+
# This script is used for compiling the core module of the
# mpegCoder.
################################################################
'''
import os
import re
import sysconfig
try:
from setuptools import setup, Extension
except ImportError:
from distutils.core import setup, Extension
import find_libpython
import numpy as np
try:
import webtools
HAS_WEBTOOLS=True
except ImportError:
HAS_WEBTOOLS=False
BASE_SRC_DIR = 'MpegCoder'
FFMPEG_DIR = './dependencies'
PYTHON_INC_DIR = sysconfig.get_path('include') # /usr/include/python3.x
NUMPY_DIR = os.path.join(os.path.dirname(np.__file__), 'core') # '/usr/local/lib/python3.x/dist-packages/numpy/core'
PYTHON_LIB_PATH = find_libpython.find_libpython()
PYTHON_LIB_DIR = os.path.dirname(PYTHON_LIB_PATH) # '/usr/lib/python3.x/config-3.xm-x86_64-linux-gnu'
PYTHON_LIB_NAME = re.search(R'(?:lib|)(python3\.(?:.+?))\..*?', os.path.basename(PYTHON_LIB_PATH)).groups(1)[0]
TARGET='mpegCoder'
with open('README.md', 'r') as fh:
LONG_DESCRIPTION = fh.read()
if (not os.path.isdir(os.path.join(FFMPEG_DIR, 'include'))) or (not os.path.isdir(os.path.join(FFMPEG_DIR, 'lib'))):
if HAS_WEBTOOLS:
print('The FFMpeg dependencies are not found. Fetch the files online...')
webtools.download_tarball('cainmagi', 'FFmpeg-Encoder-Decoder-for-Python', 'deps-3.2.0', 'dep-linux-ffmpeg_5_0.tar.xz', path=os.path.join('.', 'dependencies'), mode='auto', verbose=True, token='')
else:
raise FileNotFoundError('The required dependencies ("include" and "lib" directories) are not found in FFMPEG_DIR path ({0})'.format(FFMPEG_DIR))
module_mpegCoder = Extension(
name = TARGET,
language = 'c++',
define_macros = [('MAJOR_VERSION', '3'),
('MINOR_VERSION', '2'),
('BUILD_VERSION', '0')],
extra_compile_args = ['-std=c++11','-pthread'],
include_dirs = [PYTHON_INC_DIR, np.get_include(), '{0}/include'.format(FFMPEG_DIR), BASE_SRC_DIR],
#libraries = [PYTHON_LIB_NAME, 'avcodec', 'avdevice', 'avfilter', 'avformat', 'avutil', 'postproc', 'swresample', 'swscale', 'npymath'],
libraries = [PYTHON_LIB_NAME, 'avcodec', 'avformat', 'avutil', 'swresample', 'swscale', 'npymath'],
library_dirs = [PYTHON_LIB_DIR, '{0}/lib'.format(NUMPY_DIR), '{0}/lib'.format(FFMPEG_DIR)],
sources = [
'{0}/MpegBase.cpp'.format(BASE_SRC_DIR),
'{0}/MpegCoder.cpp'.format(BASE_SRC_DIR),
'{0}/MpegStreamer.cpp'.format(BASE_SRC_DIR),
'{0}/dllmain.cpp'.format(BASE_SRC_DIR)
]
)
setup(
name = 'mpegCoder',
version = '3.2.0',
description = 'A FFmpeg module which could provide a class for encoding, decoding, or streaming a video in any format.',
author = 'Yuchen Jin',
author_email = 'cainmagi@gmail.com',
url = 'https://github.com/cainmagi/FFmpeg-Encoder-Decoder-for-Python',
project_urls={
'Tracker': 'https://github.com/cainmagi/FFmpeg-Encoder-Decoder-for-Python/issues',
},
long_description=LONG_DESCRIPTION,
long_description_content_type='text/markdown',
classifiers=[
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Operating System :: POSIX :: Linux',
'Topic :: Software Development :: Libraries :: Python Modules'
],
keywords=[
'python', 'h264', 'video', 'rtsp', 'ffmpeg', 'rtmp', 'encoder', 'numpy', 'python3', 'python3-library', 'ffmpeg-wrapper', 'video-stream', 'python-c-api', 'rtsp-push', 'rtmp-push', 'rtsp-player', 'rtmp-player', 'ffmpeg-encoder'
],
python_requires='>=3.6,<3.11',
license='GPLv3',
ext_modules = [module_mpegCoder]
)