Skip to content

Commit

Permalink
Merge pull request #169 from mih/appveyor
Browse files Browse the repository at this point in the history
Adopt standard extension setup
  • Loading branch information
mih authored Feb 2, 2022
2 parents 2f4dd4d + 522633a commit c5939d5
Show file tree
Hide file tree
Showing 18 changed files with 2,764 additions and 496 deletions.
17 changes: 17 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "2"
checks:
file-lines:
config:
threshold: 500
plugins:
bandit:
enabled: true
checks:
assert_used:
enabled: false
exclude_patterns:
- "_datalad_buildsupport/"
- "versioneer.py"
- "*/_version.py"
- "tools/"
- "**/tests/"
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
datalad_container/_version.py export-subst
Empty file added .noannex
Empty file.
6 changes: 5 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
include formatters.py setup_support.py
include CONTRIBUTORS LICENSE versioneer.py
graft _datalad_buildsupport
graft docs
prune docs/build
global-exclude *.py[cod]
50 changes: 12 additions & 38 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,47 +1,21 @@
# simple makefile to simplify repetetive build env management tasks under posix
# Ideas borrowed from scikit-learn's and PyMVPA Makefiles -- thanks!

PYTHON ?= python
NOSETESTS ?= nosetests

MODULE ?= datalad

all: clean test

clean:
$(PYTHON) setup.py clean
rm -rf dist build bin docs/build docs/source/generated
rm -rf dist build bin docs/build docs/source/generated *.egg-info
-find . -name '*.pyc' -delete
-find . -name '__pycache__' -type d -delete

bin:
mkdir -p $@
PYTHONPATH=bin:$(PYTHONPATH) python setup.py develop --install-dir $@

test-code: bin
PATH=bin:$(PATH) PYTHONPATH=bin:$(PYTHONPATH) $(NOSETESTS) -s -v $(MODULE)

test-coverage:
rm -rf coverage .coverage
$(NOSETESTS) -s -v --with-coverage $(MODULE)

test: test-code


trailing-spaces:
find $(MODULE) -name "*.py" -exec perl -pi -e 's/[ \t]*$$//' {} \;

code-analysis:
flake8 $(MODULE) | grep -v __init__ | grep -v external
pylint -E -i y $(MODULE)/ # -d E1103,E0611,E1101

update-changelog:
@echo ".. This file is auto-converted from CHANGELOG.md (make update-changelog) -- do not edit\n\nChange log\n**********" > docs/source/changelog.rst
pandoc -t rst CHANGELOG.md >> docs/source/changelog.rst

release-pypi: update-changelog
# better safe than sorry
release-pypi:
# avoid upload of stale builds
test ! -e dist
python setup.py sdist
python setup.py bdist_wheel --universal
$(PYTHON) setup.py sdist bdist_wheel
twine upload dist/*

update-buildsupport:
git subtree pull \
-m "Update DataLad build helper" \
--squash \
--prefix _datalad_buildsupport \
https://github.com/datalad/datalad-buildsupport.git \
master
13 changes: 13 additions & 0 deletions _datalad_buildsupport/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
#
# See COPYING file distributed along with the DataLad package for the
# copyright and license terms.
#
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""Python package for functionality needed at package 'build' time by DataLad and its extensions
__init__ here should be really minimalistic, not import submodules by default
and submodules should also not require heavy dependencies.
"""

__version__ = '0.1'
26 changes: 15 additions & 11 deletions formatters.py → _datalad_buildsupport/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,23 @@ def _mk_synopsis(self, parser):
return usage

def _mk_title(self, prog):
name_version = "\"{0} {1}\"".format(prog, self._version)
return '.TH {0} {1} {2} {3}\n'.format(prog, self._section,
self._today, name_version)
name_version = "{0} {1}".format(prog, self._version)
return '.TH "{0}" "{1}" "{2}" "{3}"\n'.format(
prog, self._section, self._today, name_version)

def _make_name(self, parser):
def _mk_name(self, prog, desc):
"""
this method is in consitent with others ... it relies on
distribution
"""
return '.SH NAME\n%s \\- %s\n' % (parser.prog,
parser.description)
desc = desc.splitlines()[0] if desc else 'it is in the name'
# ensure starting lower case
desc = desc[0].lower() + desc[1:]
return '.SH NAME\n%s \\- %s\n' % (self._bold(prog), desc)

def _mk_description(self, parser):
desc = parser.description
desc = '\n'.join(desc.splitlines()[1:])
if not desc:
return ''
desc = desc.replace('\n\n', '\n.PP\n')
Expand Down Expand Up @@ -113,6 +116,7 @@ def _mk_footer(self, sections):
def format_man_page(self, parser):
page = []
page.append(self._mk_title(self._prog))
page.append(self._mk_name(self._prog, parser.description))
page.append(self._mk_synopsis(parser))
page.append(self._mk_description(parser))
page.append(self._mk_options(parser))
Expand Down Expand Up @@ -144,7 +148,7 @@ def _mk_options(self, parser):
help = re.sub(r'^ (\S.*)\n', '\\1\n', help, flags=re.MULTILINE)
return '.SH OPTIONS\n' + help

def _format_action_invocation(self, action):
def _format_action_invocation(self, action, doubledash='--'):
if not action.option_strings:
metavar, = self._metavar_formatter(action, action.dest)(1)
return metavar
Expand All @@ -167,7 +171,7 @@ def _format_action_invocation(self, action):
parts.append('%s %s' % (self._bold(option_string),
args_string))

return ', '.join(parts)
return ', '.join(p.replace('--', doubledash) for p in parts)


class RSTManPageFormatter(ManPageFormatter):
Expand Down Expand Up @@ -202,7 +206,7 @@ def _mk_title(self, prog):
title += '\n{0}\n\n'.format('=' * len(prog))
return title

def _make_name(self, parser):
def _mk_name(self, prog, desc):
return ''

def _mk_description(self, parser):
Expand Down Expand Up @@ -247,7 +251,7 @@ def _mk_options(self, parser):

def _format_action(self, action):
# determine the required width and the entry label
action_header = self._format_action_invocation(action)
action_header = self._format_action_invocation(action, doubledash='-\\\\-')

if action.help:
help_text = self._expand_help(action)
Expand All @@ -266,7 +270,7 @@ def _format_action(self, action):

def cmdline_example_to_rst(src, out=None, ref=None):
if out is None:
from six.moves import StringIO
from io import StringIO
out = StringIO()

# place header
Expand Down
Loading

0 comments on commit c5939d5

Please sign in to comment.