While publishing a Python package to a private repository with Poetry, the "- Uploading {file} {percentage}" line gets printed three times for each file instead of once:
The body of the poetry.masonry.publishing.uploader._upload_file method indicates that a requests_toolbelt.multipart.MultipartEncoderMonitor decorator is used with a lambda monitor: bar.set_progress(monitor.bytes_read) callback. Here the progress bar is an instance of the clikit.ui.components.progress_bar.ProgressBar class. Looking at the method clikit.ui.components.progress_bar.ProgressBar.__init__ method, we see that output overwrite is disabled when the self._io.error_output.supports_ansi function considers that the output does not support ANSI code pages.
On Windows:
ANSI code pages (such as CP-1252) are used for applications with a graphical user interface;
OEM code pages (such as CP-437 or CP-850) are used for applications with a textual user interface.
I am using Powershell 5.1 with the default OEM code page CP-850. Since it is not an ANSI code page, Poetry output is expected. However, switching to the ANSI code page CP-1252 gives the same output:
So the only solution is to force ANSI output using the --ansi command-line argument:
$ poetry publish --ansi -r local -u . -p .
Publishing file_proxy (0.0.1) to local
- Uploading file_proxy-0.0.1-py3-none-any.whl 100%
- Uploading file_proxy-0.0.1.tar.gz 100%
But this is a workaround. Why does the self._io.error_output.supports_ansi function considers that Powershell 5.1 does not support ANSI code pages when using the ANSI code page CP-1252?
While publishing a Python package to a private repository with Poetry, the "- Uploading {file} {percentage}" line gets printed three times for each file instead of once:
The body of the
poetry.masonry.publishing.uploader._upload_file
method indicates that arequests_toolbelt.multipart.MultipartEncoderMonitor
decorator is used with alambda monitor: bar.set_progress(monitor.bytes_read)
callback. Here the progress bar is an instance of theclikit.ui.components.progress_bar.ProgressBar
class. Looking at the methodclikit.ui.components.progress_bar.ProgressBar.__init__
method, we see that output overwrite is disabled when theself._io.error_output.supports_ansi
function considers that the output does not support ANSI code pages.On Windows:
I am using Powershell 5.1 with the default OEM code page CP-850. Since it is not an ANSI code page, Poetry output is expected. However, switching to the ANSI code page CP-1252 gives the same output:
So the only solution is to force ANSI output using the
--ansi
command-line argument:But this is a workaround. Why does the
self._io.error_output.supports_ansi
function considers that Powershell 5.1 does not support ANSI code pages when using the ANSI code page CP-1252?