copier icon indicating copy to clipboard operation
copier copied to clipboard

fix: support older versions of colorama

Open em230418 opened this issue 1 year ago • 10 comments

just_fix_windows_console was introduces in colorama 0.4.6

Some stable GNU/Linux OS use packages with older version of colorama. Examples: https://packages.altlinux.org/en/p10/binary/python3-module-colorama/noarch/ https://packages.debian.org/bullseye/python3-colorama

In order to use OS specific packages with latest copier (which is required for example here https://github.com/OCA/oca-addons-repo-template/blob/master/copier.yml#L4), this patch is introduced.

em230418 avatar Nov 21 '23 05:11 em230418

If we are to accept this fix, #1403 should also be reverted, or maybe the lower bound should just be downgraded to 0.4.4.

Removing Colorama entirely would be even better ;)

pawamoy avatar Nov 21 '23 08:11 pawamoy

If we are to accept this fix, #1403 should also be reverted

Done.

em230418 avatar Nov 21 '23 10:11 em230418

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (007f830) 97.46% compared to head (4eb2484) 94.24%. Report is 1 commits behind head on master.

:exclamation: Current head 4eb2484 differs from pull request most recent head 710ddde. Consider uploading reports for the commit 710ddde to get more accurate results

Files Patch % Lines
copier/tools.py 60.00% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1421      +/-   ##
==========================================
- Coverage   97.46%   94.24%   -3.23%     
==========================================
  Files          48       48              
  Lines        4462     4466       +4     
==========================================
- Hits         4349     4209     -140     
- Misses        113      257     +144     
Flag Coverage Δ
unittests 94.24% <60.00%> (-3.23%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Nov 21 '23 15:11 codecov[bot]

Removed modification in poetry.lock and added pragma: nocover

Our supported installation methods include pipx and nix, which are both self-contained. You can use also pip and any venv implementation you want.

In copier among these installation methods, there is installation method that just makes sure, that there is minimal versions of dependecies that can be used (those dependencies are described in pyproject.toml). I use this installation method and this PR is for those people who use the same method.

It's just that older distros will happen always.

Listed distros in my first message are not ancient and are still supported.

em230418 avatar Nov 22 '23 05:11 em230418

In order to use OS specific packages with latest copier [...]

Just trying to understand the motivation for this PR better, @em230418: Why do you need to rely on a Colorama version from an OS distro? Thr oca-addons-repo-template README instructs installing Copier via pipx, so you should be able to get a recent version of Colorama. Am I missing something? :thinking:

sisp avatar Nov 22 '23 05:11 sisp

Why do you need to rely on a Colorama version from an OS distro?

Because I trust packages from OS distro more, than packages from pypi in general. That thing is not specific for colorama. As an exclusion, if is no package in OS distro, I use from ones from pypi or github.

em230418 avatar Nov 22 '23 05:11 em230418

I suppose @em230418 installs Copier like apt install python-copier (or similar OS-specific command), where python-copier is packaged by volunteers, and depends on python-colorama (or similarly named), bypassing PyPI entirely.

pawamoy avatar Nov 22 '23 13:11 pawamoy

I'd vote to entirely remove the call to Colorama. I am myself considering the removal of Colorama from my projects:

  • it's easy enough to hardcode/copy-paste a few ANSI sequences in a codebase (or use Plumbum colors in our case)
  • just_fix_windows_console is not needed in recent tools like Microsoft's Terminal, or shells running in WSL, where ANSI sequences are natively supported
  • higher-level libraries like Rich handle this transparently for us.

Obviously, there are still people using powershell, or cmd.exe through Cmder/else. But modern Windows (10) actually supports ANSI, but it's disabled by default. This SuperUser post shows how to enable it permanently. So we could tell users to do that :shrug:

pawamoy avatar Nov 22 '23 13:11 pawamoy

Ok for dropping it

yajo avatar Nov 22 '23 15:11 yajo

@em230418 do you have intentions to go ahead with this PR and remove colorama?

Marking as draft while this isn't ready.

yajo avatar Jan 15 '24 18:01 yajo