Change setup.py to extract version without importing.
This commit is contained in:
20
setup.py
20
setup.py
@@ -17,11 +17,27 @@ limitations under the License.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
import codecs
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
from teeth_agent import agent
|
here = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
|
||||||
|
def read(*parts):
|
||||||
|
return codecs.open(os.path.join(here, *parts), 'r').read()
|
||||||
|
|
||||||
|
|
||||||
|
def find_version(*file_paths):
|
||||||
|
version_file = read(*file_paths)
|
||||||
|
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
|
||||||
|
version_file, re.M)
|
||||||
|
if version_match:
|
||||||
|
return version_match.group(1)
|
||||||
|
raise RuntimeError("Unable to find version string.")
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='teeth-agent',
|
name='teeth-agent',
|
||||||
version=agent.AGENT_VERSION,
|
version=find_version('teeth_agent', '__init__.py'),
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
)
|
)
|
||||||
|
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
__all__ = ["__version__"]
|
||||||
|
|
||||||
|
__version__ = "0.1-dev"
|
||||||
|
Reference in New Issue
Block a user