Commit 4705325b authored by Fabrice  ALLAIN's avatar Fabrice ALLAIN
Browse files

Moved get_version function

parent e78370ae
......@@ -25,23 +25,23 @@ list of PDB files.
Quick Start
-----------
1. Be sure to check if the following packages are correctly installed with
your python installation or virtual environment.
* ``pip`` (>= 9.0)
* ``setuptools`` (>= 18.0)
* ``numpy`` (>= 1.11)
* ``matplotlib``
1. Be sure to check if the following packages are correctly installed with
your python installation or virtual environment.
2. Download the ``zip`` or ``tar`` version at Gitlab_
* ``pip`` (>= 9.0)
* ``setuptools`` (>= 18.0)
* ``numpy`` (>= 1.11)
* ``matplotlib``
3. Extract the files and run ``pip install .`` inside the new directory
2. Download the ``zip`` or ``tar`` version at Gitlab_
3. Extract the files and run ``pip install .`` inside the new directory
More explanation about the ``pip`` installation can be found in the
:doc: `installation` section
.. Hyperlinks
.. _Gitlab: https://gitlab.pasteur.fr/bis-aria/ariaec
.. _ARIA: http://aria.pasteur.fr
......
......@@ -27,4 +27,62 @@ $Revision: 1.1.1.1 $
$Date: 2010/03/23 15:27:24 $
"""
import re
import os
import sys
import subprocess
from aria.core import *
from os.path import dirname, isdir, join
VERSION_RE = re.compile('^Version: (.+)$', re.M)
def get_version(full=True):
"""
Returns
-------
"""
d = dirname(__file__)
# TODO: actually no warning when git command is not available !!
if isdir(join(d, '.git')):
# Get the version using "git describe".
cmd = 'git describe --tags'.split()
try:
version = subprocess.check_output(cmd).decode().strip()
except subprocess.CalledProcessError:
print('Unable to get version number from git tags')
sys.exit(1)
# PEP 386 compatibility
if '-' in version and full:
version = '.post'.join(version.split('-')[:2])
else:
version = version.split('-')[0]
# Don't declare a version "dirty" merely because a time stamp has
# changed. If it is dirty, append a ".dev1" suffix to indicate a
# development revision after the release.
with open(os.devnull, 'w') as fd_devnull:
subprocess.call(['git', 'status'],
stdout=fd_devnull, stderr=fd_devnull)
cmd = 'git diff-index --name-only HEAD'.split()
try:
dirty = subprocess.check_output(cmd).decode().strip()
except subprocess.CalledProcessError:
print('Unable to get git index status')
sys.exit(1)
if dirty != '' and full:
version += '.dev1'
else:
# Extract the version from the PKG-INFO file.
with open(join(d, 'PKG-INFO')) as foo:
version = VERSION_RE.search(foo.read()).group(1)
return version
......@@ -22,7 +22,7 @@
import time
import sphinx_rtd_theme
# import sphinx_bootstrap_theme
from setup import get_version
from aria import get_version
# -- General configuration ------------------------------------------------
......
......@@ -32,9 +32,8 @@ import re
import os
import sys
import textwrap
import subprocess
import pkg_resources
from os.path import dirname, isdir, join
from aria import get_version
from setuptools import Command, find_packages, setup
# from pkg_resources import resource_filename
......@@ -65,7 +64,6 @@ MICRO = 2
ISRELEASED = False
# TODO: get version tag in ariabase.py ?
VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
VERSION_RE = re.compile('^Version: (.+)$', re.M)
# Compatibility checks
......@@ -111,56 +109,6 @@ class CleanCommand(Command):
'./*.egg-info ./*.egg')
def get_version(full=True):
"""
Returns
-------
"""
d = dirname(__file__)
# TODO: actually no warning when git command is not available !!
if isdir(join(d, '.git')):
# Get the version using "git describe".
cmd = 'git describe --tags'.split()
try:
version = subprocess.check_output(cmd).decode().strip()
except subprocess.CalledProcessError:
print('Unable to get version number from git tags')
sys.exit(1)
# PEP 386 compatibility
if '-' in version and full:
version = '.post'.join(version.split('-')[:2])
else:
version = version.split('-')[0]
# Don't declare a version "dirty" merely because a time stamp has
# changed. If it is dirty, append a ".dev1" suffix to indicate a
# development revision after the release.
with open(os.devnull, 'w') as fd_devnull:
subprocess.call(['git', 'status'],
stdout=fd_devnull, stderr=fd_devnull)
cmd = 'git diff-index --name-only HEAD'.split()
try:
dirty = subprocess.check_output(cmd).decode().strip()
except subprocess.CalledProcessError:
print('Unable to get git index status')
sys.exit(1)
if dirty != '' and full:
version += '.dev1'
else:
# Extract the version from the PKG-INFO file.
with open(join(d, 'PKG-INFO')) as foo:
version = VERSION_RE.search(foo.read()).group(1)
return version
def is_installed(requirement):
"""Check if requirement package is installed"""
try:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment