Skip to content

Commit

Permalink
bump version, merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Feb 2, 2018
2 parents a93a157 + 7e34dcf commit 1360fc0
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 30 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ before_install:
# fix a crash with multiprocessing on Travis
# - sudo rm -rf /dev/shm
# - sudo ln -s /run/shm /dev/shm
# coverage submission packages
- git fetch --tags
install:
- pip install tox
Expand Down
10 changes: 10 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
* files: *
MPLv2.0 2015-2018 (c) Casper da Costa-Luis
[casperdcl](https://github.com/casperdcl).


Mozilla Public Licence (MPL) v. 2.0 - Exhibit A
-----------------------------------------------

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
5 changes: 3 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Misc
include .coveragerc
include LICENCE
include Makefile
include README.rst
include tox.ini

# Test suite
recursive-include argopt/tests *.py

# Examples/Documentation
recursive-include examples *
recursive-include examples *.py
include README.rst
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
pypi
none

help:
@python setup.py make

alltests:
@+make testcoverage
@+make flake8
Expand Down Expand Up @@ -75,10 +78,10 @@ coverclean:
@+python -c "import shutil; shutil.rmtree('argopt/__pycache__', True)"
@+python -c "import shutil; shutil.rmtree('argopt/tests/__pycache__', True)"
clean:
@+python -c "import os; import glob; [os.remove(i) for i in glob.glob('*.py[co]')]"
@+python -c "import os; import glob; [os.remove(i) for i in glob.glob('argopt/*.py[co]')]"
@+python -c "import os; import glob; [os.remove(i) for i in glob.glob('examples/*.py[co]')]"
@+python -c "import os; import glob; [os.remove(i) for i in glob.glob('argopt/tests/*.py[co]')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('*.py[co]')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('argopt/*.py[co]')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('examples/*.py[co]')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('argopt/tests/*.py[co]')]"
toxclean:
@+python -c "import shutil; shutil.rmtree('.tox', True)"

Expand Down
9 changes: 6 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
argopt
======

doc to argparse driven by docopt
doc to ``argparse`` driven by ``docopt``

|PyPI-Status| |PyPI-Versions|

Expand Down Expand Up @@ -29,7 +29,7 @@ The problem is that this is not always flexible. Still need all the features of
Installation
------------

Latest pypi stable release
Latest PyPI stable release
~~~~~~~~~~~~~~~~~~~~~~~~~~

|PyPI-Status|
Expand Down Expand Up @@ -208,7 +208,7 @@ Licence

Open Source (OSI approved): |LICENCE|

Copyright (c) 2016-7 Casper da Costa-Luis.
Copyright (c) 2016-8 Casper da Costa-Luis.

This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0.
Expand All @@ -223,6 +223,8 @@ Authors

- Casper da Costa-Luis (`@casperdcl <https://github.com/casperdcl/>`__) |Donate|

|argopt-hits|

.. |Build-Status| image:: https://travis-ci.org/casperdcl/argopt.svg?branch=master
:target: https://travis-ci.org/casperdcl/argopt
.. |Coverage-Status| image:: https://coveralls.io/repos/casperdcl/argopt/badge.svg?branch=master
Expand All @@ -235,6 +237,7 @@ Authors
:target: https://pypi.python.org/pypi/argopt
.. |PyPI-Versions| image:: https://img.shields.io/pypi/pyversions/argopt.svg
:target: https://pypi.python.org/pypi/argopt
.. |argopt-hits| image:: https://caspersci.uk.to/cgi-bin/hits.cgi?q=argopt&a=hidden
.. |OpenHub-Status| image:: https://www.openhub.net/p/arg-opt/widgets/project_thin_badge?format=gif
:target: https://www.openhub.net/p/arg-opt?ref=Thin+badge
.. |LICENCE| image:: https://img.shields.io/pypi/l/argopt.svg
Expand Down
16 changes: 13 additions & 3 deletions argopt/_docopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,15 +455,25 @@ def parse_defaults(doc):


def printable_usage(doc, section="usage"):
# in python < 2.7 you can't pass flags=re.IGNORECASE
# in python < 2.7 you can't pass flags=re.IGNORECASE|re.MULTILINE
regex = ''.join(["[%s%s]" % (i.lower(), i.upper()) for i in section])
# usage_split = re.split('^(' + regex + ':)', doc, flags=re.M)
usage_split = re.split('(' + regex + ':)', doc)
if len(usage_split) < 3:
# indices of real sections (preceded by newline or blank)
secs = [i + 1 for i in range(0, len(usage_split) - 1, 2) if
usage_split[i].endswith('\n') or not
usage_split[i].strip()]
if len(secs) == 0:
raise DocoptLanguageError(
'"%s:" (case-insensitive) not found.' % section)
if len(usage_split) > 3:
elif len(secs) > 1:
raise DocoptLanguageError(
'More than one "%s:" (case-insensitive).' % section)
# ignore fake sections
s = secs[0]
usage_split = [''.join(usage_split[i]) for i in
[slice(0, s), s, slice(s + 1, None)]]

return re.split(r'\n\s*\n', ''.join(usage_split[1:]))[0].strip()


Expand Down
2 changes: 1 addition & 1 deletion argopt/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
__all__ = ["__version__"]

# major, minor, patch, -extra
version_info = 0, 3, 5
version_info = 0, 4, 0

# Nice string for the version
__version__ = '.'.join(map(str, version_info))
Expand Down
32 changes: 16 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
except ImportError:
from distutils.core import setup
import sys
import subprocess
from subprocess import check_call
from io import open as io_open

# For Makefile parsing
import shlex
try: # pragma: no cover
Expand All @@ -17,24 +19,20 @@
# Python 3 compatibility
import configparser as ConfigParser
import io as StringIO
import io
import re


__author__ = None
__licence__ = None
__version__ = None
main_file = os.path.join(os.path.dirname(__file__), 'argopt', '_argopt.py')
for l in io.open(main_file, mode='r'):
for l in io_open(main_file, mode='r'):
if any(l.startswith(i) for i in ('__author__', '__licence__')):
exec(l)
version_file = os.path.join(os.path.dirname(__file__), 'argopt', '_version.py')
with io.open(version_file, mode='r') as fd:
with io_open(version_file, mode='r') as fd:
exec(fd.read())


# # Makefile auxiliary functions # #

# Makefile auxiliary functions #

RE_MAKE_CMD = re.compile('^\t(@\+?)(make)?', flags=re.M)

Expand All @@ -50,7 +48,7 @@ def parse_makefile_aliases(filepath):
# -- Parsing the Makefile using ConfigParser
# Adding a fake section to make the Makefile a valid Ini file
ini_str = '[root]\n'
with io.open(filepath, mode='r') as fd:
with io_open(filepath, mode='r') as fd:
ini_str = ini_str + RE_MAKE_CMD.sub('\t', fd.read())
ini_fp = StringIO.StringIO(ini_str)
# Parse using ConfigParser
Expand Down Expand Up @@ -126,16 +124,17 @@ def execute_makefile_commands(commands, alias, verbose=False):
if verbose:
print("Running command: " + cmd)
# Launch the command and wait to finish (synchronized call)
subprocess.check_call(parsed_cmd)
check_call(parsed_cmd,
cwd=os.path.dirname(os.path.abspath(__file__)))


# # Main setup.py config # #
# Main setup.py config #


# Executing makefile commands if specified
if sys.argv[1].lower().strip() == 'make':
# Filename of the makefile
fpath = 'Makefile'
fpath = os.path.join(os.path.dirname(__file__), 'Makefile')
# Parse the makefile, substitute the aliases and extract the commands
commands = parse_makefile_aliases(fpath)

Expand All @@ -162,11 +161,11 @@ def execute_makefile_commands(commands, alias, verbose=False):
sys.exit(0)


# # Python package config # #

# Python package config #

README_rst = None
with io.open('README.rst', mode='r', encoding='utf-8') as fd:
README_rst = ''
fndoc = os.path.join(os.path.dirname(__file__), 'README.rst')
with io_open(fndoc, mode='r', encoding='utf-8') as fd:
README_rst = fd.read()

setup(
Expand All @@ -182,6 +181,7 @@ def execute_makefile_commands(commands, alias, verbose=False):
platforms=['any'],
packages=['argopt'],
install_requires=['argparse'],
package_data={'': ['LICENCE']},
classifiers=[
# Trove classifiers
# (https://pypi.python.org/pypi?%3Aaction=list_classifiers)
Expand Down

0 comments on commit 1360fc0

Please sign in to comment.