console icon indicating copy to clipboard operation
console copied to clipboard

pip 24.1.1 doesn't like console

Open arkarkark opened this issue 1 year ago • 10 comments

when I update pip to 24.1.1 it doesn't like console anymore.

WARNING: Error parsing dependencies of console: Invalid version: 'Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000'

pip says this is a valid warning

and you can no longer install console

#pip install console
Collecting console
  Using cached console-0.9907-py2.py3-none-any.whl.metadata (17 kB)
ERROR: Exception:
...
   raise InvalidVersion(f"Invalid version: '{version}'")
pip._vendor.packaging.version.InvalidVersion: Invalid version: 'Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000'

arkarkark avatar Jul 04 '24 19:07 arkarkark

(copied for convenience.)

Believe the error it's coming from this in setup.py:

install_requires = (
    'colorama;            os_name == "nt" and platform_version < "10.0.10586" ',
)
  1. I checked on Win/Lin/Mac and only on Windows does platform.version() return a version-like string. I think that's the root issue. A broken or at least inconsistent platform.version() result. Other available environment selectors are not sufficient to do this job.

(The job being to install colorama if using an older Windows 10 that doesn't support ANSI escape chars.)

  1. This environment selector selects os_name == "nt" first, so on non-NT environments it should finish there and not go on. This is standard boolean logic, if it needs to run both tests when not necessary that's another bug/enhancement to be done.

  2. Your pip/setuptools version parser can't handle real world output from platform.version. Setuptools shouldn't be strict here until platform or selectors can be fixed/redesigned.

mixmastamyk avatar Jul 07 '24 05:07 mixmastamyk

I can remove this check, but it used to work. So in my opinion is a regression on their side.

mixmastamyk avatar Jul 07 '24 05:07 mixmastamyk

Is there any update on this issue? I've had to essentially just copy all of the scripts from this package into almost all of my projects until now.

An1nterestingName avatar Nov 08 '24 17:11 An1nterestingName

@SomeGuyNamedJJ ... there's nothing to update here unfortunately. It is their bug, as far as I can tell.

If you don't use Windows you can clone the repo and comment this line here:

https://github.com/mixmastamyk/console/blob/master/setup.py#L17

Then pip install . or run setup.py. Or you could downgrade pip until they fix it.

mixmastamyk avatar Nov 11 '24 01:11 mixmastamyk

This is the root issue I think:

https://github.com/pypa/packaging/issues/774

mixmastamyk avatar Nov 11 '24 01:11 mixmastamyk

@mixmastamyk I did try to do what you suggested a while ago, but just running setup.py caused some wierd behavior where the entire thing just moved itself into a subfolder, but I had no idea that you could use pip to install from somewhere locally, I will try that, but obviously it is not a permanent fix.

Edit: As for downgrading pip, there's no point in me doing that, as I use Arch, so pretty much everything gets updated at once, and I'd have to specifically add an exception for pip every time I update (typically weekly)

An1nterestingName avatar Nov 11 '24 18:11 An1nterestingName

I commented at the issue linked above and it seems to have started a snowball of discussion. Maybe they will fix it?

Pip can manage itself, might be better to let it. However distros often let you pin an old version. Whichever way is best for you.

mixmastamyk avatar Nov 12 '24 02:11 mixmastamyk

I confirm - I tried (just now, because of issues due to PEP 668) pipx. The console package evidently makes it crash

  File "/home/user/.local/pipx/shared/lib/python3.10/site-packages/pip/_vendor/packaging/version.py", line 202, in __init__
    raise InvalidVersion(f"Invalid version: {version!r}")
pip._vendor.packaging.version.InvalidVersion: Invalid version: '#40~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 16 10:53:04 UTC 2'
'/home/user/.local/pipx/venvs/spesh/bin/python -m pip install --pre --upgrade spesh -q' failed

Thank you for looking at this topic, I like console very much

jaromrax avatar Mar 21 '25 08:03 jaromrax

May be something with PEP440 numbering? Or metadata in setup.py?

jaromrax avatar Mar 21 '25 09:03 jaromrax

The issue is that they broke pip (as described above) and aren't inclined to fix it. There are some fiddly work arounds above but I recently found a better one—move to uv/uvx. It really works, and its developers are responsive:

https://docs.astral.sh/uv/

(Not mentioned there but it is also installable via dnf in Fedora)

⏵ uv init new
Initialized project `new` at `.../new`
⏵ cd new/
⏵ uv add console
Using CPython 3.13.2 interpreter at: /usr/bin/python3.13
Creating virtual environment at: .venv
Resolved 6 packages in 126ms
Installed 2 packages in 3ms
 + console==0.9911
 + ezenv==0.92
⏵ source .venv/bin/activate.fish
(new) ⏵ python
Python 3.13.2 (...) on linux
>>> from console import fg, bg, fx
>>> print(fg.green('hello world'))
hello world  # green

mixmastamyk avatar Mar 21 '25 17:03 mixmastamyk

not pointing fingers here but a year+ later this is still broken. I recognize where the source of the problem is (PIP) but dismissing it as the predominant python package installer feels a smidge short sighted to me.

ya know what they say about everyone having an opinion... wanted or not you now have mine.

synman avatar Oct 13 '25 22:10 synman

Got it. I gave up on pypa a while ago, moved to uv, and have been very happy with it.

It's not clear to me how many people use this library besides myself since I've never advertised it. Do many people want to use it with pip? Not able to upgrade to uv, for various reasons?

mixmastamyk avatar Oct 13 '25 22:10 mixmastamyk

here's your audience: https://pypistats.org/packages/console

I am but one :)

