Skip to content

Commit

Permalink
Merge branch 'release-0.0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
sinoroc committed Mar 30, 2020
2 parents 5c14c00 + dfab6e8 commit df4cb9e
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 65 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@

.. Keep the current version number on line number 5
0.0.5
=====

2020-03-30

* Update 'zapp' to version '0.0.6'
* Fix call to main entry point of 'shiv'
* Add help messages for CLI options


0.0.4
=====

20120-01-09
2020-01-09

* Rewrite naming scheme for output files

Expand Down
56 changes: 56 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
..

Hacking
=======

This project makes extensive use of `tox`_, `pytest`_, and `GNU Make`_.


Development environment
-----------------------

Use following command to create a Python virtual environment with all
necessary dependencies::

tox --recreate -e develop

This creates a Python virtual environment in the ``.tox/develop`` directory. It
can be activated with the following command::

. .tox/develop/bin/activate


Run test suite
--------------

In a Python virtual environment run the following command::

make review

Outside of a Python virtual environment run the following command::

tox --recreate


Build and package
-----------------

In a Python virtual environment run the following command::

make package

Outside of a Python virtual environment run the following command::

tox --recreate -e package


.. Links
.. _`GNU Make`: https://www.gnu.org/software/make/
.. _`GNU Stow`: https://www.gnu.org/software/stow/
.. _`pytest`: https://pytest.org/
.. _`tox`: https://tox.readthedocs.io/


.. EOF
57 changes: 6 additions & 51 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
Introduction
============

This tool automates the build of Python tools according to a configuration
file. The tools can be built with `zapp`_, `shiv`_, or `pex`_.
Make single-file builds of Python tools using `zapp`_, `shiv`_, or `pex`_.


Repositories
Expand All @@ -27,8 +26,11 @@ Usage
Configuration
-------------

By default this tool looks for a configuration file ``toolmaker.cfg`` in the
current working directory.
By default this tool looks for a configuration file at the following location:

* ``${HOME}/.config/toolmaker/toolmaker.cfg`` on *Linux*

* ``%USERPROFILE%\AppData\Roaming\toolmaker\toolmaker.cfg`` on *Windows*

.. code::
Expand Down Expand Up @@ -158,60 +160,13 @@ Similar projects
* `Zapper`_


Hacking
=======

This project makes extensive use of `tox`_, `pytest`_, and `GNU Make`_.


Development environment
-----------------------

Use following command to create a Python virtual environment with all
necessary dependencies::

tox --recreate -e develop

This creates a Python virtual environment in the ``.tox/develop`` directory. It
can be activated with the following command::

. .tox/develop/bin/activate


Run test suite
--------------

In a Python virtual environment run the following command::

make review

Outside of a Python virtual environment run the following command::

tox --recreate


Build and package
-----------------

In a Python virtual environment run the following command::

make package

Outside of a Python virtual environment run the following command::

tox --recreate -e package


.. Links
.. _`GNU Make`: https://www.gnu.org/software/make/
.. _`GNU Stow`: https://www.gnu.org/software/stow/
.. _`pex`: https://pypi.org/project/pex/
.. _`pickley`: https://pypi.org/project/pickley/
.. _`pipx`: https://pipxproject.github.io/pipx/
.. _`pytest`: https://pytest.org/
.. _`shiv`: https://pypi.org/project/shiv/
.. _`tox`: https://tox.readthedocs.io/
.. _`zapp`: https://pypi.org/project/zapp/
.. _`Zapper`: https://github.com/Valassis-Digital-Media/Zapper

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ install_requires =
importlib-metadata
pex
shiv
zapp
zapp>=0.0.6
package_dir =
= src
packages = find:
Expand Down
14 changes: 14 additions & 0 deletions src/toolmaker/_i18n.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#


"""Internationalization"""


def _translate(message):
return message


_ = _translate


# EOF
10 changes: 10 additions & 0 deletions src/toolmaker/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@

import argparse

from . import _i18n
from . import _meta
from . import core


_ = _i18n._


def _create_args_parser(default_config_path, tools_names=None):
args_parser = argparse.ArgumentParser(
allow_abbrev=False,
Expand All @@ -22,29 +26,35 @@ def _create_args_parser(default_config_path, tools_names=None):
args_parser.add_argument(
'--config', '-c',
default=str(default_config_path),
help=_("configuration file (default: {})").format(default_config_path),
type=argparse.FileType('r'),
)
action_group = args_parser.add_mutually_exclusive_group()
action_group.add_argument(
'--build', '-b',
action='store_true',
help=_("build selected tool(s)"),
)
action_group.add_argument(
'--rebuild', '-r',
action='store_true',
help=_("rebuild selected tool(s)"),
)
action_group.add_argument(
'--delete', '-d',
action='store_true',
help=_("delete selected tool(s)"),
)
tools_group = args_parser.add_mutually_exclusive_group(required=True)
tools_group.add_argument(
'--all', '-a',
action='store_true',
help=_("apply action on all tools"),
)
tools_group.add_argument(
'--tools', '-t',
choices=tools_names,
help=_("apply action on this list of tools"),
metavar='tool',
nargs='+',
)
Expand Down
25 changes: 13 additions & 12 deletions src/toolmaker/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,23 @@ def _pex(requirements, entry_point, output_file_path):
def _shiv(requirements, entry_point, output_file_path):
# Since it is decorated by 'click', the 'main' function is not callable
# with its original arguments. The original function is "hidden" under
# 'callback'.
shiv.cli.main.callback(
str(output_file_path), # output_file
entry_point, # entry_point
None, # console_script
'/usr/bin/env python3', # python
None, # site_packages
True, # compressed
False, # compile_pyc
False, # extend_pythonpath
requirements, # pip_args
# 'shiv.cli.main.callback', and 'shiv.cli.main' takes the equivalent of
# 'sys.argv' instead.
shiv.cli.main( # pylint: disable=no-value-for-parameter
[
'--output-file', str(output_file_path),
'--entry-point', entry_point, # entry_point
'--python', '/usr/bin/env python3',
] + requirements,
)


def _zapp(requirements, entry_point, output_file_path):
zapp.core.build_zapp(requirements, entry_point, output_file_path)
zapp.core.build_zapp(
output_file_path,
entry_point,
requirements=requirements,
)


def _get_requirements(config):
Expand Down

0 comments on commit df4cb9e

Please sign in to comment.