Skip to content

Commit

Permalink
add license
Browse files Browse the repository at this point in the history
  • Loading branch information
yodeng committed Jun 21, 2023
1 parent 850abde commit 070e404
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 33 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2022~2023 yodeng <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2 changes: 1 addition & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ requirements:

about:
home: https://github.com/yodeng/fsplit
license: BSD
license: MIT
153 changes: 123 additions & 30 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,127 @@
import os
import sys
import sysconfig

from setuptools import setup
from src.version import __version__


def getdes():
des = ""
with open(os.path.join(os.getcwd(), "README.md")) as fi:
des = fi.read()
return des


setup(
name="fsplit",
version=__version__,
packages=["fsplit"],
package_data={"fsplit": ["gsplit", ]},
package_dir={"fsplit": "src"},
author="Deng Yong",
author_email="[email protected]",
url="",
license="BSD",
install_requires=[],
python_requires='>=2.7.10, <=3.11',
long_description=getdes(),
long_description_content_type='text/markdown',
entry_points={
'console_scripts': [
'fsplit = fsplit.main:main',
'gsplit = fsplit.main:gsplit',
from functools import partial
from setuptools.extension import Extension


class Packages(object):

def __init__(self, pkg_name=""):
self.name = pkg_name
self.base_dir = os.path.dirname(__file__)
basejoin = partial(self._join, self.base_dir)
self.source_dir = basejoin("src")
self.version_file = basejoin("src/_version.py")
self.des_file = basejoin("README.md")
self.req_file = basejoin("requirements.txt")

def _join(self, *args):
return os.path.join(*args)

@property
def listdir(self):
df, nc = [], []
if os.path.isdir(self.name):
nc = os.listdir(self.name)
for a, b, c in os.walk(self.source_dir):
if os.path.basename(a).startswith("__"):
continue
for i in c:
if i.startswith("__") or not i.endswith(".py") or i in nc:
continue
p = os.path.join(a[len(self.source_dir)+1:], i)
df.append(p)
return df

@property
def description(self):
des = ""
if os.path.isfile(self.des_file):
with open(self.des_file) as fi:
des = fi.read()
return des

@property
def version(self):
v = {}
if not os.path.isfile(self.version_file):
for f in os.listdir(self.source_dir):
if f.endswith("version.py"):
self.version_file = os.path.join(self.source_dir, f)
break
with open(self.version_file) as fi:
c = fi.read()
exec(compile(c, self.version_file, "exec"), v)
return v["__version__"]

@property
def requirements(self):
requires = []
if os.path.isfile(self.req_file):
with open(self.req_file) as fi:
for line in fi:
line = line.strip()
requires.append(line)
return requires

@property
def _extensions(self):
exts = []
for f in self.listdir:
e = Extension(self.name + "." + os.path.splitext(f)[0].replace("/", "."),
[os.path.join(self.source_dir, f), ], extra_compile_args=["-O3", ],)
e.cython_directives = {
'language_level': sysconfig._PY_VERSION_SHORT_NO_DOT[0]}
exts.append(e)
return exts

@property
def _package_dir(self):
pd = {}
for a, b, v in os.walk(self.source_dir):
p = a.replace(self.source_dir, self.name).replace("/", ".")
pd[p] = a.replace(self.source_dir, "src")
return pd

def install(self, ext=False):
kwargs = {}
kwargs.update(
name=self.name,
version=self.version,
license="MIT",
packages=list(self._package_dir.keys()),
package_dir=self._package_dir,
package_data={self.name: ["gsplit", ]},
install_requires=self.requirements,
python_requires='>=2.7.10, <=3.11',
long_description=self.description,
long_description_content_type='text/markdown',
entry_points={'console_scripts': self._entrys},
author="yodeng",
author_email="[email protected]",
url="https://github.com/yodeng/fsplit",
)
if ext:
kwargs.pop("package_dir")
kwargs["ext_modules"] = self._extensions
setup(**kwargs)

@property
def _entrys(self):
eps = [
'{0} = {0}.main:main'.format(self.name),
'{0} = {1}.main:{0}'.format("gsplit", self.name),
]
}
)
return eps


def main():
pkgs = Packages("fsplit")
pkgs.install()


if __name__ == "__main__":
main()
5 changes: 3 additions & 2 deletions src/bcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,16 @@ def make_bcl_cmd(self):
"--barcode-mismatches", self.mis,
"-p", self.nproc,
"--sample-sheet", self.samplesheet]
return " ".join(cmd)
return cmd

def call(self, cmd, run=True):
if self.print_cmd:
self.logs.info(cmd)
if not run:
return
with open(os.devnull, "w") as fo:
subprocess.check_call(cmd, shell=True, stdout=fo, stderr=fo)
subprocess.check_call(cmd, shell=isinstance(
cmd, str) and True or False, stdout=fo, stderr=fo)

def stats(self, j):
with open(j) as fi:
Expand Down

0 comments on commit 070e404

Please sign in to comment.