mirror of https://github.com/phonopy/phonopy.git
Version number handling is brought back to the previous form, and setuptools-scm is under testing
This commit is contained in:
parent
6d41e28319
commit
6f5fb7159f
12
.travis.yml
12
.travis.yml
|
@ -8,14 +8,20 @@ python:
|
|||
- '3.6'
|
||||
|
||||
before_install:
|
||||
- TRAVIS_PYTHON_VERSION=`python --version |& awk '{print $2}'|awk -F'.' '{print $1"."$2}'`
|
||||
- wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
|
||||
#- TRAVIS_PYTHON_VERSION=`python --version |& awk '{print $2}'|awk -F'.' '{print $1"."$2}'`
|
||||
# - wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
|
||||
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
|
||||
wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh;
|
||||
else
|
||||
wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
|
||||
fi
|
||||
- echo $TRAVIS_PYTHON_VERSION
|
||||
- bash miniconda.sh -b -p $HOME/miniconda
|
||||
- export PATH="$HOME/miniconda/bin:$PATH"
|
||||
- conda update --yes conda
|
||||
|
||||
install:
|
||||
- conda install --yes python=$TRAVIS_PYTHON_VERSION pip numpy h5py pyyaml matplotlib
|
||||
- conda install --yes python=$TRAVIS_PYTHON_VERSION pip numpy h5py pyyaml matplotlib setuptools setuptools_scm
|
||||
- pwd
|
||||
- ./get_nanoversion.sh
|
||||
- cat __nanoversion__.txt
|
||||
|
|
|
@ -31,6 +31,8 @@ requirements:
|
|||
- matplotlib
|
||||
- pyyaml
|
||||
- h5py
|
||||
- setuptools
|
||||
- setuptools_scm
|
||||
|
||||
run:
|
||||
- python
|
||||
|
|
|
@ -32,7 +32,4 @@
|
|||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from phonopy.version.git_hash import git_hash
|
||||
|
||||
short_version = "1.11.12"
|
||||
__version__ = short_version
|
||||
__version__ = "1.11.12"
|
39
setup.py
39
setup.py
|
@ -1,5 +1,6 @@
|
|||
import numpy
|
||||
import os
|
||||
import sys
|
||||
import numpy
|
||||
|
||||
with_openmp = False
|
||||
|
||||
|
@ -12,6 +13,17 @@ except ImportError:
|
|||
use_setuptools = False
|
||||
print("distutils is used.")
|
||||
|
||||
try:
|
||||
from setuptools_scm import get_version
|
||||
except ImportError:
|
||||
git_hash = None
|
||||
|
||||
if 'setuptools_scm' in sys.modules.keys():
|
||||
try:
|
||||
git_hash = get_version().split('.')[3]
|
||||
except:
|
||||
git_hash = None
|
||||
|
||||
include_dirs_numpy = [numpy.get_include()]
|
||||
cc = None
|
||||
if 'CC' in os.environ:
|
||||
|
@ -107,8 +119,7 @@ packages_phonopy = ['phonopy',
|
|||
'phonopy.qha',
|
||||
'phonopy.spectrum',
|
||||
'phonopy.structure',
|
||||
'phonopy.unfolding',
|
||||
'phonopy.version']
|
||||
'phonopy.unfolding']
|
||||
scripts_phonopy = ['scripts/phonopy',
|
||||
'scripts/phonopy-qha',
|
||||
'scripts/phonopy-FHI-aims',
|
||||
|
@ -123,28 +134,13 @@ scripts_phonopy = ['scripts/phonopy',
|
|||
if __name__ == '__main__':
|
||||
|
||||
version_nums = [None, None, None]
|
||||
with open("phonopy/version/__init__.py") as f:
|
||||
with open("phonopy/version.py") as f:
|
||||
for line in f:
|
||||
if "short_version" in line:
|
||||
if "__version__" in line:
|
||||
for i, num in enumerate(line.split()[2].strip('\"').split('.')):
|
||||
version_nums[i] = int(num)
|
||||
break
|
||||
|
||||
try:
|
||||
import subprocess
|
||||
git_describe = subprocess.check_output(["git", "describe", "--tags"])
|
||||
git_hash = str(git_describe.strip().split(b"-")[2][1:])
|
||||
if git_hash[:2] == "b\'":
|
||||
git_hash = git_hash[2:]
|
||||
git_hash = git_hash.replace('\'', '')
|
||||
with open("phonopy/version/git_hash.py", 'w') as w:
|
||||
git_hash_line = "git_hash = \"%s\"\n" % git_hash
|
||||
w.write(git_hash_line)
|
||||
print(git_hash_line)
|
||||
except:
|
||||
with open("phonopy/version/git_hash.py", 'w') as w:
|
||||
w.write("git_hash = None\n")
|
||||
|
||||
# To deploy to pypi/conda by travis-CI
|
||||
if os.path.isfile("__nanoversion__.txt"):
|
||||
with open('__nanoversion__.txt') as nv:
|
||||
|
@ -162,6 +158,9 @@ if __name__ == '__main__':
|
|||
raise
|
||||
|
||||
version_number = ".".join(["%d" % n for n in version_nums])
|
||||
if git_hash:
|
||||
version_number += "%s" % git_hash
|
||||
|
||||
if use_setuptools:
|
||||
setup(name='phonopy',
|
||||
version=version_number,
|
||||
|
|
Loading…
Reference in New Issue