Examples (and tests) for python namespace packages
This commit is contained in:
parent
70a2a11f29
commit
0a81b76b31
2 changed files with 36 additions and 1 deletions
|
|
@ -10,7 +10,8 @@ import_packages_subdirs = \
|
||||||
from_init3 \
|
from_init3 \
|
||||||
relativeimport1 \
|
relativeimport1 \
|
||||||
relativeimport2 \
|
relativeimport2 \
|
||||||
relativeimport3
|
relativeimport3 \
|
||||||
|
namespace_pkg
|
||||||
|
|
||||||
check: build
|
check: build
|
||||||
if test "x$(SRCDIR)" != x; then \
|
if test "x$(SRCDIR)" != x; then \
|
||||||
|
|
|
||||||
34
Examples/python/import_packages/namespace_pkg/setupPkg.py
Normal file
34
Examples/python/import_packages/namespace_pkg/setupPkg.py
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
#---------------------------------
|
||||||
|
# setup the namespace package dirs
|
||||||
|
#---------------------------------
|
||||||
|
import os, shutil, zipfile
|
||||||
|
|
||||||
|
|
||||||
|
def copyMods():
|
||||||
|
dirs = ['path1', 'path2', 'path3']
|
||||||
|
|
||||||
|
# Clean out any old package paths
|
||||||
|
for d in dirs:
|
||||||
|
if os.path.isdir(d):
|
||||||
|
shutil.rmtree(d)
|
||||||
|
|
||||||
|
for d in dirs:
|
||||||
|
os.mkdir(d)
|
||||||
|
os.mkdir(os.path.join(d, 'brave'))
|
||||||
|
|
||||||
|
shutil.copy('robin.py', os.path.join('path1', 'brave'))
|
||||||
|
shutil.copy('_robin.so', os.path.join('path1', 'brave'))
|
||||||
|
|
||||||
|
shutil.copy('robin.py', os.path.join('path2', 'brave'))
|
||||||
|
shutil.copy('_robin.so', os.path.join('path3', 'brave'))
|
||||||
|
|
||||||
|
mkzip()
|
||||||
|
|
||||||
|
def mkzip():
|
||||||
|
zf = zipfile.ZipFile("path4.zip", "w")
|
||||||
|
zf.writestr("brave/", b'')
|
||||||
|
zf.write('robin.py', 'brave/robin.py')
|
||||||
|
zf.close()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
copyMods()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue