comparison TEisotools-1.1.a/setup_TEiso.py @ 13:feef9a0db09d draft

Uploaded
author urgi-team
date Wed, 20 Jul 2016 09:04:42 -0400
parents
children
comparison
equal deleted inserted replaced
12:22b0494ec883 13:feef9a0db09d
1 import os, shutil, glob, re, sys, time
2 from distutils.util import convert_path
3 from distutils.core import setup
4 from distutils.core import Command
5
6 class Devtools(object):
7
8 @staticmethod
9 def find_sub_packages(lrootPackage, lExclude=()):
10 lPackages = Devtools.find_packages(exclude=lExclude)
11 lSubPackage = []
12 for package in lPackages:
13 for rootPackage in lrootPackage:
14 if package.startswith(rootPackage):
15 lSubPackage.append(package)
16 return lSubPackage
17
18 @staticmethod
19 def find_packages(where='.', exclude=()):
20 out = []
21 stack=[(convert_path(where), '')]
22 while stack:
23 where,prefix = stack.pop(0)
24 for name in os.listdir(where):
25 fn = os.path.join(where,name)
26 if ('.' not in name and os.path.isdir(fn) and os.path.isfile(os.path.join(fn,'__init__.py'))):
27 out.append(prefix+name); stack.append((fn,prefix+name+'.'))
28 for pat in list(exclude)+['ez_setup', 'distribute_setup']:
29 from fnmatch import fnmatchcase
30 out = [item for item in out if not fnmatchcase(item,pat)]
31 return out
32
33 @staticmethod
34 def findall(directory = os.curdir):
35 all_files = []
36 for base, dirs, files in os.walk(directory):
37 if base==os.curdir or base.startswith(os.curdir+os.sep):
38 base = base[2:]
39 if base:
40 files = [os.path.join(base, f) for f in files]
41 all_files.extend(filter(os.path.isfile, files))
42 return all_files
43
44
45 class Install(Command):
46 description = "Install TEiso_tools"
47 user_options = []
48
49 def initialize_options(self):
50 """Use this to set option defaults before parsing."""
51 pass
52
53 def finalize_options(self):
54 """Code to validate/modify command-line/config input goes here."""
55 pass
56
57 def _isToLink(self, fileName):
58 if re.search("__\w*.py", fileName):
59 return False
60 elif re.search("Test\w*.py", fileName):
61 return False
62 elif re.search("\w*.py$", fileName):
63 return True
64 return False
65
66 def run(self):
67 cwd = os.getcwd()
68 print "Build TEiso in %s" % (cwd)
69 if not os.path.isdir("bin"):
70 os.mkdir("bin")
71 os.chdir("bin")
72 lPackages = ["TEiso"]
73 for package in lPackages:
74 if os.path.isdir("../%s" % package):
75 print "processing %s/..." % package
76 [os.symlink(i, os.path.basename(i)) for i in Devtools.findall("../%s" % package) if self._isToLink(os.path.basename(i))]
77 os.system("chmod 0755 *")
78 print "TEiso is ready to use"
79
80 class PublicRelease(Command):
81 description = "public release for TEiso_tools"
82 user_options = []
83
84 def initialize_options(self):
85 """Use this to set option defaults before parsing."""
86 pass
87
88 def finalize_options(self):
89 """Code to validate/modify command-line/config input goes here."""
90 pass
91
92 def run(self):
93
94 print "START Releasing (%s)" % time.strftime("%Y-%m-%d %H:%M:%S")
95 sys.stdout.flush()
96
97 cwd = os.getcwd()
98
99 print "Removing all '.pyc' files and dead symlinks in bin, then adding execution rights to all 'py' files (%s)" % time.strftime("%Y-%m-%d %H:%M:%S")
100 sys.stdout.flush()
101
102 os.system("find . -name '*.pyc' -exec rm {} \;")
103 os.system("find . -name '*.py' -exec chmod +x {} \;")
104 os.system("find -L ./bin -type l -exec rm {} +")
105
106 # lSetupFiles = FileUtils.getFileNamesList(cwd, "setup_.*.py")
107 # lSetupFiles.remove("setup_REPET.py")
108 # FileUtils.removeFilesFromList(lSetupFiles)
109
110 os.chdir("..")
111 os.system("tar -czf %s.tar.gz %s" % (os.path.basename(cwd), os.path.basename(cwd)))
112
113 print "END Releasing (%s)" % time.strftime("%Y-%m-%d %H:%M:%S")
114 sys.stdout.flush()
115
116 setup(
117 name = "TEisotools",
118 version = "1.1.a",
119 description='Set of tools to analyse RNA_seq for the France Genomics projects.',
120 author='URGI team',
121 author_email='urgi-support@versailles.inra.fr',
122 url='https://urgi.versailles.inra.fr/Projects/TEiso',
123 packages=[],
124 #Additionnal Files
125 data_files=[('TEiso',["TEiso/LaunchTEiso.py", "TEiso/Tophat.py", "TEiso/Cufflinks.py", "TEiso/Cuffcompare.py", "TEiso/Bowtie_build.py", "TEiso/Bedtools_closest.py","TEiso/ClosestToStartSite.py", "TEiso/GFFToBed.py", "TEiso/CufflinksGTFToBed.py"]),
126 ("commons/core", glob.glob("commons/core/*.py")),
127 ("commons", glob.glob("commons/*.py")),
128 ("commons/core/utils", glob.glob("commons/core/utils/*.py")),
129 ("commons/core/checker", glob.glob("commons/core/checker/*.py")),
130 ("commons/core/seq", glob.glob("commons/core/seq/*.py")),
131 ("commons/core/coord", glob.glob("commons/core/coord/*.py")),
132 ('commons/core/parsing',["commons/core/parsing/GtfParser.py", "commons/core/parsing/TranscriptListParser.py", "commons/core/parsing/GffParser.py", "commons/core/parsing/__init__.py"]),
133 ('',['TEiso/doc/README_TEiso.txt']),('',['LICENSE'])],
134 cmdclass={
135 'install' : Install
136 }
137 )
138
139