| 1 |
|
| 2 |
""" |
| 3 |
Run 'pip install .' to install Readucks. |
| 4 |
""" |
| 5 |
|
| 6 |
|
| 7 |
import sys |
| 8 |
if sys.version_info.major != 3 or sys.version_info.minor < 4: |
| 9 |
print('Error: you must execute setup.py using Python 3.4 or later') |
| 10 |
sys.exit(1) |
| 11 |
|
| 12 |
import os |
| 13 |
import shutil |
| 14 |
import subprocess |
| 15 |
import multiprocessing |
| 16 |
import fnmatch |
| 17 |
import importlib.util |
| 18 |
|
| 19 |
|
| 20 |
if not importlib.util.find_spec("setuptools"): |
| 21 |
import ez_setup |
| 22 |
ez_setup.use_setuptools() |
| 23 |
|
| 24 |
from setuptools import setup |
| 25 |
from setuptools.command.install import install |
| 26 |
|
| •27 |
from distutils.command.build import build |
| 28 |
from distutils.core import Command |
| 29 |
|
| 30 |
|
| 31 |
exec(open('readucks/version.py').read()) |
| 32 |
|
| 33 |
with open('README.md', 'rb') as readme: |
| 34 |
LONG_DESCRIPTION = readme.read().decode() |
| 35 |
|
| 36 |
|
| 37 |
class Build(build): |
| 38 |
""" |
| 39 |
The build process. |
| 40 |
""" |
| 41 |
|
| 42 |
def run(self): |
| 43 |
build.run(self) |
| 44 |
|
| 45 |
|
| 46 |
class Install(install): |
| 47 |
""" |
| 48 |
The install process. |
| 49 |
""" |
| 50 |
|
| 51 |
def run(self): |
| 52 |
install.run(self) |
| 53 |
|
| 54 |
|
| 55 |
class Clean(Command): |
| 56 |
""" |
| 57 |
Custom clean command that really cleans up everything, except for: |
| 58 |
- the compiled *.so file needed when running the programs |
| 59 |
- setuptools-*.egg file needed when running this script |
| 60 |
""" |
| •61 |
user_options = [('all', None, '(Compatibility with original clean command)')] |
| 62 |
|
| 63 |
def initialize_options(self): |
| •64 |
self.all = False |
| 65 |
self.cwd = None |
| 66 |
|
| 67 |
def finalize_options(self): |
| 68 |
self.cwd = os.getcwd() |
| 69 |
|
| 70 |
def run(self): |
| 71 |
assert os.getcwd() == self.cwd, 'Must be in package root: %s' % self.cwd |
| 72 |
|
| 73 |
delete_directories = [] |
| 74 |
for root, dir_names, filenames in os.walk(self.cwd): |
| 75 |
for dir_name in fnmatch.filter(dir_names, '*.egg-info'): |
| 76 |
delete_directories.append(os.path.join(root, dir_name)) |
| 77 |
for dir_name in fnmatch.filter(dir_names, 'build'): |
| 78 |
delete_directories.append(os.path.join(root, dir_name)) |
| 79 |
for dir_name in fnmatch.filter(dir_names, '__pycache__'): |
| 80 |
delete_directories.append(os.path.join(root, dir_name)) |
| 81 |
for delete_directory in delete_directories: |
| 82 |
print('Deleting directory:', delete_directory) |
| 83 |
shutil.rmtree(delete_directory) |
| 84 |
|
| 85 |
delete_files = [] |
| 86 |
for root, dir_names, filenames in os.walk(self.cwd): |
| 87 |
for filename in fnmatch.filter(filenames, 'setuptools*.zip'): |
| 88 |
delete_files.append(os.path.join(root, filename)) |
| 89 |
for filename in fnmatch.filter(filenames, '*.o'): |
| 90 |
delete_files.append(os.path.join(root, filename)) |
| 91 |
for filename in fnmatch.filter(filenames, '*.pyc'): |
| 92 |
delete_files.append(os.path.join(root, filename)) |
| 93 |
for delete_file in delete_files: |
| 94 |
print('Deleting file:', delete_file) |
| 95 |
os.remove(delete_file) |
| 96 |
|
| 97 |
|
| 98 |
setup(name='readucks', |
| 99 |
version=__version__, |
| 100 |
description='Readucks: a simple demultiplexer for nanopore reads', |
| 101 |
long_description=LONG_DESCRIPTION, |
| 102 |
long_description_content_type="text/markdown", |
| 103 |
url='http://github.com/rambaut/readucks', |
| 104 |
author='Andrew Rambaut', |
| 105 |
author_email='[email protected]', |
| 106 |
license='GPL', |
| 107 |
packages=['readucks'], |
| 108 |
entry_points={"console_scripts": ['readucks = readucks.readucks:main']}, |
| 109 |
zip_safe=False, |
| 110 |
cmdclass={'build': Build, |
| 111 |
'install': Install, |
| 112 |
'clean': Clean} |
| 113 |
) |