Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display logging messages from poetry-core when building #2715

Merged
merged 2 commits into from
Jul 24, 2020
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: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ jobs:

- name: Run pytest
shell: bash
run: poetry run pytest -v tests
run: poetry run python -m pytest -v tests
82 changes: 35 additions & 47 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions poetry/console/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class BuildCommand(EnvCommand):
]

loggers = [
"poetry.core.masonry.builders.builder",
"poetry.core.masonry.builders.sdist",
"poetry.core.masonry.builders.wheel",
]
Expand Down
5 changes: 5 additions & 0 deletions poetry/console/config/application_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ def register_command_loggers(
logger.handlers = [handler]

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():
level = logging.DEBUG
elif io.is_very_verbose() or io.is_verbose():
Expand Down
1 change: 1 addition & 0 deletions poetry/console/logging/formatters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


FORMATTERS = {
"poetry.core.masonry.builders.builder": BuilderLogFormatter(),
"poetry.core.masonry.builders.sdist": BuilderLogFormatter(),
"poetry.core.masonry.builders.wheel": BuilderLogFormatter(),
}
16 changes: 12 additions & 4 deletions poetry/console/logging/formatters/builder_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@

class BuilderLogFormatter(Formatter):
def format(self, msg): # type: (str) -> str
if msg.startswith(" - Building ") or msg.startswith(" - Built "):
msg = re.sub(r" - (Buil(?:t|ing)) (.+)", " - \\1 <c2>\\2</c2>", msg)
elif msg.startswith(" - Adding: "):
msg = re.sub(r" - Adding: (.+)", " - Adding: <b>\\1</b>", msg)
if msg.startswith("Building "):
msg = re.sub("Building (.+)", " - Building <info>\\1</info>", msg)
elif msg.startswith("Built "):
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
8 changes: 1 addition & 7 deletions poetry/console/logging/io_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ class IOHandler(logging.Handler):
def __init__(self, io):
self._io = io

level = logging.WARNING
if io.is_debug():
level = logging.DEBUG
elif io.is_very_verbose() or io.is_verbose():
level = logging.INFO

super(IOHandler, self).__init__(level)
super(IOHandler, self).__init__()

def emit(self, record):
try:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ classifiers = [
[tool.poetry.dependencies]
python = "~2.7 || ^3.5"

poetry-core = "^1.0.0a8"
poetry-core = "^1.0.0a9"
cleo = "^0.8.1"
clikit = "^0.6.2"
crashtest = { version = "^0.3.0", python = "^3.6" }
Expand Down
1 change: 1 addition & 0 deletions tests/masonry/builders/test_editable_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def test_builder_installs_proper_files_for_standard_packages(simple_poetry, tmp_
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Project-URL: Documentation, https://python-poetry.org/docs
Expand Down
1 change: 1 addition & 0 deletions tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def test_create_poetry():
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Libraries :: Python Modules",
]
Expand Down
4 changes: 2 additions & 2 deletions tests/utils/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"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(
"poetry.utils.env.EnvManager.build_venv", side_effect=lambda *args, **kwargs: ""
Expand All @@ -648,7 +648,7 @@ def test_create_venv_tries_to_find_a_compatible_python_executable_using_specific
manager.create_venv(NullIO())

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"
)


Expand Down