My own usage is for an unreleased console driven test app I use as a test harness for a library I maintain.... and it's limited to a single function wait_key

while True: 
    key = wait_key()
    if key == "\x1b": 
        special = True
        continue
    if special:
        if key == "[": continue
        if key == "C":  # right arrow
            print("\rmove right\r")
        if key == "D":  # left arrow
            print("\rmove left\r")
        special = False
        continue

    if not special and key == "\r":
        print("\r")

    if key == "?":
        print("\r\nCommands:\r\n")
        print("   ? = this list\r")
        print("   b = bed target temperature\r")
        print("   c = chamber target temperature\r")
        print("   d = dump printer json object\r")
        print("   g = send gcode command\r")
        print("   f = fan speed (in percent)\r")
        print("   l = toggle light\r")
        print("   o = print options\r")
        print("   p = print 3MF file\r")
        print("   q = quit\r")
        print("   Q = restart without exiting")
        print("   r = request full data refresh\r")
        print("   s = change filament / spool\r")
        print("   S = change speed (1 to 4)\r")
        print("   t = tool target temperature\r")
        print("   u = unload filament / spool\r")
        print("   v = toggle verbose reporting\r")
        print("   w = wifi signal strength\r")
        print("   X = extrustion calibration\r")
        print("   x = set extrustion calibration results\r")
        print("   ! = abort job\r")
        print("   ~ = toggle subscription\n\r")

so bringing in a completely different package installer breaks my workflow. Right now I'm froze on pip 24.1 hoping this magically gets fixed.

synman avatar Oct 14 '25 00:10 synman

you can further get a feel for pip vs uv too

https://pypistats.org/packages/pip https://pypistats.org/packages/uv

pip leads by about 6 to 1 usage wise.

I'll be quiet now. appreciate the convenience of the package you provide regardless.

synman avatar Oct 14 '25 01:10 synman

Hmm, wonder how many of those downloading console are bots?

Also, I get uv from my linux distribution and some use cargo/rustup etc. Some might get pip from distros as well. So not sure how accurate that proportion of downloads is.

Interestingly this is on HN today:


I guess I could disable the environment marker in setup now that Windows 10 is going EOL. By another coincidence that happens tomorrow. Maybe the universe is trying to tell me something.

(To be honest this is not the outcome I expected, that pypa would break pip and then just sit there and do nothing for over a year/indefinitely.)

mixmastamyk avatar Oct 14 '25 03:10 mixmastamyk

I use macOS as my development ABI / runtime.

