Improve setup.py
* Now setup.py don't import googletrans.__init__.py wchich import requests, and this occure ImportError during installation of library. * Changes with getting version in setup.py without importing googletrans.__init__.py Now you can install py-googletrans on clean virtualenv, without earlier install dependencies.
This commit is contained in:
parent
ae4953dff9
commit
b670db30ec
@ -1,7 +1,6 @@
|
|||||||
"""Free Google Translate API for Python. Translates totally free of charge."""
|
"""Free Google Translate API for Python. Translates totally free of charge."""
|
||||||
__all__ = 'Translator',
|
__all__ = 'Translator',
|
||||||
__version_info__ = 2, 1, 2
|
__version__ = '2.1.2'
|
||||||
__version__ = '.'.join(str(v) for v in __version_info__)
|
|
||||||
|
|
||||||
|
|
||||||
from googletrans.client import Translator
|
from googletrans.client import Translator
|
||||||
|
31
setup.py
31
setup.py
@ -1,12 +1,13 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import googletrans
|
|
||||||
import os.path
|
import os.path
|
||||||
|
import re
|
||||||
|
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
|
|
||||||
def readme():
|
def get_file(*paths):
|
||||||
path = os.path.join(os.path.dirname(__file__), 'README.rst')
|
path = os.path.join(*paths)
|
||||||
try:
|
try:
|
||||||
with open(path, 'rb') as f:
|
with open(path, 'rb') as f:
|
||||||
return f.read().decode('utf8')
|
return f.read().decode('utf8')
|
||||||
@ -14,12 +15,30 @@ def readme():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def get_version():
|
||||||
|
init_py = get_file(os.path.dirname(__file__), 'googletrans', '__init__.py')
|
||||||
|
pattern = r"{0}\W*=\W*'([^']+)'".format('__version__')
|
||||||
|
version, = re.findall(pattern, init_py)
|
||||||
|
return version
|
||||||
|
|
||||||
|
|
||||||
|
def get_description():
|
||||||
|
init_py = get_file(os.path.dirname(__file__), 'googletrans', '__init__.py')
|
||||||
|
pattern = r'"""(.*?)"""'
|
||||||
|
description, = re.findall(pattern, init_py, re.DOTALL)
|
||||||
|
return description
|
||||||
|
|
||||||
|
|
||||||
|
def get_readme():
|
||||||
|
return get_file(os.path.dirname(__file__), 'README.rst')
|
||||||
|
|
||||||
|
|
||||||
def install():
|
def install():
|
||||||
setup(
|
setup(
|
||||||
name='googletrans',
|
name='googletrans',
|
||||||
version=googletrans.__version__,
|
version=get_version(),
|
||||||
description=googletrans.__doc__,
|
description=get_description(),
|
||||||
long_description=readme(),
|
long_description=get_readme(),
|
||||||
license='MIT',
|
license='MIT',
|
||||||
author='SuHun Han',
|
author='SuHun Han',
|
||||||
author_email='ssut' '@' 'ssut.me',
|
author_email='ssut' '@' 'ssut.me',
|
||||||
|
Loading…
Reference in New Issue
Block a user