Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ctypes AttributeError on pip install #3407

Closed
AyanSinhaMahapatra opened this issue May 22, 2023 · 2 comments
Closed

ctypes AttributeError on pip install #3407

AyanSinhaMahapatra opened this issue May 22, 2023 · 2 comments
Assignees
Milestone

Comments

@AyanSinhaMahapatra
Copy link
Member

AyanSinhaMahapatra commented May 22, 2023

Description

Please leave a brief description of the bug or feature request:

On python 3.8:

Traceback (most recent call last):
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py38/bin/scancode", line 5, in <module>
    from scancode.cli import scancode
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py38/lib/python3.8/site-packages/scancode/cli.py", line 113, in <module>
    plugin_classes, plugin_options = PluginManager.load_plugins()
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py38/lib/python3.8/site-packages/plugincode/__init__.py", line 199, in load_plugins
    mgr_setup = manager.setup()
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py38/lib/python3.8/site-packages/plugincode/__init__.py", line 223, in setup
    self.manager.load_setuptools_entrypoints(entrypoint)
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py38/lib/python3.8/site-packages/pluggy/_manager.py", line 287, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py38/lib/python3.8/site-packages/importlib_metadata/__init__.py", line 210, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py38/lib/python3.8/site-packages/summarycode/classify_plugin.py", line 16, in <module>
    from packagedcode import get_package_handler
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py38/lib/python3.8/site-packages/packagedcode/__init__.py", line 13, in <module>
    from packagedcode import about
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py38/lib/python3.8/site-packages/packagedcode/about.py", line 16, in <module>
    from packagedcode import models
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py38/lib/python3.8/site-packages/packagedcode/models.py", line 32, in <module>
    from typecode import contenttype
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py38/lib/python3.8/site-packages/typecode/__init__.py", line 21, in <module>
    from typecode.contenttype import get_type
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py38/lib/python3.8/site-packages/typecode/contenttype.py", line 32, in <module>
    from typecode import magic2
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py38/lib/python3.8/site-packages/typecode/magic2.py", line 378, in <module>
    libmagic = load_lib()
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py38/lib/python3.8/site-packages/typecode/magic2.py", line 193, in load_lib
    failover_lib = load_lib_failover()
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py38/lib/python3.8/site-packages/typecode/magic2.py", line 121, in load_lib_failover
    ctypes.util.find_library('magic')
AttributeError: module 'ctypes' has no attribute 'util'

On python 3.11:

Traceback (most recent call last):
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py311/bin/scancode", line 5, in <module>
    from scancode.cli import scancode
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py311/lib/python3.11/site-packages/scancode/cli.py", line 113, in <module>
    plugin_classes, plugin_options = PluginManager.load_plugins()
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py311/lib/python3.11/site-packages/plugincode/__init__.py", line 199, in load_plugins
    mgr_setup = manager.setup()
                ^^^^^^^^^^^^^^^
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py311/lib/python3.11/site-packages/plugincode/__init__.py", line 223, in setup
    self.manager.load_setuptools_entrypoints(entrypoint)
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py311/lib/python3.11/site-packages/pluggy/_manager.py", line 287, in load_setuptools_entrypoints
    plugin = ep.load()
             ^^^^^^^^^
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py311/lib/python3.11/site-packages/importlib_metadata/__init__.py", line 210, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py311/lib/python3.11/site-packages/summarycode/classify_plugin.py", line 16, in <module>
    from packagedcode import get_package_handler
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py311/lib/python3.11/site-packages/packagedcode/__init__.py", line 13, in <module>
    from packagedcode import about
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py311/lib/python3.11/site-packages/packagedcode/about.py", line 16, in <module>
    from packagedcode import models
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py311/lib/python3.11/site-packages/packagedcode/models.py", line 32, in <module>
    from typecode import contenttype
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py311/lib/python3.11/site-packages/typecode/__init__.py", line 21, in <module>
    from typecode.contenttype import get_type
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py311/lib/python3.11/site-packages/typecode/contenttype.py", line 32, in <module>
    from typecode import magic2
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py311/lib/python3.11/site-packages/typecode/magic2.py", line 378, in <module>
    libmagic = load_lib()
               ^^^^^^^^^^
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py311/lib/python3.11/site-packages/typecode/magic2.py", line 193, in load_lib
    failover_lib = load_lib_failover()
                   ^^^^^^^^^^^^^^^^^^^
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py311/lib/python3.11/site-packages/typecode/magic2.py", line 121, in load_lib_failover
    ctypes.util.find_library('magic')
    ^^^^^^^^^^^
AttributeError: module 'ctypes' has no attribute 'util'

How To Reproduce

Tell us how to reproduce the issue.

python3.11 -m venv venvs/scancode-32.0.0-py311/
source venvs/scancode-32.0.0-py311/bin/activate
pip install scancode-toolkit
scancode -h

System configuration

For bug reports, it really helps us to know:

  • What OS are you running on? (Windows/MacOS/Linux) ubuntu-20.04
  • What version of scancode-toolkit was used to generate the scan file? v32.0.0
  • What installation method was used to install/run scancode? (pip/source download/other) pip

Seems to be aboutcode-org/typecode#27 and aboutcode-org/typecode#32 is related to this, since same errors are referenced?

@AyanSinhaMahapatra
Copy link
Member Author

AyanSinhaMahapatra commented May 23, 2023

This seems to be solved with https://github.com/nexB/typecode/releases/tag/v30.0.1 but we have a new error on running the same command.

/home/ayansinha/nexB/venvs/scancode-32.0.0-py311-new/lib/python3.11/site-packages/typecode/magic2.py:195: UserWarning: System libmagic found in typical location is used. Install instead a typecode-libmagic plugin for best support.
  warnings.warn(
Traceback (most recent call last):
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py311-new/bin/scancode", line 5, in <module>
    from scancode.cli import scancode
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py311-new/lib/python3.11/site-packages/scancode/cli.py", line 113, in <module>
    plugin_classes, plugin_options = PluginManager.load_plugins()
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py311-new/lib/python3.11/site-packages/plugincode/__init__.py", line 199, in load_plugins
    mgr_setup = manager.setup()
                ^^^^^^^^^^^^^^^
  File "/home/ayansinha/nexB/venvs/scancode-32.0.0-py311-new/lib/python3.11/site-packages/plugincode/__init__.py", line 236, in setup
    raise PlugincodeError(
plugincode.PlugincodeError: Invalid plugin: 'pre_scan:classify': <class 'summarycode.classify_plugin.FileClassifier'> must extend <class 'plugincode.pre_scan.PreScanPlugin'>.

@jyang noticed that the setup.cfg in https://files.pythonhosted.org/packages/88/4b/79ca4c6f06c5b9ad1f5f601f1191e207fa05dcbccb2c4a46b381d3ad98af/scancode-toolkit-32.0.0.tar.gz is different from the one in the git checkout. Opened a new issue at #3408

@AyanSinhaMahapatra AyanSinhaMahapatra added this to the v32.0 milestone May 23, 2023
@AyanSinhaMahapatra
Copy link
Member Author

This is fixed, closing!

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

No branches or pull requests

1 participant