Skip to content

updated to digikey v4 and python 3.12#51

Open
hurricaneJoef wants to merge 2 commits into
peeter123:masterfrom
hurricaneJoef:master
Open

updated to digikey v4 and python 3.12#51
hurricaneJoef wants to merge 2 commits into
peeter123:masterfrom
hurricaneJoef:master

Conversation

@hurricaneJoef

Copy link
Copy Markdown

No description provided.

@eeintech

eeintech commented Jul 3, 2024

Copy link
Copy Markdown

Hello @hurricaneJoef thanks for your work! Is your fork compatible with Python 3.10+ versions or is it exclusive to Python 3.12+ versions?

@hurricaneJoef

hurricaneJoef commented Jul 3, 2024

Copy link
Copy Markdown
Author

I have not tested it yet on 3.10 but its not using anything specific to 3.12 or 3.11. please let me know if it does work

@eeintech

eeintech commented Jul 3, 2024

Copy link
Copy Markdown

Sounds good, thanks!

@eeintech

eeintech commented Oct 15, 2024

Copy link
Copy Markdown

@hurricaneJoef I am not able to install without the fixes in #47, would you be able to pull those in?

The error I get:

  File "/home/francois/development/Ki-nTree/kintree/search/digikey_api.py", line 3, in <module>
    import digikey
  File "/home/francois/development/Ki-nTree/.venv/lib/python3.12/site-packages/digikey/__init__.py", line 1, in <module>
    from digikey.v4.api import (keyword_search, product_details, digi_reel_pricing, suggested_parts,
  File "/home/francois/development/Ki-nTree/.venv/lib/python3.12/site-packages/digikey/v4/api.py", line 3, in <module>
    from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils'

@T0jan

T0jan commented Oct 15, 2024

Copy link
Copy Markdown

@nabelekt

nabelekt commented Nov 22, 2024

Copy link
Copy Markdown

Does anybody here know if there is a fork of this library being maintained that has both these changes and those from #47 merged in?
@hurricaneJoef, @eeintech, @T0jan, @hvraven, @G-Pereira, @peeter123
Thanks

Edit: For now, I am switching to @hurricaneJoef's fork. Here are some commands to do that, in case anyone else wants to:

pip uninstall digikey-api
pip install git+https://github.com/hurricaneJoef/digikey-api.git

@eeintech

Copy link
Copy Markdown

Edit: For now, I am switching to @hurricaneJoef's fork. Here are some commands to do that, in case anyone else wants to:

pip uninstall digikey-api
pip install git+https://github.com/hurricaneJoef/digikey-api.git

That's the one we're using for Ki-nTree

Comment thread digikey/v4/api.py
@@ -0,0 +1,171 @@
import os
import logging
from distutils.util import strtobool

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Distutils is gone in python 3.12: https://docs.python.org/3/library/distutils.html, I'm not sure how this is working for you.

@zmdev2082 zmdev2082 Feb 27, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To get this working with 3.12 I just used:

`
def strtobool(val):
"""Convert a string representation of truth to true (1) or false (0).

True values are 'y', 'yes', 't', 'true', 'on', and '1'; 
false values are 'n', 'no', 'f', 'false', 'off', and '0'.
Raises ValueError if 'val' is anything else.
"""
    val = val.lower()
    if val in ('y', 'yes', 't', 'true', 'on', '1'):
       return 1
    elif val in ('n', 'no', 'f', 'false', 'off', '0'):
        return 0
    else:
        raise ValueError(f"invalid truth value {val}")

`
The function is only called once in the library so there might be a more eloquent solution.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

distutils.strtobool still exsits in Python 3.13.3. It's part of setuptools. hurricaneJoef#2 adds the missing dependency.

@amosborne

Copy link
Copy Markdown

@hurricaneJoef @eeintech I am using your pull-request with python 3.12.8. digikey.keyword_search works fine but digikey.batch_product_details returns a TypeError: BatchSearchApi.batch_product_details_with_http_info() got multiple values for argument 'authorization'. Have you seen such an error before?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants