Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ Breaking Changes
- Binary distributions are now built via the sdist by default in the CLI (`PR #304`_, Fixes `#257`_)
- ``python -m build`` will now build a sdist, extract it, and build a wheel from the source
- As a side-effect of `PR #304`_, ``build.__main__.build_package`` no longer does CLI error handling (print nice message and exit the program)
- Importing ``build.__main__`` no longer has any side-effects, it no longer overrides ``warnings.showwarning`` or runs ``colorama.init`` on import (`PR #312`_)

.. _PR #303: https://github.com/pypa/build/pull/303
.. _PR #304: https://github.com/pypa/build/pull/304
.. _PR #312: https://github.com/pypa/build/pull/312
.. _#257: https://github.com/pypa/build/issues/257
.. _#301: https://github.com/pypa/build/issues/301

Expand Down
19 changes: 10 additions & 9 deletions src/build/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@
from build.env import IsolatedEnvBuilder


try:
import colorama
except ImportError:
pass
else:
colorama.init() # fix colors on windows


__all__ = ['build', 'main', 'main_parser']


Expand All @@ -51,7 +43,15 @@ def _showwarning(message, category, filename, lineno, file=None, line=None): #
print('{} {}'.format(prefix, str(message)))


warnings.showwarning = _showwarning
def _setup_cli(): # type: () -> None
warnings.showwarning = _showwarning

try:
import colorama
except ImportError:
pass
else:
colorama.init() # fix colors on windows


def _error(msg, code=1): # type: (str, int) -> None # pragma: no cover
Expand Down Expand Up @@ -264,6 +264,7 @@ def main(cli_args, prog=None): # type: (List[str], Optional[str]) -> None # no
:param cli_args: CLI arguments
:param prog: Program name to show in help text
"""
_setup_cli()
parser = main_parser()
if prog:
parser.prog = prog
Expand Down