Dakkaron / ArchiveImporter

A Python module that allows importing files from password protected zips and (compressed) tars
Apache License 2.0
23 stars 10 forks source link

Import Packages from password Protected zip. #1

Open skamdar opened 3 years ago

skamdar commented 3 years ago

@Dakkaron I am trying to use ArchieveImporter to import a package which has further subpackages from a password protected zip but I am unable to handle .pyd files in it, any idea how can we resolve this issue?

Dakkaron commented 3 years ago

From what I can see, .pyd files are Windows specific. Since I am a Linux dev, I haven't tested it with .pyd files, but it shouldn't be that hard.

Do you have a sample file that I can test it with?

skamdar commented 3 years ago

@Dakkaron Just to give you some background of what I have done so far:

  1. With the original implementation of ArchieveImporter, we are going into infinite recursion(when init.py imports package.subpackage) while importing any package from zip. In order to resolve this, I placed 'sys.modules[fullname] = newModule' before 'exec(data, newModule.dict)', it seems to work but I have no idea of it's repercussions.
  2. In order to list .pyd files I added 'modlist += [ x[:-4] for x in namelist if x.endswith(".pyd")]' into getModlist method similarly a line can be added for .so files in case of linux. You can test it with any .so file instead .pyd that you have.

Now the problem I am running into is exec() does not like content of .pyd (not sure about .so, I have not tested it). I tried searching importlib module of python to see how Python initializes .pyd file but without luck.

Any guidance at this point will be helpful.