Convert colorama into an optional dependency
I propose an update to the list of dependecies required to use icecream.
Right now, we have to install colorama on all platforms, despite the fact that ic will run properly on some operating systems even without colorama presented.
As stated, I suggest:
- Converting colorama into an optional dependecy;
- Wrapping colorama import and initialization in a platform-dependent if-block;
- Some refactoring to the icecream.py;
I have no problem with an optional colorama dependency, per se. But let's back up quickly to make sure we're all on the same page and tackling the right problem.
Why would you like to move colorama to an optional dependency? For example
- Faster import speeds? (fewer imports = faster import speed)
- Smaller install footprint? (ie faster install speed, smaller size on disk)
- You want color disabled by default?
And/or other reason(s) entirely.
Thanks for your attention, @gruns!
I'm using pipenv as the main tool for dependency management.
It allows me to set platform specific dependencies. For example:
uvloop = {version = "==0.14.0", markers = "sys_platform != 'win32' and implementation_name == 'cpython'"}
colorama = {version = "==0.4.3", markers = "sys_platform == 'win32' and implementation_name == 'cpython'"}
As you know less dependecies means less version conflicts, less security issues etc. So usually I prefer to not install colorama on windows.
pipenv also supports a lock-file - automatically generated file that helps with the validation of a checksum of a package before installing it.
It's a very useful security feature, but pipenv always pushes colorama's platform marker into lock-file, if me or one of my teammates generates this lock-file on Windows.
And after that, we cannot run our project reliably in a non-windows environment, since colorama won't be presented in python's environment, but icecream will be.
Maybe this concrete issue (pipenv + icecream + colorama) should be solved through pipenv's repo, but their release cycle is unbelievably long. So I've started with icream at first.
Thank you for expounding; I understand your predicament much better now.
It's a very useful security feature, but pipenv always pushes colorama's platform marker into lock-file This is the money line.
From Googling, we're not the first to be bitten by this: https://github.com/pypa/pipenv/issues/3902.
-
Does the
--keep-outdatedpipenv flag resolve the problem for you -- either with pipenv2018.11.26(the last stable release) or master? I unfortunately don't have a Windows machine to test on. -
Since pipenv's release cycle is glacial, nigh deceased, can this be fixed from colorama's end?
-
Does Poetry (https://python-poetry.org/) suffer the same problem here?
If none of the above are satisfactory, perhaps it's time indeed to turn colorama into an optional icecream dependency.
Sorry, @gruns, was a little bit busy with my work.
Answering your questions:
- I've tried
--keep-outdate, but without any luck - problem was still present. - I doubt
coloramacan solve this issue.Coloramais a Windows specific package, and it makes sense for them to not be installed on any other platform. - It might be a solution, but I'm an active
pipenvuser and it will be nuisance to switch to another package manager, and to enforce a new package manager tool for my dev team.
pipenv published a new release recently. I've checked the described problem, but it's still present, sadly - if i'm trying to generate a lock-file on Windows platform pipenv converts colorama a Windows specific dependency.
Marking colorama as platform_system=='Windows' in setup.py should do the trick nicely and avoid runtime if sys.platform.startswith('win'): checks.
- https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-platform-specific-dependencies
One problem: I don't have ready access to a Window machine to test. @VaultVulp Would you be able to graciously continue to assist and test on Windows?
For sure, @gruns, I'll help you.
But if we do not move colorama's import under an if-case, Python will try to import colorama and fail with the ModuleNotFoundError.
Hi, folks! You asked for my help @gruns , can I help you with anything?