diff --git a/paddleaudio/__init__.py b/paddleaudio/__init__.py index 8676cfe33d7215efc365db1c9a686a1965397058..2685cf57c600b5931f17f5257a9443796662b916 100644 --- a/paddleaudio/__init__.py +++ b/paddleaudio/__init__.py @@ -13,11 +13,3 @@ # limitations under the License. from .backends import * from .features import * - -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 fb855d010586c59a14ddc1d1f5df78a94c9db8bf..185a92b8d94d3426d616c0624f0f2ee04339349e 100644 --- a/paddlespeech/__init__.py +++ b/paddlespeech/__init__.py @@ -11,10 +11,3 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -try: - from .version import full_version as __version__ -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" - ) diff --git a/setup.py b/setup.py index 75870003e7703f39cafe58b3028cbaa39493c402..5c6a9e49c559cadf4ceb67e3c83a55cefdb7d929 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ from setuptools.command.install import install HERE = Path(os.path.abspath(os.path.dirname(__file__))) -PADDLESPEECH_VERSION = '0.1.1' +VERSION = '0.1.1' requirements = { "install": [ @@ -84,13 +84,12 @@ requirements = { } -def write_version_py(filename='paddlespeech/version.py'): - ver_str = """# THIS FILE IS GENERATED FROM PADDLESPEECH SETUP.PY -# -full_version = '%(version)s' -""" - with open(filename, 'w') as f: - f.write(ver_str % {'version': PADDLESPEECH_VERSION}) +def write_version_py(filename='paddlespeech/__init__.py'): + import paddlespeech + if hasattr(paddlespeech, "__version__") and paddlespeech.__version__ == VERSION: + return + with open(filename, "a") as f: + f.write(f"\n__version__ = '{VERSION}'\n") @contextlib.contextmanager @@ -185,7 +184,7 @@ write_version_py() setup_info = dict( # Metadata name='paddlespeech', - version=PADDLESPEECH_VERSION, + version=VERSION, author='PaddlePaddle Speech and Language Team', author_email='paddlesl@baidu.com', url='https://github.com/PaddlePaddle/PaddleSpeech', diff --git a/setup_audio.py b/setup_audio.py index a0c15ae02724f41beba2452e348669caacec1ab5..d6e9e892a616ef01f66c84b4b90cf412d3f7c7e1 100644 --- a/setup_audio.py +++ b/setup_audio.py @@ -14,23 +14,22 @@ import setuptools # set the version here -PADDLEAUDIO_VERSION = '0.1.0' +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}) +def write_version_py(filename='paddleaudio/__init__.py'): + import paddleaudio + if hasattr(paddleaudio, "__version__") and paddleaudio.__version__ == VERSION: + return + with open(filename, "a") as f: + f.write(f"\n__version__ = '{VERSION}'\n") write_version_py() setuptools.setup( name="paddleaudio", - version=PADDLEAUDIO_VERSION, + version=VERSION, author="", author_email="", description="PaddleAudio, in development",