From 565a63c5ef766e8e2c4a8034855157955c2f7c50 Mon Sep 17 00:00:00 2001 From: huangyuxin Date: Tue, 18 Jan 2022 02:18:41 +0000 Subject: [PATCH] refactor the setup in paddleaudio --- paddleaudio/__init__.py | 8 +++++++- paddlespeech/__init__.py | 2 +- setup.py | 2 +- setup_audio.py | 18 ++++++++++++++---- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/paddleaudio/__init__.py b/paddleaudio/__init__.py index b717777d..8676cfe3 100644 --- a/paddleaudio/__init__.py +++ b/paddleaudio/__init__.py @@ -14,4 +14,10 @@ from .backends import * from .features import * -__version__ = '0.1.0' +try: + from .version import full_version as __version__ +except ImportError: + import sys + sys.stderr.write( + "Warning: import paddlaudio from source directory without installing, run 'python setup_audio.py install' to install paddlespeech firstly\n" + ) diff --git a/paddlespeech/__init__.py b/paddlespeech/__init__.py index 135ec218..fb855d01 100644 --- a/paddlespeech/__init__.py +++ b/paddlespeech/__init__.py @@ -16,5 +16,5 @@ try: except ImportError: import sys sys.stderr.write( - "Warning: import paddlespeech from source directory without installing, run 'python setup.py install' to install paddlespeech firstly\n" + "Warning: import paddlespeech from source directory without installing, run 'python setup.py install' to install paddlespeech firstly.\n" ) diff --git a/setup.py b/setup.py index bc923683..75870003 100644 --- a/setup.py +++ b/setup.py @@ -85,7 +85,7 @@ requirements = { def write_version_py(filename='paddlespeech/version.py'): - ver_str = """# THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY + ver_str = """# THIS FILE IS GENERATED FROM PADDLESPEECH SETUP.PY # full_version = '%(version)s' """ diff --git a/setup_audio.py b/setup_audio.py index 5f014065..a0c15ae0 100644 --- a/setup_audio.py +++ b/setup_audio.py @@ -13,14 +13,24 @@ # limitations under the License. import setuptools -import paddleaudio - # set the version here -version = paddleaudio.__version__ +PADDLEAUDIO_VERSION = '0.1.0' + + +def write_version_py(filename='paddleaudio/version.py'): + ver_str = """# THIS FILE IS GENERATED FROM SETUP_AUDIO.PY +# +full_version = '%(version)s' +""" + with open(filename, 'w') as f: + f.write(ver_str % {'version': PADDLEAUDIO_VERSION}) + + +write_version_py() setuptools.setup( name="paddleaudio", - version=version, + version=PADDLEAUDIO_VERSION, author="", author_email="", description="PaddleAudio, in development", -- GitLab