提交 2da42cdf authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Use versioneer.

上级 f39edc12
theano/_version.py export-subst
...@@ -11,3 +11,5 @@ include bin/theano-cache ...@@ -11,3 +11,5 @@ include bin/theano-cache
include bin/theano-nose include bin/theano-nose
prune .jenkins prune .jenkins
prune .travis prune .travis
include versioneer.py
include theano/_version.py
...@@ -5,8 +5,7 @@ package: ...@@ -5,8 +5,7 @@ package:
version: {{ version }} version: {{ version }}
source: source:
git_url: https://github.com/Theano/Theano.git path: ../
git_tag: rel-{{ version }}
build: build:
noarch: python noarch: python
...@@ -14,15 +13,12 @@ build: ...@@ -14,15 +13,12 @@ build:
requirements: requirements:
build: build:
- m2-filesystem [win]
- m2-git [win]
- git [not win]
- python - python
- setuptools - setuptools
- six >=1.9.0 - six >=1.9.0
- numpy >=1.9.1 - numpy >=1.9.1
- scipy >=0.14.0 - scipy >=0.14.0
- pygpu >=0.6,<0.7 - pygpu >=0.7
run: run:
- python - python
- mkl-service - mkl-service
...@@ -31,7 +27,7 @@ requirements: ...@@ -31,7 +27,7 @@ requirements:
- six >=1.9.0 - six >=1.9.0
- numpy >=1.9.1 - numpy >=1.9.1
- scipy >=0.14.0 - scipy >=0.14.0
- pygpu >=0.6,<0.7 - {{ pin_compatible('pygpu', '0.7', max_pin='0.8') }}
test: test:
requires: requires:
......
...@@ -4,3 +4,15 @@ nocapture=1 ...@@ -4,3 +4,15 @@ nocapture=1
[flake8] [flake8]
ignore=E501,E123,E133,FI12,FI14,FI15,FI50,FI51,FI53 ignore=E501,E123,E133,FI12,FI14,FI15,FI50,FI51,FI53
# See the docstring in versioneer.py for instructions. Note that you must
# re-run 'versioneer.py setup' after changing this section, and commit the
# resulting files.
[versioneer]
VCS = git
style = pep440
versionfile_source = theano/_version.py
versionfile_build = theano/_version.py
tag_prefix = rel-
#parentdir_prefix =
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
from __future__ import absolute_import, print_function, division from __future__ import absolute_import, print_function, division
import os import os
import subprocess
import codecs import codecs
from fnmatch import fnmatchcase from fnmatch import fnmatchcase
from distutils.util import convert_path from distutils.util import convert_path
...@@ -15,6 +14,8 @@ try: ...@@ -15,6 +14,8 @@ try:
except ImportError: except ImportError:
from distutils.core import setup from distutils.core import setup
import versioneer
CLASSIFIERS = """\ CLASSIFIERS = """\
Development Status :: 4 - Beta Development Status :: 4 - Beta
...@@ -50,13 +51,6 @@ CLASSIFIERS = [_f for _f in CLASSIFIERS.split('\n') if _f] ...@@ -50,13 +51,6 @@ CLASSIFIERS = [_f for _f in CLASSIFIERS.split('\n') if _f]
AUTHOR = "LISA laboratory, University of Montreal" AUTHOR = "LISA laboratory, University of Montreal"
AUTHOR_EMAIL = "theano-dev@googlegroups.com" AUTHOR_EMAIL = "theano-dev@googlegroups.com"
PLATFORMS = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"] PLATFORMS = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"]
MAJOR = 0
MINOR = 10
MICRO = 0
SUFFIX = "beta2" # Should be blank except for rc's, betas, etc.
ISRELEASED = False
VERSION = '%d.%d.%d%s' % (MAJOR, MINOR, MICRO, SUFFIX)
def find_packages(where='.', exclude=()): def find_packages(where='.', exclude=()):
...@@ -67,91 +61,17 @@ def find_packages(where='.', exclude=()): ...@@ -67,91 +61,17 @@ def find_packages(where='.', exclude=()):
for name in os.listdir(where): for name in os.listdir(where):
fn = os.path.join(where, name) fn = os.path.join(where, name)
if ('.' not in name and os.path.isdir(fn) and if ('.' not in name and os.path.isdir(fn) and
os.path.isfile(os.path.join(fn, '__init__.py')) os.path.isfile(os.path.join(fn, '__init__.py'))):
): out.append(prefix + name)
out.append(prefix+name) stack.append((fn, prefix + name + '.'))
stack.append((fn, prefix+name+'.'))
for pat in list(exclude) + ['ez_setup', 'distribute_setup']: for pat in list(exclude) + ['ez_setup', 'distribute_setup']:
out = [item for item in out if not fnmatchcase(item, pat)] out = [item for item in out if not fnmatchcase(item, pat)]
return out return out
def git_version():
"""
Return the sha1 of local git HEAD as a string.
"""
# josharian: I doubt that the minimal environment stuff here is
# still needed; it is inherited. This was originally
# an hg_version function borrowed from NumPy's setup.py.
# I'm leaving it in for now because I don't have enough other
# environments to test in to be confident that it is safe to remove.
def _minimal_ext_cmd(cmd):
# construct minimal environment
env = {}
for k in ['SYSTEMROOT', 'PATH', 'PYTHONPATH']:
v = os.environ.get(k)
if v is not None:
env[k] = v
# LANGUAGE is used on win32
env['LANGUAGE'] = 'C'
env['LANG'] = 'C'
env['LC_ALL'] = 'C'
out = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
env=env
).communicate()[0]
return out
try:
out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
git_revision = out.strip().decode('ascii')
except OSError:
git_revision = "unknown-git"
return git_revision
def write_text(filename, text):
try:
with open(filename, 'w') as a:
a.write(text)
except Exception as e:
print(e)
def write_version_py(filename=os.path.join('theano', 'generated_version.py')):
cnt = """
# THIS FILE IS GENERATED FROM THEANO SETUP.PY
short_version = '%(version)s'
version = '%(version)s'
git_revision = '%(git_revision)s'
full_version = '%(version)s.dev-%%(git_revision)s' %% {
'git_revision': git_revision}
release = %(isrelease)s
if not release:
version = full_version
"""
FULL_VERSION = VERSION
if os.path.isdir('.git'):
GIT_REVISION = git_version()
elif os.path.exists(filename):
# must be a source distribution, use existing version file
GIT_REVISION = "RELEASE"
else:
GIT_REVISION = "unknown-git"
FULL_VERSION += '.dev-' + GIT_REVISION
text = cnt % {'version': VERSION,
'full_version': FULL_VERSION,
'git_revision': GIT_REVISION,
'isrelease': str(ISRELEASED)}
write_text(filename, text)
def do_setup(): def do_setup():
write_version_py()
setup(name=NAME, setup(name=NAME,
version=VERSION, version=versioneer.get_version(),
description=DESCRIPTION, description=DESCRIPTION,
long_description=LONG_DESCRIPTION, long_description=LONG_DESCRIPTION,
classifiers=CLASSIFIERS, classifiers=CLASSIFIERS,
...@@ -161,6 +81,7 @@ def do_setup(): ...@@ -161,6 +81,7 @@ def do_setup():
license=LICENSE, license=LICENSE,
platforms=PLATFORMS, platforms=PLATFORMS,
packages=find_packages(), packages=find_packages(),
cmdclass=versioneer.get_cmdclass(),
install_requires=['numpy>=1.9.1', 'scipy>=0.14', 'six>=1.9.0'], install_requires=['numpy>=1.9.1', 'scipy>=0.14', 'six>=1.9.0'],
# pygments is a dependency for Sphinx code highlight # pygments is a dependency for Sphinx code highlight
extras_require={ extras_require={
......
...@@ -245,3 +245,7 @@ def sparse_grad(var): ...@@ -245,3 +245,7 @@ def sparse_grad(var):
__import__('theano.tensor.shared_randomstreams') __import__('theano.tensor.shared_randomstreams')
from ._version import get_versions
__version__ = get_versions()['version']
del get_versions
差异被折叠。
from __future__ import absolute_import, print_function, division from __future__ import absolute_import, print_function, division
from theano._version import get_versions
info = get_versions()
full_version = info['version']
git_revision = info['full-revisionid']
del info, get_versions
short_version = full_version.split('+')[0]
# This tries to catch a tag like beta2, rc1, ...
try: try:
from theano.generated_version import * # noqa int(short_version.split('.')[2])
except ImportError: release = True
short_version = 'unknown' except ValueError:
version = 'unknown'
git_revision = 'unknown'
full_version = 'unknown'
release = False release = False
if release:
version = short_version
else:
version = full_version
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论