gh-action-pypi-publish icon indicating copy to clipboard operation
gh-action-pypi-publish copied to clipboard

Disable the progress bar when exec `twine upload`

Open shenxianpeng opened this issue 10 months ago • 16 comments

Closes #229. I looked at twine's help and added a new input no-color for this action.

twine --help
usage: twine [-h] [--version] [--no-color] {check,upload,register}

positional arguments:
  {check,upload,register}

options:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --no-color            disable colored output

shenxianpeng avatar Apr 21 '24 15:04 shenxianpeng

The CI doesn't test this case, which is necessary to ensure this keeps working over time. Also, it might make sense to just do this unconditionally.

webknjaz avatar Apr 21 '24 16:04 webknjaz

So let's see if the output is good enough to avoid exposing another API toggle to the end-users.

webknjaz avatar Apr 21 '24 16:04 webknjaz

Also, it might make sense to just do this unconditionally.

OK. I'll leave it on by default, this time could be as a test.

shenxianpeng avatar Apr 22 '24 02:04 shenxianpeng

The CI run is now approved, let's see..

webknjaz avatar Apr 22 '24 09:04 webknjaz

Looks like the lockfile needs updating.

webknjaz avatar Apr 22 '24 10:04 webknjaz

I retried the option --no-color from my local, the right command should be twine --no-color upload dist/* not twine upload --no-color dist/*, I hope I can adjust --no-color before upload.

shenxianpeng avatar Apr 22 '24 10:04 shenxianpeng

I have moved the position of --no-color before upload when no-color=true. could you approve to run CI again? thank you.

shenxianpeng avatar Apr 22 '24 10:04 shenxianpeng

Sure. Though, I'm not sure anymore if disabling color altogether is good. I'd rather disable progress bars but not the colorizarion. Perhaps, the Twine upstream needs to be consulted..

webknjaz avatar Apr 22 '24 11:04 webknjaz

I have tested the following commands to upload to testpypi, and both work with Python 3.11. and Python 3.12.

twine --no-color upload dist/* --repository testpypi
twine upload dist/* --repository testpypi
root@eca5ed1e5006:/src# twine --no-color upload dist/* --repository testpypi
Uploading distributions to https://test.pypi.org/legacy/
WARNING  Error getting password from keyring
         Traceback (most recent call last):
           File "/usr/local/lib/python3.12/site-packages/twine/auth.py", line 81, in get_password_from_keyring
             return cast(str, keyring.get_password(system, username))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           File "/usr/local/lib/python3.12/site-packages/keyring/core.py", line 56, in get_password
             return get_keyring().get_password(service_name, username)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           File "/usr/local/lib/python3.12/site-packages/keyring/backends/fail.py", line 28, in get_password
             raise NoKeyringError(msg)
         keyring.errors.NoKeyringError: No recommended backend was available. Install a recommended 3rd party backend package; or, install the
         keyrings.alt package if you want to use the non-recommended backends. See https://pypi.org/project/keyring for details.
Enter your API token:
Uploading clang_tools-0.11.1.post1.dev5-py3-none-any.whl
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 19.9/19.9 kB • 00:00 • 19.3 MB/s
Uploading clang_tools-0.11.1.post1.dev5.tar.gz
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 79.1/79.1 kB • 00:00 • 171.3 MB/s

View at:
https://test.pypi.org/project/clang-tools/0.11.1.post1.dev5/
root@eca5ed1e5006:/src# python3 -V
Python 3.12.3
root@eca5ed1e5006:/src#

I'll try again soon to find the cause.

shenxianpeng avatar Apr 22 '24 16:04 shenxianpeng

I still think that it's best to get Twine to implement something like --no-animation instead and keep the color on.

webknjaz avatar Apr 25 '24 01:04 webknjaz

Thanks for the hint. twine upload supports --disable-progress-bar, which I hadn't realized before. this should be what you need.

shenxianpeng avatar Apr 25 '24 02:04 shenxianpeng

pre-commit.ci works in my local environment. 🤔

~/r/s/gh-action-pypi-publish (feature/support-no-color)> pre-commit run --all-files
Add trailing commas.......................................................Passed
isort.....................................................................Passed
Tabs remover..............................................................Passed
Validate GitHub Actions...................................................Passed
Validate GitHub Workflows.................................................Passed
Check GitHub Workflows set timeout-minutes................................Passed
Validate ReadTheDocs Config...........................(no files to check)Skipped
fix end of files..........................................................Passed
trim trailing whitespace..................................................Passed
mixed line ending.........................................................Passed
python tests naming...................................(no files to check)Skipped
check for added large files...............................................Passed
check BOM - deprecated: use fix-byte-order-marker.........................Passed
check for case conflicts..................................................Passed
check that executables have shebangs......................................Passed
check for merge conflicts.................................................Passed
check json............................................(no files to check)Skipped
check for broken symlinks.............................(no files to check)Skipped
check yaml................................................................Passed
detect private key........................................................Passed
check python ast..........................................................Passed
debug statements (python).................................................Passed
codespell.................................................................Passed
yamllint..................................................................Passed
flake8 WPS-excluded.......................................................Passed
flake8 WPS-only...........................................................Passed
pylint....................................................................Passed
Verify that enforced flake8 version stays unchanged.......................Passed

shenxianpeng avatar Apr 25 '24 02:04 shenxianpeng

pre-commit.ci works in my local environment. 🤔

pre-commit.ci upgraded their runtime to Python 3.12 yesterday which is incompatible with some linting configuration present. I'll address that separately.

webknjaz avatar Apr 25 '24 03:04 webknjaz

pre-commit.ci upgraded their runtime to Python 3.12 yesterday which is incompatible with some linting configuration present. I'll address that separately.

Maybe can use default_language_version to pin the runtime version to the previous version. for example:

default_language_version:
    python: python3.11

shenxianpeng avatar Apr 25 '24 04:04 shenxianpeng

That's what I used elsewhere. But it's not something that's in the scope of this PR so let's keep it atomic.

webknjaz avatar Apr 25 '24 22:04 webknjaz

Yes. I rebased my commits and it's ready to run CI and your review.

shenxianpeng avatar Apr 26 '24 16:04 shenxianpeng