Commit ec11aa34 authored by Fabrice  ALLAIN's avatar Fabrice ALLAIN

Cleaner version of setuptools installation

parent 57f42c78
.venv
.idea
.eggs
.git
*.pyc
data
docs/_static
docs/_templates
docs/_builds
\ No newline at end of file
graft ariaec/conf
graft ariaec/templates
graft ariaec/data
graft docs
\ No newline at end of file
graft docs
prune examples*
......@@ -273,6 +273,9 @@ class PDBStat(object):
# pool = ProcessingPool(nodes=ncpus)
# iteresults = pool.imap(self.subdist, [dists]*len(groups), groups)
# interdists = []
# TODO: use sql to select subdataframes in order to work with heavy
# data http://pythondata.com/working-large-csv-files-python/
tqdm_out = TqdmToLogger(LOG, level=logging.INFO)
interdists = [
self.subdist(dists, group) for group in tqdm(groups, file=tqdm_out,
......
......@@ -4,4 +4,4 @@
# will need to generate wheels for each Python version that you support.
universal=1
[egg_info]
tag_build = .dev
# tag_build = .dev
......@@ -6,13 +6,14 @@ from __future__ import absolute_import, division, print_function
import os
import sys
import re
import textwrap
import subprocess
import pkg_resources
from version import get_version
from setuptools import Command, find_packages, setup
DOCLINES = __doc__.split("\n")
DOCLINES = re.sub("\n", " ", re.sub(" {2,}", "", __doc__))
CLASSIFIERS = """\
Development Status :: 3 - Alpha
......@@ -35,13 +36,6 @@ Operating System :: Unix
Operating System :: MacOS
"""
MAJOR = 0
MINOR = 1
MICRO = 0
ISRELEASED = False
# TODO: get version tag in ariabase.py ?
VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
# Compatibility checks
# TODO: Change this line after python 3 compatibility done !
......@@ -90,61 +84,16 @@ def is_installed(requirement):
pkg_resources.require(requirement)
except pkg_resources.ResolutionError:
return False
else:
finally:
return True
def git_version():
"""
Return the git revision as a string
"""
def _minimal_ext_cmd(cmd):
# construct minimal environment
env = {}
for k in ['SYSTEMROOT', 'PATH']:
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'
return subprocess.Popen(
cmd, stdout=subprocess.PIPE, env=env).communicate()[0]
try:
out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
git_revision = out.strip().decode('ascii')
except OSError:
git_revision = "Unknown"
return git_revision
def get_version_info():
"""
Return full version number with git revision string
"""
# Adding the git rev number needs to be done inside write_version_py(),
# otherwise the import of aria.version messes up the build under Python 3.
full_version = VERSION
if os.path.exists('.git'):
git_revision = git_version()
else:
git_revision = "Unknown"
if not ISRELEASED:
full_version += '.dev0+' + git_revision[:7]
return full_version, git_revision
def setup_package():
"""Main function"""
metadata = dict(
name='ariaec',
version=get_version_info()[0],
version=get_version(),
maintainer="ARIA Developers",
# maintainer_email="bardiaux@pasteur.fr",
author="Allain Fabrice",
......@@ -197,24 +146,28 @@ def setup_package():
# TODO: solution to enable zip_safe
zip_safe=False,
package_dir={'ariaec': './ariaec'},
# Doesn't works if we use package_dir with include_package_data
# package_dir={'ariaec': './ariaec'},
packages=find_packages(),
packages=find_packages(exclude=("examples",)),
# Install any data files found in the package
include_package_data=True,
package_data={
# If any package contains these files, include them
'': ['*.txt', '*.rst'],
# And include files found in the 'ariaec' package, too:
'ariaec': ['conf/*',
'templates/*',
'data/cullpdb/160427/*',
'data/cullpdb/170315/*'
'data/*',
],
},
# Using MANIFEST file, we do not need package_data which doesn't work
# for all kind of building process ...
# package_data={
# # If any package contains these files, include them
# '': ['*.txt', '*.rst', '*.p', '*.pro'],
# # And include files found in the 'ariaec' package, too:
# 'ariaec': ['conf/*',
# 'templates/*',
# 'data/pdbdists/*'
# 'data/cullpdb/160427/*',
# 'data/cullpdb/170315/*'
# 'data/*',
# ],
# },
# If we want to include non data files (documentation, examples, ..)
# in the sys.prefix directory. The package can't access these files !
......@@ -231,7 +184,7 @@ Error: numpy needs to be installed first. You can install it via:
$ pip install numpy
"""), file=sys.stderr)
exit(1)
sys.exit(1)
if not is_installed('matplotlib'):
......@@ -240,7 +193,7 @@ Error: matplotlib needs to be installed first. You can install it via:
$ pip install matplotlib
"""), file=sys.stderr)
exit(1)
sys.exit(1)
if __name__ == '__main__':
......
.venv
.idea
.eggs
.git
*.pyc
data
docs/_static
docs/_templates
docs/_builds
\ No newline at end of file
# coding=utf-8
# This program is placed into the public domain.
"""
VERSION
Gets the current version number.
If in a git repository, it is the current git tag.
Otherwise it is the one contained in the PKG-INFO file.
To use this script, simply import it in your setup.py file
and use the results of get_version() as your package version:
from version import *
setup(
...
version=get_version(),
...
)
"""
# Do not edit this file, pipeline versioning is governed by git tags
__version__ = 'v0.1.0'
__all__ = 'get_version'
from os.path import dirname, isdir, join
import sys
import os
import re
import subprocess
version_re = re.compile('^Version: (.+)$', re.M)
def get_version():
"""
Returns
-------
"""
d = dirname(__file__)
version = ''
dirty = ''
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:
version = '.post'.join(version.split('-')[:2])
# 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 != '':
version += '.dev1'
else:
# Extract the version from the PKG-INFO file.
with open(join(d, 'PKG-INFO')) as f:
version = version_re.search(f.read()).group(1)
return version
if __name__ == '__main__':
print(get_version())
Markdown is supported
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