logger = logging.getLogger(os.path.basename(__file__))
logger.setLevel(logging.INFO)
+IGNORE = ['__pycache__', '__init__.py', '.yamm', 'NEWS', 'README']
+
def remove(path):
- if os.path.isdir(path):
+ logger.debug('Removing %r' % (path))
+ if os.path.islink(path):
+ os.unlink(path)
+ elif os.path.isdir(path):
shutil.rmtree(path)
- elif os.path.islink(path):
- os.remove(path)
else:
os.remove(path)
logger.debug('Copy %r to %r' % (src, dst))
if os.path.exists(dst):
remove(dst)
- if os.path.isdir(src):
- shutil.copytree(src, dst)
- else:
+ if not os.path.isdir(src):
shutil.copyfile(src, dst)
+ else:
+ shutil.copytree(src, dst)
def copy_or_link(src, dst):
if sys.platform in ('linux', 'linux2'):
if os.path.exists(dst):
+ current_dst = os.readlink(dst)
+ logger.warning('Destination link %r already exists and links to %r.' % (dst, current_dst))
+ logger.warning('It is overwritten to %r' % (src))
remove(dst)
os.symlink(src, dst)
else:
raise Exception("Must be using Python 3")
-def main(prerequis_install_dir, salome_install_dir, context_file_name, env_file_name):
+def main(prerequis_install_dir, salome_install_dir, context_file_name, env_file_name, ignore=None):
# Create the new python module folder on the same directory of prerequisites folder (salome install path )
+ if ignore:
+ ignore = IGNORE + ignore
+ else:
+ ignore = IGNORE[::]
+
while(prerequis_install_dir[-1] == '/'):
prerequis_install_dir = prerequis_install_dir[:-1]
if salome_install_dir.strip() == '':
easy_install.write("./%s\n" % egg_file)
else:
for f in os.listdir(d):
+ if f in ignore:
+ continue
full_file_srcpath = os.path.join(d, f)
full_file_dstpath = os.path.join(pythonpath_common, f)
copy_or_link(full_file_srcpath, full_file_dstpath)
help='Context file name (default: %(default)s)')
parser.add_argument('-e', '--env-file', default='salome_prerequisites.sh',
help='Env file name (default: %(default)s)')
+ parser.add_argument('-i', '--ignore', nargs='*',
+ help='List of comma separated files to ignore')
parser.add_argument(dest='prerequis_install_dir', help='Prerequisites install directory')
args = parser.parse_args()
if args.verbose:
logger.setLevel(logging.DEBUG)
- main(args.prerequis_install_dir, args.salome_install_dir, args.context_file, args.env_file)
+ main(args.prerequis_install_dir, args.salome_install_dir, args.context_file, args.env_file, args.ignore)