Skip to content

Commit

Permalink
updated setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Acribbs committed Nov 29, 2024
1 parent fbbe65d commit cba8541
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 93 deletions.
35 changes: 19 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pyproject.toml
[build-system]
requires = [
"setuptools>=64.0",
Expand All @@ -12,37 +11,41 @@ build-backend = "setuptools.build_meta"
[project]
name = "cgat"
version = "0.7.7"
description = "cgat : the Computational Genomics Analysis Toolkit"
description = "Computational Genomics Analysis Toolkit"
authors = [
{name = "Adam Cribbs", email = "[email protected]"},
{ name = "Adam Cribbs", email = "[email protected]" },
]
license = { text = "MIT" }
readme = "README.md"
requires-python = ">=3.6"
keywords = ["computational genomics"]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"License :: OSI Approved",
"Programming Language :: Python",
"Topic :: Software Development",
"Topic :: Scientific/Engineering",
"Operating System :: POSIX",
"Operating System :: Unix",
"Operating System :: MacOS",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
]
dependencies = [
"Cython>=0.29.35",
"numpy",
"pysam",
]
readme = "README.md"
requires-python = ">=3.10"

[tool.setuptools]
packages = { find = { where = ["cgat"] } }
include-package-data = true

[tool.setuptools.package-data]
cgat = ["*.txt", "*.yaml", "*.yml", "*.h"]

[project.scripts]
cgat = "cgat.cgat:main"

[tool.setuptools.package-data]
cgat = ["*.txt", "*.yaml", "*.yml"]

[project.urls]
Source = "https://github.com/cgat-developers/cgat-apps/"
Bug_Tracker = "https://github.com/cgat-developers/cgat-apps/issues/"
Expand Down
112 changes: 35 additions & 77 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,40 @@
# setup.py
import sysconfig
import sys
import os
import subprocess
import re

# Import setuptools at the beginning
import setuptools
from setuptools import setup, find_packages, Extension
from distutils.version import LooseVersion
from Cython.Distutils import build_ext

# Ensure dependencies are installed before setup
try:
import numpy
import Cython
import pysam
except ImportError as e:
missing_package = str(e).split("'")[1]
raise ImportError(f"{missing_package} must be installed before running setup.py")
from setuptools.command.build_ext import build_ext
from Cython.Distutils import build_ext as cython_build_ext
import numpy
import pysam

# Enforce Python 3 requirement
# Enforce Python version
if sys.version_info < (3, 6):
raise SystemExit("Python 3.6 or later is required to install this package.")

# Minimum setuptools version requirement
if LooseVersion(setuptools.__version__) < LooseVersion('1.1'):
raise ImportError("Setuptools version >=1.1 is required")

# External dependency check
external_dependencies = [("wigToBigWig", "UCSC tools", 255), ("bedtools", "bedtools", 0)]
for tool, toolkit, expected in external_dependencies:
retcode = subprocess.call(tool, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if retcode != expected:
print(f"WARNING: Dependency check for {toolkit} ({tool}) failed with error code {retcode}")

# Adjust packages and directories
cgat_packages = find_packages(include=["cgat", "cgat.*"], exclude=['tests'])
cgat_package_dirs = {'cgat': 'cgat'}
# Package and directory settings
cgat_packages = find_packages(include=["cgat", "cgat.*"], exclude=["tests"])
cgat_package_dirs = {"cgat": "cgat"}

# Cython extensions and paths
# Paths for build dependencies
conda_includes = [os.path.dirname(sysconfig.get_paths()["include"])]
conda_libdirs = [os.path.dirname(sysconfig.get_paths()["stdlib"])]
pysam_libraries = pysam.get_libraries()
pysam_libdirs = list(set(os.path.dirname(x) for x in pysam_libraries)) + conda_libdirs
pysam_libs = ["hts"] + [os.path.basename(x)[3:-3] for x in pysam_libraries]
pysam_dirname = os.path.dirname(pysam.__file__)
extra_link_args_pysam = [f'-Wl,-rpath,{x}' for x in pysam_libdirs + conda_libdirs]
pysam_libdirs = list(set(os.path.dirname(lib) for lib in pysam.get_libraries())) + conda_libdirs
pysam_libs = ["hts"] + [os.path.basename(lib)[3:-3] for lib in pysam.get_libraries()]
extra_link_args_pysam = [f"-Wl,-rpath,{path}" for path in pysam_libdirs + conda_libdirs]

# Define Cython extensions
extensions = [
Extension(
'cgat.Components',
['cgat/Components/Components.pyx', 'cgat/Components/connected_components.cpp'],
include_dirs=[os.path.join('cgat', 'Components')] + conda_includes,
"cgat.Components",
["cgat/Components/Components.pyx", "cgat/Components/connected_components.cpp"],
include_dirs=["cgat/Components"] + conda_includes,
language="c++",
),
Extension(
"cgat.NCL.cnestedlist",
["cgat/NCL/cnestedlist.pyx", "cgat/NCL/intervaldb.c"],
include_dirs=["cgat/NCL"] + conda_includes,
language="c",
),
Extension(
Expand All @@ -67,6 +44,7 @@
define_macros=pysam.get_defines(),
language="c",
),
# Additional extensions for BamTools, VCFTools, and FastqTools
Extension(
"cgat.BamTools.bamtools",
["cgat/BamTools/bamtools.pyx"],
Expand All @@ -77,26 +55,6 @@
language="c",
extra_link_args=extra_link_args_pysam,
),
Extension(
"cgat.BamTools.geneprofile",
["cgat/BamTools/geneprofile.pyx"],
include_dirs=conda_includes + pysam.get_include() + [numpy.get_include()],
library_dirs=pysam_libdirs,
libraries=pysam_libs,
define_macros=pysam.get_defines(),
language="c",
extra_link_args=extra_link_args_pysam,
),
Extension(
"cgat.BamTools.peakshape",
["cgat/BamTools/peakshape.pyx"],
include_dirs=conda_includes + pysam.get_include() + [numpy.get_include()],
library_dirs=pysam_libdirs,
libraries=pysam_libs,
define_macros=pysam.get_defines(),
language="c",
extra_link_args=extra_link_args_pysam,
),
Extension(
"cgat.VCFTools",
["cgat/VCFTools/vcftools.pyx"],
Expand All @@ -107,33 +65,33 @@
language="c",
extra_link_args=extra_link_args_pysam,
),
Extension(
"cgat.FastqTools",
["cgat/FastqTools/fastqtools.pyx"],
include_dirs=conda_includes + pysam.get_include() + [numpy.get_include()],
library_dirs=pysam_libdirs,
libraries=pysam_libs,
define_macros=pysam.get_defines(),
language="c",
extra_link_args=extra_link_args_pysam,
),
]

# Build setup configuration
setup(
name="cgat",
version="0.7.7",
description="Computational Genomics Analysis Toolkit",
author="Adam Cribbs",
author_email="[email protected]",
license="MIT",
packages=cgat_packages,
package_dir=cgat_package_dirs,
include_package_data=True,
package_data={
"cgat.Components": ["*.h"],
},
ext_modules=extensions,
cmdclass={'build_ext': build_ext},
zip_safe=False,
cmdclass={"build_ext": cython_build_ext},
entry_points={
'console_scripts': [
'cgat = cgat.cgat.main',
],
},
test_suite="tests",
"console_scripts": [
"cgat = cgat.cgat:main",
]
},
zip_safe=False,
install_requires=[
"Cython>=0.29.35",
"numpy",
"pysam",
],
)

0 comments on commit cba8541

Please sign in to comment.