Skip to content

Commit

Permalink
Update build system.
Browse files Browse the repository at this point in the history
  • Loading branch information
erykoff committed Jun 20, 2024
1 parent 1d2feea commit b905571
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 55 deletions.
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build-system]
requires = [
"setuptools>=46",
"wheel",
"oldest-supported-numpy",
]
build-backend = "setuptools.build_meta"
43 changes: 43 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[metadata]
name = redmapper
description = Python implementation of redMaPPer cluster finder
long_description = file: README.md
long_description_content_type = text/markdown
author = Eli Rykoff
url = https://github.com/erykoff/redmapper
author_email = erykoff@stanford.edu
classifiers =
Intended Audience :: Science/Research
License :: OSI Approved :: Apache Software License
Operating System :: POSIX :: Linux
Operating System :: MacOS
Programming Language :: C
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10

[options]
packages = find:
python_requires = >=3.8
install_requires =
astropy
matplotlib
pyyaml
fitsio
esutil
numpy
scipy
healsparse
hpgeom
tests_require =
pytest
zip_safe = True

[options.packages.find]
exclude =
tests

[options.package_data]
redmapper = data/initcolors/*.fit, data/mstar/*.fit
79 changes: 24 additions & 55 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
# -*- coding: utf-8 -*-
from setuptools import setup, Extension
import numpy
import os

from setuptools import setup, find_packages, Extension, Command
import numpy,os,glob

with open('README.md') as f:
readme = f.read()

with open('LICENSE') as f:
license = f.read()

exec(open('redmapper/_version.py').read())

Expand All @@ -31,55 +25,30 @@
'bin/redmapper_weight_randoms.py',
'bin/redmapper_predict_memory.py']

include_dirs = [numpy.get_include()]

ext_modules=[]

# solver_nfw
solver_nfw_sources=['redmapper/solver_nfw/solver_nfw_pywrap.c',
'redmapper/solver_nfw/solver_nfw.c',
'redmapper/solver_nfw/nfw_weights.c']
solver_nfw_module = Extension('redmapper.solver_nfw._solver_nfw_pywrap',
extra_compile_args=['-std=gnu99'],
sources=solver_nfw_sources,
include_dirs=include_dirs)
ext_modules.append(solver_nfw_module)

# chisq_dist
chisq_dist_sources=['redmapper/chisq_dist/chisq_dist.c',
'redmapper/chisq_dist/chisq_dist_pywrap.c']
chisq_dist_module = Extension('redmapper.chisq_dist._chisq_dist_pywrap',
extra_compile_args=['-std=gnu99',os.path.expandvars('-I${GSLI}')],
extra_link_args=[os.path.expandvars('-L${GSLL}')],
libraries=['gsl', 'gslcblas'],
sources=chisq_dist_sources,
include_dirs=include_dirs)
ext_modules.append(chisq_dist_module)
solver_nfw_ext = Extension(
"redmapper.solver_nfw._solver_nfw_pywrap",
extra_compile_args=["-std=gnu99"],
sources=[
"redmapper/solver_nfw/solver_nfw_pywrap.c",
"redmapper/solver_nfw/solver_nfw.c",
"redmapper/solver_nfw/nfw_weights.c",
],
)

class CleanCommand(Command):
"""Custom clean command to tidy up the project root."""
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
os.system('rm -vrf ./build ./dist ./*.pyc ./*.tgz ./*.egg-info')
chisq_dist_ext = Extension(
"redmapper.chisq_dist._chisq_dist_pywrap",
extra_compile_args=["-std=gnu99", os.path.expandvars("-I${GSLI}")],
extra_link_args=[os.path.expandbars("-L${GSLL}")],
libraries=["gsl", "gslcblas"],
sources=[
"redmapper/chisq_dist/chisq_dist.c",
"redmapper/chisq_dist/chisq_dist_pywrap.c",
],
)

setup(
name='redmapper',
ext_modules=[solver_nfw_ext, chisq_dist_ext],
include_dirs=numpy.get_include(),
version=__version__,
description='Public, Python implementation of redMaPPer',
long_description=readme,
author='Eli Rykoff, Brett Harvey',
author_email='erykoff@slac.stanford.edu, rbharvey@stanford.edu',
url='https://github.com/erykoff/redmapper',
license=license,
ext_modules=ext_modules,
scripts=scripts,
install_requires=['numpy'],
packages=find_packages(exclude=('tests', 'docs')),
include_package_data=True,
cmdclass={'clean': CleanCommand}
)

0 comments on commit b905571

Please sign in to comment.