Skip to content

Commit

Permalink
Added command to output version
Browse files Browse the repository at this point in the history
Avoid repetition when writing to file.

Added command to get the current version.

Also added version to output. This required changes in the tests
expected output files.

Added a way to easily update the version in tests.

Updated readme and usage documentation.

Added script to get the current version to be used in bootstrap.
  • Loading branch information
ansasaki committed May 28, 2018
1 parent 9f0d1d0 commit fa2af44
Show file tree
Hide file tree
Showing 166 changed files with 295 additions and 134 deletions.
10 changes: 1 addition & 9 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@ current_version = 0.1.0
commit = True
tag = True

[bumpversion:file:setup.py]
search = version='{current_version}'
replace = version='{new_version}'

[bumpversion:file:README.rst]
search = v{current_version}.
replace = v{new_version}.

[bumpversion:file:docs/conf.py]
search = version = release = '{current_version}'
replace = version = release = '{new_version}'

[bumpversion:file:src/smap/__init__.py]
[bumpversion:file:src/smap/_version.py]
search = __version__ = '{current_version}'
replace = __version__ = '{new_version}'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pip-log.txt
nosetests.xml
coverage.xml
htmlcov
tests/data

# Translations
*.mo
Expand Down
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ include README.rst
include HISTORY.rst

include Makefile
include version.py

include tox.ini .travis.yml

global-exclude docs/_build* *.swp
global-exclude docs/_build* *.swp tests/data
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ help:
ci-bootstrap: ci/bootstrap.py
python ci/bootstrap.py

bootstrap-tests:
@SMAP_NAME_VERSION=`python version.py`; \
echo "Setting name and version in tests as $${SMAP_NAME_VERSION}"; \
$(MAKE) -C tests SMAP_NAME_VERSION=$${SMAP_NAME_VERSION}

clean: clean-build clean-pyc clean-test clean-docs

clean-build: ## remove build artifacts
Expand All @@ -51,6 +56,7 @@ clean-test: ## remove test and coverage artifacts
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/
rm -rf tests/data

clean-docs: ## remove generated docs files
rm -rf dist/docs
Expand All @@ -59,7 +65,7 @@ clean-docs: ## remove generated docs files
lint: ## check style with flake8
flake8 src/smap tests

test: ## run tests quickly with the default Python
test: bootstrap-tests## run tests quickly with the default Python
pytest -vv --ignore=src/

test-all: tox.ini## run tests on every Python version with tox
Expand Down
27 changes: 20 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,28 +155,34 @@ or (to check the content of a existing map)::

$ smap check my.map

or (to check the current version)::

$ smap version

Long version
------------

Running ``smap -h`` will give::

usage: smap [-h] {update,new,check} ...
usage: smap [-h] {update,new,check,version} ...
Helper tools for linker version script maintenance
optional arguments:
-h, --help show this help message and exit
-h, --help show this help message and exit
Subcommands:
{update,new,check} These subcommands have their own set of options
update Update the map file
new Create a new map file
check Check the map file
{update,new,check,version}
These subcommands have their own set of options
update Update the map file
new Create a new map file
check Check the map file
version Print version
Call a subcommand passing '-h' to see its specific options

Call a subcommand passing '-h' to see its specific options
There are three subcommands, ``update``, ``new``, and ``check``
There are four subcommands, ``update``, ``new``, ``check``, and ``version``

Running ``smap update -h`` will give::

Expand Down Expand Up @@ -269,6 +275,13 @@ Running ``smap check -h`` will give::
-l LOGFILE, --logfile LOGFILE
Log to this file

Running ``smap version -h`` will give::

usage: smap version [-h]
optional arguments:
-h, --help show this help message and exit

Import as a library:
--------------------

Expand Down
1 change: 1 addition & 0 deletions ci/templates/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ deps =
pyyaml
cover: pytest-cov
commands =
make bootstrap-tests
nocov: {posargs:py.test -vv --ignore=src}
cover: {posargs:py.test --cov --cov-report=term-missing -vv}

Expand Down
13 changes: 10 additions & 3 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,29 @@ HELP_CHECK:
echo >> HELP_CHECK
smap check -h | sed -e 's/^/ /' >> HELP_CHECK

