Skip to content
Snippets Groups Projects
Commit c09c64c3 authored by Mikkel Friis-Møller's avatar Mikkel Friis-Møller
Browse files

pytables -> tables

versioning from setup.py instead of yml-file
parent 8f4c1fac
No related branches found
No related tags found
Loading
Pipeline #8339 passed
......@@ -44,7 +44,6 @@ pypi_linux:
script:
- apt-get update
- pip install -e . --upgrade
- python3 -c 'from git_utils import write_vers; write_vers()'
- python3 -m pip install -U setuptools wheel
- python3 setup.py sdist bdist_wheel
- python3 -m pip install -U twine
......@@ -62,7 +61,6 @@ pypi_windows:
- tags
- test_pypi
script:
- c:/Anaconda3/envs/WindEnergyToolbox/python.exe -c "from git_utils import write_vers; write_vers()"
- c:/Anaconda3/envs/WindEnergyToolbox/python.exe setup.py bdist_wheel
- twine upload dist/* -u %TWINE_USERNAME% -p %TWINE_PASSWORD%
#- twine upload --repository-url https://test.pypi.org/legacy/ dist/* -u %TWINE_USERNAME% -p %TWINE_PASSWORD% # for testing purposes
......
......@@ -4,6 +4,6 @@ index-servers=
#testpypi # include this line for testing
[testpypi]
repository: https://test.pypi.org/legacy/ # use this line when testing
#repository: https://upload.pypi.org/legacy/
#repository: https://test.pypi.org/legacy/ # use this line when testing
repository: https://upload.pypi.org/legacy/
username: DTUWindEnergy
[![build status](https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox/badges/master/build.svg)](https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox/commits/master)
[![coverage report](https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox/badges/master/coverage.svg)](https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox/commits/master)
[![pypi status](https://img.shields.io/pypi/v/wetb.png)](https://pypi.python.org/pypi/wetb)
# Introduction
......
......@@ -139,7 +139,6 @@ use ```deactivate``` to deactivate the environment.
- [h5py](http://www.h5py.org/)
- [matplotlib](http://matplotlib.org/)
- [pytables](http://www.pytables.org/)
- [pyscaffold](http://pyscaffold.readthedocs.org/en/)
- [pytest](https://pypi.python.org/pypi/pytest)
- [pytest-cov](https://pypi.python.org/pypi/pytest-cov/)
- six, [future](http://python-future.org/index.html)
......@@ -159,7 +158,7 @@ Install the necessary Python dependencies using the conda package manager:
```
>> conda install setuptools_scm future h5py pytables pytest pytest-cov nose sphinx blosc pbr paramiko
>> conda install scipy pandas matplotlib cython xlrd coverage xlwt openpyxl psutil pandoc twine pypandoc
>> conda install -c conda-forge pyscaffold sshtunnel --no-deps
>> conda install -c conda-forge sshtunnel --no-deps
```
Note that ```--no-deps``` avoids that newer packages from the channel
......
......@@ -7,9 +7,7 @@
Install the necessary Python dependencies using the ```conda``` package manager:
```
>> conda install setuptools_scm future h5py pytables pytest pytest-cov nose sphinx blosc pbr paramiko
>> conda install scipy pandas matplotlib cython xlrd coverage xlwt openpyxl psutil
>> conda install -c conda-forge pyscaffold sshtunnel --no-deps
>> conda install blosc
```
Now you can install ```wetb``` with ```pip``` (there is no ```conda``` package
......@@ -58,8 +56,4 @@ in Python 2.7 by default. You can also write code that is compatible with both
[issue 1](https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox/issues/1)).
# Note
This project has been set up using PyScaffold 2.5. For details and usage
information on PyScaffold see http://pyscaffold.readthedocs.org/.
......@@ -14,11 +14,12 @@ def _run_git_cmd(cmd, git_repo_path=None):
try:
process = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
cwd=os.path.abspath(git_repo_path))
stdout = process.communicate()[0]
stdout,stderr = process.communicate()
if process.returncode != 0:
raise EnvironmentError()
raise EnvironmentError("%s\n%s"%(stdout, stderr))
return stdout.strip()
except EnvironmentError as e:
......@@ -26,13 +27,22 @@ def _run_git_cmd(cmd, git_repo_path=None):
raise Warning("unable to run git")
def get_git_branch(git_repo_path=None):
cmd = ["git", "rev-parse", "--abbrev-ref", "HEAD"]
return _run_git_cmd(cmd, git_repo_path)
def get_git_version(git_repo_path=None):
cmd = ["git", "describe", "--tags", "--dirty", "--always"]
return _run_git_cmd(cmd, git_repo_path)
def get_tag(git_repo_path=None):
return _run_git_cmd(['git', 'describe', '--tags', '--abbrev=0'], git_repo_path)
def get_tag(git_repo_path=None, verbose=False):
tag = _run_git_cmd(['git', 'describe', '--tags', '--always', '--abbrev=0'],
git_repo_path)
if verbose:
print(tag)
return tag
def set_tag(tag, push, git_repo_path=None):
......@@ -55,41 +65,69 @@ def update_git_version(version_module, git_repo_path=None):
fid.read()
return version_str
def write_vers(vers_file='wetb/__init__.py'):
version = get_tag(os.getcwd())
def write_vers(vers_file='wetb/__init__.py', repo=None, skip_chars=1):
"""Writes out version string as follows:
"last tag"-("nr commits since tag")-("branch name")-("hash commit")
and where nr of commits since last tag is only included if >0,
branch name is only inlcuded when not on master,
and hash commit is only included when not at a tag (when nr of commits > 0)
"""
if not repo:
repo = os.getcwd()
version_long = get_git_version(repo)
branch = get_git_branch(repo)
verel = version_long.split('-')
# tag name
version = verel[0][skip_chars:]
# number of commits since last tag, only if >0
nr_commits = 0
if len(verel) > 1:
try:
nr_commits = int(verel[1])
except ValueError:
nr_commits = -1
if nr_commits > 0:
version += '-' + verel[1]
# branch name, only when NOT on master
if branch != 'master':
version += '-' + branch
# hash commit, only if not at tag
if len(verel) > 2 and nr_commits > 0:
# first character on the hash is always a g (not part of the hash)
version += '-' + verel[2][1:]
print(version_long)
print('Writing version: {} in {}'.format(version, vers_file))
with open(vers_file, 'r') as f:
lines = f.readlines()
for n,l in enumerate(lines):
for n, l in enumerate(lines):
if l.startswith('__version__'):
lines[n] = "__version__ = '{}'\n".format(version[1:])
lines[n] = "__version__ = '{}'\n".format(version)
for n, l in enumerate(lines):
if l.startswith('__release__'):
lines[n] = "__release__ = '{}'\n".format(version)
with open(vers_file, 'w') as f:
f.write(''.join(lines))
return version
def rename_dist_file():
for f in os.listdir('dist'):
if f.endswith('whl'):
split = f.split('linux')
new_name = 'manylinux1'.join(split)
old_path = os.path.join('dist',f)
new_path = os.path.join('dist',new_name)
old_path = os.path.join('dist', f)
new_path = os.path.join('dist', new_name)
os.rename(old_path, new_path)
def main():
"""Example of how to run (pytest-friendly)"""
if __name__ == '__main__':
# pass
# import version
# import app_utils
# git_path = os.path.dirname(app_utils.__file__) + "/../"
# update_git_version(version, git_path)
# tag = get_tag(os.getcwd())
# print(tag)
# version = get_git_version(os.getcwd())
# print(version)
# rename_dist_file()
write_vers()
pass
main()
......@@ -5,10 +5,12 @@
"""
import os
from git_utils import write_vers
import sys
from setuptools import setup, find_packages
import wetb
__version__ = wetb.__version__
repo = os.path.dirname(__file__)
version = write_vers(vers_file='wetb/__init__.py', repo=repo, skip_chars=1)
try:
from pypandoc import convert_file
......@@ -25,18 +27,38 @@ from Cython.Distutils import build_ext
def setup_package():
ex_info = [('wetb.fatigue_tools.rainflowcounting', ['pair_range', 'peak_trough', 'rainflowcount_astm']),
('wetb.signal.filters', ['cy_filters'])]
('wetb.signal.filters', ['cy_filters'])]
extlist = [Extension('%s.%s' % (module, n),
[os.path.join(module.replace(".","/"), n)+'.pyx'],
[os.path.join(module.replace(".", "/"), n) + '.pyx'],
include_dirs=[np.get_include()]) for module, names in ex_info for n in names]
needs_sphinx = {'build_sphinx', 'upload_docs'}.intersection(sys.argv)
sphinx = ['sphinx'] if needs_sphinx else []
setup(setup_requires=['six'] + sphinx,
cmdclass = {'build_ext': build_ext},
ext_modules = extlist,
install_requires = ['future',
'h5py',
'tables',
'pytest',
'pytest-cov',
# 'blosc', # gives an error - has to be pre-installed
'pbr',
'paramiko',
'scipy',
'pandas',
'matplotlib',
'cython',
'xlrd',
'coverage',
'xlwt',
'openpyxl',
'psutil',
'six',
'sshtunnel']
build_requires = ['cython']
setup(install_requires=install_requires,
setup_requires=install_requires + build_requires + sphinx,
cmdclass={'build_ext': build_ext},
ext_modules=extlist,
long_description=read_md('README.md'),
version=__version__,
version=version,
packages=find_packages(),
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment