Skip to content

Commit 070e404

Browse files
committed
add license
1 parent 850abde commit 070e404

File tree

4 files changed

+148
-33
lines changed

4 files changed

+148
-33
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2022~2023 yodeng <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

recipe/meta.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ requirements:
2121

2222
about:
2323
home: https://github.com/yodeng/fsplit
24-
license: BSD
24+
license: MIT

setup.py

+123-30
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,127 @@
11
import os
2+
import sys
3+
import sysconfig
24

35
from setuptools import setup
4-
from src.version import __version__
5-
6-
7-
def getdes():
8-
des = ""
9-
with open(os.path.join(os.getcwd(), "README.md")) as fi:
10-
des = fi.read()
11-
return des
12-
13-
14-
setup(
15-
name="fsplit",
16-
version=__version__,
17-
packages=["fsplit"],
18-
package_data={"fsplit": ["gsplit", ]},
19-
package_dir={"fsplit": "src"},
20-
author="Deng Yong",
21-
author_email="[email protected]",
22-
url="",
23-
license="BSD",
24-
install_requires=[],
25-
python_requires='>=2.7.10, <=3.11',
26-
long_description=getdes(),
27-
long_description_content_type='text/markdown',
28-
entry_points={
29-
'console_scripts': [
30-
'fsplit = fsplit.main:main',
31-
'gsplit = fsplit.main:gsplit',
6+
from functools import partial
7+
from setuptools.extension import Extension
8+
9+
10+
class Packages(object):
11+
12+
def __init__(self, pkg_name=""):
13+
self.name = pkg_name
14+
self.base_dir = os.path.dirname(__file__)
15+
basejoin = partial(self._join, self.base_dir)
16+
self.source_dir = basejoin("src")
17+
self.version_file = basejoin("src/_version.py")
18+
self.des_file = basejoin("README.md")
19+
self.req_file = basejoin("requirements.txt")
20+
21+
def _join(self, *args):
22+
return os.path.join(*args)
23+
24+
@property
25+
def listdir(self):
26+
df, nc = [], []
27+
if os.path.isdir(self.name):
28+
nc = os.listdir(self.name)
29+
for a, b, c in os.walk(self.source_dir):
30+
if os.path.basename(a).startswith("__"):
31+
continue
32+
for i in c:
33+
if i.startswith("__") or not i.endswith(".py") or i in nc:
34+
continue
35+
p = os.path.join(a[len(self.source_dir)+1:], i)
36+
df.append(p)
37+
return df
38+
39+
@property
40+
def description(self):
41+
des = ""
42+
if os.path.isfile(self.des_file):
43+
with open(self.des_file) as fi:
44+
des = fi.read()
45+
return des
46+
47+
@property
48+
def version(self):
49+
v = {}
50+
if not os.path.isfile(self.version_file):
51+
for f in os.listdir(self.source_dir):
52+
if f.endswith("version.py"):
53+
self.version_file = os.path.join(self.source_dir, f)
54+
break
55+
with open(self.version_file) as fi:
56+
c = fi.read()
57+
exec(compile(c, self.version_file, "exec"), v)
58+
return v["__version__"]
59+
60+
@property
61+
def requirements(self):
62+
requires = []
63+
if os.path.isfile(self.req_file):
64+
with open(self.req_file) as fi:
65+
for line in fi:
66+
line = line.strip()
67+
requires.append(line)
68+
return requires
69+
70+
@property
71+
def _extensions(self):
72+
exts = []
73+
for f in self.listdir:
74+
e = Extension(self.name + "." + os.path.splitext(f)[0].replace("/", "."),
75+
[os.path.join(self.source_dir, f), ], extra_compile_args=["-O3", ],)
76+
e.cython_directives = {
77+
'language_level': sysconfig._PY_VERSION_SHORT_NO_DOT[0]}
78+
exts.append(e)
79+
return exts
80+
81+
@property
82+
def _package_dir(self):
83+
pd = {}
84+
for a, b, v in os.walk(self.source_dir):
85+
p = a.replace(self.source_dir, self.name).replace("/", ".")
86+
pd[p] = a.replace(self.source_dir, "src")
87+
return pd
88+
89+
def install(self, ext=False):
90+
kwargs = {}
91+
kwargs.update(
92+
name=self.name,
93+
version=self.version,
94+
license="MIT",
95+
packages=list(self._package_dir.keys()),
96+
package_dir=self._package_dir,
97+
package_data={self.name: ["gsplit", ]},
98+
install_requires=self.requirements,
99+
python_requires='>=2.7.10, <=3.11',
100+
long_description=self.description,
101+
long_description_content_type='text/markdown',
102+
entry_points={'console_scripts': self._entrys},
103+
author="yodeng",
104+
author_email="[email protected]",
105+
url="https://github.com/yodeng/fsplit",
106+
)
107+
if ext:
108+
kwargs.pop("package_dir")
109+
kwargs["ext_modules"] = self._extensions
110+
setup(**kwargs)
111+
112+
@property
113+
def _entrys(self):
114+
eps = [
115+
'{0} = {0}.main:main'.format(self.name),
116+
'{0} = {1}.main:{0}'.format("gsplit", self.name),
32117
]
33-
}
34-
)
118+
return eps
119+
120+
121+
def main():
122+
pkgs = Packages("fsplit")
123+
pkgs.install()
124+
125+
126+
if __name__ == "__main__":
127+
main()

src/bcl.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,16 @@ def make_bcl_cmd(self):
7070
"--barcode-mismatches", self.mis,
7171
"-p", self.nproc,
7272
"--sample-sheet", self.samplesheet]
73-
return " ".join(cmd)
73+
return cmd
7474

7575
def call(self, cmd, run=True):
7676
if self.print_cmd:
7777
self.logs.info(cmd)
7878
if not run:
7979
return
8080
with open(os.devnull, "w") as fo:
81-
subprocess.check_call(cmd, shell=True, stdout=fo, stderr=fo)
81+
subprocess.check_call(cmd, shell=isinstance(
82+
cmd, str) and True or False, stdout=fo, stderr=fo)
8283

8384
def stats(self, j):
8485
with open(j) as fi:

0 commit comments

Comments
 (0)