usage: HELP HELP_NEW HELP_UPDATE HELP_CHECK
HELP_VERSION:
echo 'Running ``$ smap version -h`` will give::' > HELP_VERSION
echo >> HELP_VERSION
smap version -h | sed -e 's/^/ /' >> HELP_VERSION

usage: HELP HELP_NEW HELP_UPDATE HELP_CHECK HELP_VERSION
cp templates/usage.template usage.rst
sed -e '/HELP_PLACEHOLDER/ {' -e 'r HELP' -e 'd' -e '}' -i usage.rst
sed -e '/HELP_UPDATE_PLACEHOLDER/ {' -e 'r HELP_UPDATE' -e 'd' -e '}' -i usage.rst
sed -e '/HELP_NEW_PLACEHOLDER/ {' -e 'r HELP_NEW' -e 'd' -e '}' -i usage.rst
sed -e '/HELP_CHECK_PLACEHOLDER/ {' -e 'r HELP_CHECK' -e 'd' -e '}' -i usage.rst
sed -e '/HELP_VERSION_PLACEHOLDER/ {' -e 'r HELP_VERSION' -e 'd' -e '}' -i usage.rst

readme: HELP HELP_NEW HELP_UPDATE HELP_CHECK
readme: HELP HELP_NEW HELP_UPDATE HELP_CHECK HELP_VERSION
cp templates/readme.template readme.rst
sed -e '/HELP_PLACEHOLDER/ {' -e 'r HELP' -e 'd' -e '}' -i readme.rst
sed -e '/HELP_UPDATE_PLACEHOLDER/ {' -e 'r HELP_UPDATE' -e 'd' -e '}' -i readme.rst
sed -e '/HELP_NEW_PLACEHOLDER/ {' -e 'r HELP_NEW' -e 'd' -e '}' -i readme.rst
sed -e '/HELP_CHECK_PLACEHOLDER/ {' -e 'r HELP_CHECK' -e 'd' -e '}' -i readme.rst
sed -e '/HELP_VERSION_PLACEHOLDER/ {' -e 'r HELP_VERSION' -e 'd' -e '}' -i readme.rst

.PHONY: clean

clean:
rm -rf HELP HELP_NEW HELP_UPDATE HELP_CHECK
rm -rf HELP HELP_NEW HELP_UPDATE HELP_CHECK HELP_VERSION

27 changes: 20 additions & 7 deletions docs/readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,28 +155,34 @@ or (to check the content of a existing map)::

$ smap check my.map

or (to check the current version)::

$ smap version

Long version
------------

Running ``smap -h`` will give::

usage: smap [-h] {update,new,check} ...
usage: smap [-h] {update,new,check,version} ...
Helper tools for linker version script maintenance
optional arguments:
-h, --help show this help message and exit
-h, --help show this help message and exit
Subcommands:
{update,new,check} These subcommands have their own set of options
update Update the map file
new Create a new map file
check Check the map file
{update,new,check,version}
These subcommands have their own set of options
update Update the map file
new Create a new map file
check Check the map file
version Print version
Call a subcommand passing '-h' to see its specific options

Call a subcommand passing '-h' to see its specific options
There are three subcommands, ``update``, ``new``, and ``check``
There are four subcommands, ``update``, ``new``, ``check``, and ``version``

Running ``smap update -h`` will give::

Expand Down Expand Up @@ -269,6 +275,13 @@ Running ``smap check -h`` will give::
-l LOGFILE, --logfile LOGFILE
Log to this file

Running ``smap version -h`` will give::

usage: smap version [-h]
optional arguments:
-h, --help show this help message and exit

Import as a library:
--------------------

Expand Down
12 changes: 9 additions & 3 deletions docs/templates/readme.template
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,25 @@ or (to check the content of a existing map)::

$ smap check my.map

or (to check the current version)::

$ smap version

Long version
------------

INCLUDE_HELP_PLACEHOLDER

Call a subcommand passing '-h' to see its specific options
There are three subcommands, ``update``, ``new``, and ``check``
There are four subcommands, ``update``, ``new``, ``check``, and ``version``

INCLUDE_HELP_UPDATE_PLACEHOLDER
INCLUDE HELP_UPDATE_PLACEHOLDER

INCLUDE HELP_NEW_PLACEHOLDER

