mirror of https://github.com/n1nj4sec/pupy.git
41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
|
import sys
|
||
|
from distutils.core import setup
|
||
|
import os
|
||
|
from glob import glob
|
||
|
import zipfile
|
||
|
import shutil
|
||
|
|
||
|
sys.path.insert(0, os.path.join('resources','library_patches'))
|
||
|
sys.path.insert(0, os.path.join('..','..','pupy'))
|
||
|
|
||
|
import pp
|
||
|
import additional_imports
|
||
|
import Crypto
|
||
|
|
||
|
all_dependencies=set([x.split('.')[0] for x,m in sys.modules.iteritems() if not '(built-in)' in str(m) and x != '__main__'])
|
||
|
|
||
|
print "ALLDEPS: ", all_dependencies
|
||
|
|
||
|
zf = zipfile.ZipFile(os.path.join('resources','library.zip'), mode='w', compression=zipfile.ZIP_DEFLATED)
|
||
|
try:
|
||
|
for dep in all_dependencies:
|
||
|
mdep = __import__(dep)
|
||
|
print "DEPENDENCY: ", dep, mdep
|
||
|
if hasattr(mdep, '__path__'):
|
||
|
print('adding package %s'%dep)
|
||
|
path, root = os.path.split(mdep.__path__[0])
|
||
|
for root, dirs, files in os.walk(mdep.__path__[0]):
|
||
|
for f in list(set([x.rsplit('.',1)[0] for x in files])):
|
||
|
for ext in ('.pyc', '.so', '.pyo', '.py'):
|
||
|
if os.path.exists(os.path.join(root,f+ext)):
|
||
|
print('adding file : %s'%os.path.join(root[len(path)+1:], f+ext))
|
||
|
zf.write(os.path.join(root, f+ext), os.path.join(root[len(path)+1:], f+ext))
|
||
|
break
|
||
|
else:
|
||
|
_, ext = os.path.splitext(mdep.__file__)
|
||
|
print('adding %s -> %s'%(mdep.__file__, dep+ext))
|
||
|
zf.write(mdep.__file__, dep+ext)
|
||
|
|
||
|
finally:
|
||
|
zf.close()
|