mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
deploy-ng: Combine build_apps files and directories options into a single copy_paths
copy_paths is a list of strings and two item sequences. If a copy_paths element is a single string, it is treated as both the source and destination paths. If the element is a sequence, the first element is the source and the second is the destination. NOTE: exclude_paths now uses file globs TODO: Support globs for copy_paths
This commit is contained in:
parent
66ef8f7c2a
commit
dcb743c30d
@ -13,6 +13,9 @@ from direct.showutil import FreezeTool
|
|||||||
import panda3d.core as p3d
|
import panda3d.core as p3d
|
||||||
|
|
||||||
|
|
||||||
|
if 'basestring' not in globals():
|
||||||
|
basestring = str
|
||||||
|
|
||||||
|
|
||||||
# TODO replace with Packager
|
# TODO replace with Packager
|
||||||
def find_packages(whlfile):
|
def find_packages(whlfile):
|
||||||
@ -42,8 +45,7 @@ class build_apps(distutils.core.Command):
|
|||||||
self.build_base = os.path.join(os.getcwd(), 'build')
|
self.build_base = os.path.join(os.getcwd(), 'build')
|
||||||
self.gui_apps = {}
|
self.gui_apps = {}
|
||||||
self.console_apps = {}
|
self.console_apps = {}
|
||||||
self.directories = []
|
self.copy_paths = []
|
||||||
self.files = []
|
|
||||||
self.exclude_paths = []
|
self.exclude_paths = []
|
||||||
self.exclude_modules = []
|
self.exclude_modules = []
|
||||||
self.deploy_platforms = []
|
self.deploy_platforms = []
|
||||||
@ -211,20 +213,25 @@ class build_apps(distutils.core.Command):
|
|||||||
ignore_copy_list = [
|
ignore_copy_list = [
|
||||||
'__pycache__',
|
'__pycache__',
|
||||||
] + list(freezer_modules) + self.exclude_paths + list(self.gui_apps.values()) + list(self.console_apps.values())
|
] + list(freezer_modules) + self.exclude_paths + list(self.gui_apps.values()) + list(self.console_apps.values())
|
||||||
|
ignore_copy_list = [p3d.GlobPattern(i) for i in ignore_copy_list]
|
||||||
|
|
||||||
for copydir in self.directories:
|
def copy_file(src, dst):
|
||||||
for root, dirs, files in os.walk(copydir):
|
src = os.path.normpath(src)
|
||||||
for item in files:
|
dst = os.path.normpath(dst)
|
||||||
src = os.path.join(root, item)
|
|
||||||
dst = os.path.normpath(os.path.join(builddir, root, item))
|
|
||||||
|
|
||||||
if item in ignore_copy_list:
|
dst_dir = os.path.dirname(dst)
|
||||||
print("skipping", src)
|
if not os.path.exists(dst_dir):
|
||||||
continue
|
distutils.dir_util.mkpath(dst_dir)
|
||||||
|
|
||||||
ext = os.path.splitext(src)[1]
|
ext = os.path.splitext(src)[1]
|
||||||
dst_root = os.path.splitext(dst)[0]
|
dst_root = os.path.splitext(dst)[0]
|
||||||
|
|
||||||
|
for pattern in ignore_copy_list:
|
||||||
|
#print("check ignore:", pattern, src, pattern.matches(src))
|
||||||
|
if pattern.matches(src):
|
||||||
|
print("skipping file", src)
|
||||||
|
return
|
||||||
|
|
||||||
if ext in self.build_scripts:
|
if ext in self.build_scripts:
|
||||||
dst_ext, script = self.build_scripts[ext]
|
dst_ext, script = self.build_scripts[ext]
|
||||||
dst = dst_root + dst_ext
|
dst = dst_root + dst_ext
|
||||||
@ -235,24 +242,26 @@ class build_apps(distutils.core.Command):
|
|||||||
#print("Copy file", src, dst)
|
#print("Copy file", src, dst)
|
||||||
distutils.file_util.copy_file(src, dst)
|
distutils.file_util.copy_file(src, dst)
|
||||||
|
|
||||||
for item in dirs[:]:
|
def copy_dir(src, dst):
|
||||||
path = os.path.normpath(os.path.join(builddir, root, item))
|
for item in os.listdir(src):
|
||||||
if item in ignore_copy_list:
|
s = os.path.join(src, item)
|
||||||
print("skipping", path)
|
d = os.path.join(dst, item)
|
||||||
dirs.remove(item)
|
if os.path.isfile(s):
|
||||||
|
copy_file(s, d)
|
||||||
else:
|
else:
|
||||||
print("making directory", path)
|
copy_dir(s, d)
|
||||||
distutils.dir_util.mkpath(path)
|
|
||||||
|
|
||||||
# Copy extra files
|
for path in self.copy_paths:
|
||||||
for extra in self.files:
|
if isinstance(path, basestring):
|
||||||
if len(extra) == 2:
|
src = dst = path
|
||||||
src, dst = extra
|
|
||||||
dst = os.path.join(builddir, dst)
|
|
||||||
else:
|
else:
|
||||||
src = extra
|
src, dst = path
|
||||||
dst = builddir
|
dst = os.path.join(builddir, dst)
|
||||||
distutils.file_util.copy_file(src, dst)
|
|
||||||
|
if os.path.isfile(src):
|
||||||
|
copy_file(src, dst)
|
||||||
|
else:
|
||||||
|
copy_dir(src, dst)
|
||||||
|
|
||||||
|
|
||||||
class bdist_apps(distutils.core.Command):
|
class bdist_apps(distutils.core.Command):
|
||||||
|
@ -4,8 +4,8 @@ setup(
|
|||||||
name="asteroids",
|
name="asteroids",
|
||||||
options = {
|
options = {
|
||||||
'build_apps': {
|
'build_apps': {
|
||||||
'directories': ['.'],
|
'copy_paths': ['.'],
|
||||||
'exclude_paths': ['build', 'setup.py', 'requirements.txt', 'wheels'],
|
'exclude_paths': ['build/*', 'setup.py', 'requirements.txt', 'wheels/*', '*.swp'],
|
||||||
'gui_apps': {
|
'gui_apps': {
|
||||||
'asteroids': 'main.py',
|
'asteroids': 'main.py',
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user