INCLUDE_HELP_CHECK_PLACEHOLDER
INCLUDE HELP_CHECK_PLACEHOLDER

INCLUDE HELP_VERSION_PLACEHOLDER

Import as a library:
--------------------
Expand Down
14 changes: 10 additions & 4 deletions docs/templates/usage.template
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,25 @@ or (to check the content of a existing map)::

$ smap check my.map

or (to check the current version)::

$ smap version

Long version
------------

INCLUDE_HELP_PLACEHOLDER
INCLUDE HELP_PLACEHOLDER

Call a subcommand passing '-h' to see its specific options
There are three subcommands, ``update``, ``new``, and ``check``
There are four subcommands, ``update``, ``new``, ``check``, and ``version``

INCLUDE_HELP_UPDATE_PLACEHOLDER
INCLUDE HELP_UPDATE_PLACEHOLDER

INCLUDE HELP_NEW_PLACEHOLDER

INCLUDE_HELP_CHECK_PLACEHOLDER
INCLUDE HELP_CHECK_PLACEHOLDER

INCLUDE HELP_VERSION_PLACEHOLDER

Import as a library:
--------------------
Expand Down
27 changes: 20 additions & 7 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,34 @@ or (to check the content of a existing map)::

$ smap check my.map

or (to check the current version)::

$ smap version

Long version
------------

Running ``smap -h`` will give::

usage: smap [-h] {update,new,check} ...
usage: smap [-h] {update,new,check,version} ...
Helper tools for linker version script maintenance
optional arguments:
-h, --help show this help message and exit
-h, --help show this help message and exit
Subcommands:
{update,new,check} These subcommands have their own set of options
update Update the map file
new Create a new map file
check Check the map file
{update,new,check,version}
These subcommands have their own set of options
update Update the map file
new Create a new map file
check Check the map file
version Print version
Call a subcommand passing '-h' to see its specific options

Call a subcommand passing '-h' to see its specific options
There are three subcommands, ``update``, ``new``, and ``check``
There are four subcommands, ``update``, ``new``, ``check``, and ``version``

Running ``smap update -h`` will give::

Expand Down Expand Up @@ -155,6 +161,13 @@ Running ``smap check -h`` will give::
-l LOGFILE, --logfile LOGFILE
Log to this file

Running ``smap version -h`` will give::

usage: smap version [-h]
optional arguments:
-h, --help show this help message and exit

Import as a library:
--------------------

Expand Down
14 changes: 11 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@

"""The setup script."""

import os
from glob import glob
from os.path import basename
from os.path import splitext

from setuptools import find_packages
from setuptools import setup
from version import get_version

package_name = "symver-smap"
here = os.path.abspath(os.path.dirname(__file__))

with open('README.rst') as readme_file:
readme = readme_file.read()
Expand All @@ -22,6 +27,8 @@

test_requirements = ['pytest', 'pyyaml', 'pytest-cov', 'pytest-console-scripts']

version = get_version()

setup(
author="Anderson Toshiyuki Sasaki",
author_email='ansasaki@redhat.com',
Expand All @@ -44,17 +51,18 @@
long_description=readme + '\n\n' + history,
include_package_data=True,
keywords='symver smap symbol version versioning linker script library maintenance',
name='symver-smap',
name=package_name,
packages=find_packages('src'),
package_dir={'': 'src'},
py_modules=[splitext(basename(path))[0] for path in glob('src/smap/*.py')],
py_modules=[splitext(basename(path))[0] for path in glob(
os.path.join(here, 'src', 'smap', '*.py'))],
entry_points={
'console_scripts': ['smap=smap.main:main']
},
setup_requires=setup_requirements,
test_suite='tests',
tests_require=test_requirements,
url='https://github.com/ansasaki/smap',
version='0.1.0',
version=version,
zip_safe=False,
)
3 changes: 2 additions & 1 deletion src/smap/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
# flake8: noqa
from ._version import __version__

"""Top-level package for smap."""

__author__ = """Anderson Toshiyuki Sasaki"""
__email__ = 'ansasaki@redhat.com'
__version__ = '0.1.0'
1 change: 1 addition & 0 deletions src/smap/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.1.0'
Loading

0 comments on commit fa2af44

Please sign in to comment.