Skip to content

Conversation

@tardyp
Copy link
Contributor

@tardyp tardyp commented Mar 31, 2021

This allows scancode to install and run in systems not supported by
extractcode-libarchive and extractcode-7zip

Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

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

@tardyp Thanks! this makes a lot of sense. The idea for using a system-provided libarchive or 7zip so far has been to have instead a plugin that provides "system paths" ... but these feel contrived compared to your cleaner and simpler approach here.

For the current code, see https://github.com/nexB/scancode-plugins/tree/main/builtins/extractcode_7z_system_provided and https://github.com/nexB/scancode-plugins/tree/main/builtins/extractcode_libarchive_system_provided
Then we have that extra requires in https://github.com/nexB/extractcode/blob/main/setup.cfg#L49
So if one wants to use system-installed binaries, the procedure would be:

  • install them by pip first
  • pip install typecode[full]
  • install scancode-toolkit separately

With all that said, I made a few minor comments inline for your consideration.

And I am not sure we could have a test for these?
Also which OS and architecture are you getting support and problems with?

'plugin with a valid executable available.'
)
sevenzip = which("7z")
if sevenzip is None:
Copy link
Member

Choose a reason for hiding this comment

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

What about this instead?

Suggested change
if sevenzip is None:
if not sevenzip:

)
filepath = ctypes.util.find_library(_LIBRARY_NAME)
libarchive = ctypes.cdll.LoadLibrary(filepath)
if libarchive is None:
Copy link
Member

Choose a reason for hiding this comment

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

What about this instead?

Suggested change
if libarchive is None:
if not libarchive:

@tardyp
Copy link
Contributor Author

tardyp commented Apr 6, 2021

hi @pombredanne thanks for review.

please have a look at related issue. We are having problems with mac m1 and windows wsl2.

aboutcode-org/scancode-toolkit#2470

according to https://github.com/nexB/scancode-toolkit/blob/develop/setup.cfg#L98

'extractcode[full]' is required for scancode.

If I don't comment those lines, even if I install extractcode first, pip will still try to install the [full] dependencies which are not available because extractcode-libarchive is only available for a select number of systems.

Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

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

Thanks for the updates! Do you mind to switch to using single quotes for strings?
We will eventually switch to using Black as a style at once, but until then I would prefer to keep single quotes consistently in the code.

EXTRACTCODE_LIBARCHIVE_DLL = 'extractcode.libarchive.dll'
_LIBRARY_NAME = "libarchive"

def load_lib_failover():
Copy link
Member

Choose a reason for hiding this comment

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

Why are you keep a no-op function there?

@pombredanne
Copy link
Member

If I don't comment those lines, even if I install extractcode first, pip will still try to install the [full] dependencies which are not available because extractcode-libarchive is only available for a select number of systems.

Sorry for missing your aboutcode-org/scancode-toolkit#2470 post
The comment there is likely to help a bit: aboutcode-org/scancode-toolkit#2470 (comment) ... and I am repasting for completeness

For this use case there is the "scancode-toolkit-mini" build that is exactly the same code as "scancode-toolkit" but uses this setup instead https://github.com/nexB/scancode-toolkit/blob/6c43e29f446c948ec581995fa59665594341eef8/setup-mini.cfg which does not require these tow by default:

extractcode[full] >= 21.2.24
typecode[full] >= 21.2.24

This allows scancode to install and run in systems not supported by
extractcode-libarchive and extractcode-7zip

Signed-off-by: Pierre Tardy <pierre.tardy@renault.com>
@pombredanne
Copy link
Member

@pombredanne pombredanne merged commit 78994e6 into aboutcode-org:main Apr 19, 2021
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.

2 participants