one would think pypi would be pretty legit stats wise. bots are probably in the low hundreds per month but I ack it is possibly proportional to the popularity of the library.

I'm also going to take a leap here and assume CI is Continuous Integration -- aka enterprise / non consumer / non human driven builds. I'd be just as curious to understand better how they determined uv was "winning" lol as CI is managed by a large range of tools / solutions / integrations.

I 100% agree about the pip situation. It has historically been frustrating for a lot of different groups.

synman avatar Oct 14 '25 05:10 synman

should mention I am also heavily invested in pyenv and virtualenvwrapper

synman avatar Oct 14 '25 05:10 synman

I made an update to remove the marker and pushed a prerelease build. To install it use something like:

pip install -U --pre console

Would like to know if it works for you.

mixmastamyk avatar Oct 15 '25 03:10 mixmastamyk

Bueller?

mixmastamyk avatar Oct 15 '25 23:10 mixmastamyk

will take a look... was not expecting immediate relief!!! woohoo !!!

synman avatar Oct 16 '25 20:10 synman

worked like a charm

(bpm) shell@shells-16mbp ~ %  python -m pip install --upgrade pip
Requirement already satisfied: pip in ./.virtualenvs/bpm/lib/python3.12/site-packages (24.0)
Collecting pip
  Downloading pip-25.2-py3-none-any.whl.metadata (4.7 kB)
Downloading pip-25.2-py3-none-any.whl (1.8 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 MB 9.1 MB/s eta 0:00:00
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 24.0
    Uninstalling pip-24.0:
      Successfully uninstalled pip-24.0
Successfully installed pip-25.2
(bpm) shell@shells-16mbp ~ % pip install -U --pre console
Collecting console
  Downloading console-0.9912b1-py3-none-any.whl.metadata (18 kB)
Requirement already satisfied: ezenv>=0.92 in ./.virtualenvs/bpm/lib/python3.12/site-packages (from console) (0.92)
Downloading console-0.9912b1-py3-none-any.whl (96 kB)
Installing collected packages: console
Successfully installed console-0.9912b1
(bpm) shell@shells-16mbp ~ % GitHub/bambu-mqtt/bambu-mqtt.py 

Model #: A1
restoring chamber target to [0.0]

printer firmware: [] serial #: [xxx]
ams firmware: []

tool=[23.8/0.0] bed=[22.3/0.0] chamber=[24.7/0.0] fan=[0] print=[FINISH] speed=[2] light=[off]
stg_cur=[] file=[] layers=[231] layer=[231] %=[100] eta=[0 min] spool=[255 (Unloaded)]
buildplate_marker_detector=[True]

printer firmware: [01.05.00.00] serial #: [xxx]
ams firmware: [00.00.07.94]

tool=[23.8/0.0] bed=[22.3/0.0] chamber=[24.7/0.0] fan=[0] print=[FINISH] speed=[2] light=[off]
stg_cur=[] file=[] layers=[231] layer=[231] %=[100] eta=[0 min] spool=[255 (Unloaded)]
buildplate_marker_detector=[True]

Commands:

   ? = this list
   b = bed target temperature
   c = chamber target temperature
   d = dump printer json object
   g = send gcode command
   f = fan speed (in percent)
   l = toggle light
   o = print options
   p = print 3MF file
   q = quit
   Q = restart without exiting
   r = request full data refresh
   s = change filament / spool
   S = change speed (1 to 4)
   t = tool target temperature
   u = unload filament / spool
   v = toggle verbose reporting
   w = wifi signal strength
   X = extrustion calibration
   x = set extrustion calibration results
   ! = abort job
   ~ = toggle subscription
   P = toggle buildplate_marker_detector

synman avatar Oct 16 '25 20:10 synman

Ok, well with Windows 10 EOL there is no reason for the colorama package any longer. So might as well remove it. The irony is that line only broke it on Linux. I'll have a regular release out soon.

mixmastamyk avatar Oct 16 '25 22:10 mixmastamyk

Fixed with console version 0.9912.

mixmastamyk avatar Oct 17 '25 21:10 mixmastamyk