Commit be3be634 by Sébastien Eustace Committed by GitHub

Merge pull request #2715 from python-poetry/improve-build-command-display-output

Display logging messages from poetry-core when building
parents f57d22e9 8d54665a
...@@ -77,4 +77,4 @@ jobs: ...@@ -77,4 +77,4 @@ jobs:
- name: Run pytest - name: Run pytest
shell: bash shell: bash
run: poetry run pytest -v tests run: poetry run python -m pytest -v tests
...@@ -13,6 +13,7 @@ class BuildCommand(EnvCommand): ...@@ -13,6 +13,7 @@ class BuildCommand(EnvCommand):
] ]
loggers = [ loggers = [
"poetry.core.masonry.builders.builder",
"poetry.core.masonry.builders.sdist", "poetry.core.masonry.builders.sdist",
"poetry.core.masonry.builders.wheel", "poetry.core.masonry.builders.wheel",
] ]
......
...@@ -90,6 +90,11 @@ class ApplicationConfig(BaseApplicationConfig): ...@@ -90,6 +90,11 @@ class ApplicationConfig(BaseApplicationConfig):
logger.handlers = [handler] logger.handlers = [handler]
level = logging.WARNING level = logging.WARNING
# The builders loggers are special and we can actually
# start at the INFO level.
if logger.name.startswith("poetry.core.masonry.builders"):
level = logging.INFO
if io.is_debug(): if io.is_debug():
level = logging.DEBUG level = logging.DEBUG
elif io.is_very_verbose() or io.is_verbose(): elif io.is_very_verbose() or io.is_verbose():
......
...@@ -2,6 +2,7 @@ from .builder_formatter import BuilderLogFormatter ...@@ -2,6 +2,7 @@ from .builder_formatter import BuilderLogFormatter
FORMATTERS = { FORMATTERS = {
"poetry.core.masonry.builders.builder": BuilderLogFormatter(),
"poetry.core.masonry.builders.sdist": BuilderLogFormatter(), "poetry.core.masonry.builders.sdist": BuilderLogFormatter(),
"poetry.core.masonry.builders.wheel": BuilderLogFormatter(), "poetry.core.masonry.builders.wheel": BuilderLogFormatter(),
} }
...@@ -5,9 +5,17 @@ from .formatter import Formatter ...@@ -5,9 +5,17 @@ from .formatter import Formatter
class BuilderLogFormatter(Formatter): class BuilderLogFormatter(Formatter):
def format(self, msg): # type: (str) -> str def format(self, msg): # type: (str) -> str
if msg.startswith(" - Building ") or msg.startswith(" - Built "): if msg.startswith("Building "):
msg = re.sub(r" - (Buil(?:t|ing)) (.+)", " - \\1 <c2>\\2</c2>", msg) msg = re.sub("Building (.+)", " - Building <info>\\1</info>", msg)
elif msg.startswith(" - Adding: "): elif msg.startswith("Built "):
msg = re.sub(r" - Adding: (.+)", " - Adding: <b>\\1</b>", msg) msg = re.sub("Built (.+)", " - Built <success>\\1</success>", msg)
elif msg.startswith("Adding: "):
msg = re.sub("Adding: (.+)", " - Adding: <b>\\1</b>", msg)
elif msg.startswith("Executing build script: "):
msg = re.sub(
"Executing build script: (.+)",
" - Executing build script: <b>\\1</b>",
msg,
)
return msg return msg
...@@ -5,13 +5,7 @@ class IOHandler(logging.Handler): ...@@ -5,13 +5,7 @@ class IOHandler(logging.Handler):
def __init__(self, io): def __init__(self, io):
self._io = io self._io = io
level = logging.WARNING super(IOHandler, self).__init__()
if io.is_debug():
level = logging.DEBUG
elif io.is_very_verbose() or io.is_verbose():
level = logging.INFO
super(IOHandler, self).__init__(level)
def emit(self, record): def emit(self, record):
try: try:
......
...@@ -24,7 +24,7 @@ classifiers = [ ...@@ -24,7 +24,7 @@ classifiers = [
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "~2.7 || ^3.5" python = "~2.7 || ^3.5"
poetry-core = "^1.0.0a8" poetry-core = "^1.0.0a9"
cleo = "^0.8.1" cleo = "^0.8.1"
clikit = "^0.6.2" clikit = "^0.6.2"
crashtest = { version = "^0.3.0", python = "^3.6" } crashtest = { version = "^0.3.0", python = "^3.6" }
......
...@@ -105,6 +105,7 @@ Classifier: Programming Language :: Python :: 3.5 ...@@ -105,6 +105,7 @@ Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Software Development :: Build Tools Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Software Development :: Libraries :: Python Modules
Project-URL: Documentation, https://python-poetry.org/docs Project-URL: Documentation, https://python-poetry.org/docs
......
...@@ -107,6 +107,7 @@ def test_create_poetry(): ...@@ -107,6 +107,7 @@ def test_create_poetry():
"Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Software Development :: Build Tools", "Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Libraries :: Python Modules",
] ]
......
...@@ -639,7 +639,7 @@ def test_create_venv_tries_to_find_a_compatible_python_executable_using_specific ...@@ -639,7 +639,7 @@ def test_create_venv_tries_to_find_a_compatible_python_executable_using_specific
mocker.patch("sys.version_info", (2, 7, 16)) mocker.patch("sys.version_info", (2, 7, 16))
mocker.patch( mocker.patch(
"poetry.utils._compat.subprocess.check_output", side_effect=["3.5.3", "3.8.0"] "poetry.utils._compat.subprocess.check_output", side_effect=["3.5.3", "3.9.0"]
) )
m = mocker.patch( m = mocker.patch(
"poetry.utils.env.EnvManager.build_venv", side_effect=lambda *args, **kwargs: "" "poetry.utils.env.EnvManager.build_venv", side_effect=lambda *args, **kwargs: ""
...@@ -648,7 +648,7 @@ def test_create_venv_tries_to_find_a_compatible_python_executable_using_specific ...@@ -648,7 +648,7 @@ def test_create_venv_tries_to_find_a_compatible_python_executable_using_specific
manager.create_venv(NullIO()) manager.create_venv(NullIO())
m.assert_called_with( m.assert_called_with(
Path("/foo/virtualenvs/{}-py3.8".format(venv_name)), executable="python3.8" Path("/foo/virtualenvs/{}-py3.9".format(venv_name)), executable="python3.9"
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment