Skip to content
Snippets Groups Projects
Verified Commit d79c656d authored by Bertrand  NÉRON's avatar Bertrand NÉRON
Browse files

:fire: update setup remove unused code

parent 191932b1
No related branches found
No related tags found
No related merge requests found
Pipeline #10896 passed
......@@ -5,7 +5,7 @@
# This file is part of Counter RNAseq Window (craw) package. #
# #
# Authors: Bertrand Neron #
# Copyright c 2017 Institut Pasteur (Paris). #
# Copyright (c) 2017-2019 Institut Pasteur (Paris). #
# see COPYRIGHT file for details. #
# #
# craw is free software: you can redistribute it and/or modify #
......@@ -24,49 +24,13 @@
# #
###########################################################################
import sys
if sys.version_info[0] == 2:
sys.exit("Sorry, Python 2 is not supported")
import os
import time
import sysconfig
from distutils.errors import DistutilsFileError
from distutils.util import subst_vars as distutils_subst_vars
from setuptools import setup
from setuptools import setup, find_packages
from setuptools.dist import Distribution
from setuptools.command.install_lib import install_lib as _install_lib
class install_lib(_install_lib):
def finalize_options(self):
_install_lib.finalize_options(self)
def run(self):
def subst_file(_file, vars_2_subst):
input_file = os.path.join(self.build_dir, _file)
output_file = input_file + '.tmp'
try:
subst_vars(input_file, output_file, vars_2_subst)
except Exception as err:
print("Cannot substitute file {}: {}".format(input_file, err), file-sys.stderr)
raise err
os.unlink(input_file)
self.move_file(output_file, input_file)
inst = self.distribution.command_options.get('install')
if inst:
if self.distribution.fix_lib is not None:
vars_2_subst = {'PREFIX': inst['prefix'][1] if 'prefix' in inst else '',
'VERSION': self.distribution.get_version()
}
for _file in self.distribution.fix_lib:
subst_file(_file, vars_2_subst)
_install_lib.run(self)
from craw import __version__ as cr_vers
class UsageDistribution(Distribution):
......@@ -114,30 +78,6 @@ def get_install_data_dir(inst):
return install_dir
def subst_vars(src, dst, vars):
"""
substitute variables (string starting with $) in file
:param src: the file containing variable to substitute
:type src: string
:param dst: the destination file
:type dst: string
:param vars: the variables to substitute in dict key are variable name
:type vars: dict
"""
try:
src_file = open(src, "r")
except os.error as err:
raise DistutilsFileError("could not open '{0}': {1}".format(src, err))
try:
dest_file = open(dst, "w")
except os.error as err:
raise DistutilsFileError("could not create '{0}': {1}".format(dst, err))
with src_file, dest_file:
for line in src_file:
new_line = distutils_subst_vars(line, vars)
dest_file.write(new_line)
def expand_data(data_to_expand):
"""
From data structure like setup.py data_files (see http://)
......@@ -180,7 +120,7 @@ def read_md(f): return open(f, 'r').read()
setup(name="craw",
version='master-{}'.format(time.strftime('%Y%m%d')),
version=cr_vers,
author='Bertrand Neron',
author_email='bneron@pasteur.fr',
url="https://gitlab.pasteur.fr/bneron/craw",
......@@ -194,14 +134,15 @@ setup(name="craw",
'Topic :: Scientific/Engineering :: Bio-Informatics',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
],
description="Counter RNA seq Window is a package which aim to compute and visualize the coverage of RNA seq experiment.",
description="Counter RNA seq Window is a package which aim to compute and "
"visualize the coverage of RNA seq experiment.",
long_description=read_md('README.md'),
long_description_content_type='text/markdown',
platforms=["Unix"],
python_requires='>=3.5',
install_requires=open("requirements.txt").read().split(),
extras_require={'dev': open("requirements_dev.txt").read().split()},
packages=['craw'],
packages=find_packages(),
entry_points={
'console_scripts': [
'craw_coverage=craw.scripts.craw_coverage:main',
......@@ -212,11 +153,5 @@ setup(name="craw",
data_files=expand_data([('share/craw/doc/html', ['doc/build/html/']),
('share/craw/doc/pdf/', ['doc/build/latex/CounterRNAseqWindow.pdf'])]),
# library file where some variable must be fix by install_lib
fix_lib=['craw/__init__.py'],
# scripts file where some variable must be fix by install_scripts
fix_scripts=['craw_coverage.py'],
cmdclass={'install_lib': install_lib},
distclass=UsageDistribution
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment