cryptlex / lexactivator-python

LexActivator API wrapper for Python (licensing library)
https://cryptlex.com
MIT License
10 stars 5 forks source link

Improve dynamic libraries loading #17

Open B3QL opened 1 year ago

B3QL commented 1 year ago

Currently lexactivator is using __file__ variable for path resolution (see: https://github.com/cryptlex/lexactivator-python/blob/master/cryptlex/lexactivator/lexactivator_native.py#L47) The problem with that approach is that the code assumes it will have access to the file system which is not always true.

From Python 3.8, ResourceReader and importlib.resources are recommended ways of accessing package resources that enables interoprability across the Python ecosystem with projects like https://github.com/indygreg/PyOxidizer.

A more in-depth description of various loading mechanisms is available here

adnan-kamili commented 1 year ago

Thanks for the suggestion, we will look into this.

B3QL commented 1 year ago

@adnan-kamili what is the current status? Can you share a rough ETA?

adnan-kamili commented 1 year ago

The problem with that approach is that the code assumes it will have access to the file system which is not always true.

In the case of LexActivator, it has to be true as it stores data on disk and also accesses a few files on the disk for its proper functioning.

B3QL commented 1 year ago

That's totally true, but Python tries to abstract that by using importlib.resources API. In the current state, it's impossible to integrate your client safely with the PyOxidizer project, which allows to "binarize" Python applications. By safely I mean storing Python wrapper around C libraries in binary itself, because if it's stored in filesystem it is possible to temper the wrapper and return fake data without ever calling C libs.

adnan-kamili commented 1 year ago

Ok, that makes sense. Would it be possible for you to submit a pull request?

B3QL commented 1 year ago

I tried to come up with some solution but without a success. I can give it a shot next time I'll be working on licensing area, but it won't be soon.