Skip to content

Commit

Permalink
BLD: update build system and use pyproject.toml (#1144)
Browse files Browse the repository at this point in the history
* BLD: update build system and use pyproject.toml
  • Loading branch information
fangchenli authored May 9, 2024
1 parent c410d19 commit 9a11985
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
pip install --no-build-isolation classy==2.9.4
- name: Install CCL
run: pip install -v -e .
run: pip install --no-use-pep517 -v -e .

- name: Unit tests
run: |
Expand Down
47 changes: 47 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[build-system]
requires = ["setuptools>=64", "setuptools_scm>=8", "cmake", "swig"]

[project]
name = "pyccl"
authors = [
{name = "LSST DESC"},
]
description="Library of validated cosmological functions."
readme = "README.md"
requires-python = ">=3.8"
keywords = ["cosmology", "astrophysics", "physics", "science", "LSST"]
license = { text = "BSD" }
dynamic = ["version"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX :: Linux",
"Programming Language :: C",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Astronomy",
"Topic :: Scientific/Engineering :: Physics",
]
dependencies = [
"numpy",
]

[project.urls]
homepage = "https://lsstdesc.org/"
documentation = "https://ccl.readthedocs.io/en/latest/"
repository = "https://github.com/LSSTDESC/CCL"

[project.optional-dependencies]
dev = [
"pytest",
"pytest-cov",
]

[tool.setuptools.packages.find]
include = ["pyccl*"]

[tool.setuptools.package-data]
pyccl = ["_ccllib.so", "emulators/data/*.npz"]

[tool.setuptools_scm]
57 changes: 7 additions & 50 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/usr/bin/env python
from setuptools.command.build_py import build_py as _build
from setuptools.command.develop import develop as _develop
from distutils.command.clean import clean as _clean
from setuptools import Distribution as _distribution
from setuptools import setup, find_packages
from subprocess import call
from io import open
import os
import shutil
import sys
from subprocess import call

from setuptools import Distribution as _distribution
from setuptools import setup
from setuptools.command.build_py import build_py as _build
from setuptools.command.develop import develop as _develop


def _compile_ccl(debug=False):
Expand Down Expand Up @@ -64,47 +61,7 @@ def run(self):
_develop.run(self)


class Clean(_clean):
"""Remove the copied _ccllib.so"""
def run(self):
if os.path.isfile("pyccl/_ccllib.so"):
os.remove("pyccl/_ccllib.so")
print("Removed pyccl/_ccllib.so")
_clean.run(self)
shutil.rmtree("build")
print("Removed build.")


# read the contents of the README file
with open('README.md', encoding="utf-8") as f:
long_description = f.read()

setup(
name="pyccl",
description="Library of validated cosmological functions.",
long_description=long_description,
long_description_content_type='text/markdown',
author="LSST DESC",
url="https://github.com/LSSTDESC/CCL",
packages=find_packages(),
provides=['pyccl'],
package_data={'pyccl': ['_ccllib.so', 'emulators/data/*.npz']},
include_package_data=True,
use_scm_version=True,
distclass=Distribution,
python_requires='>=3.8',
setup_requires=['setuptools_scm'],
install_requires=['numpy'],
cmdclass={'build_py': Build, 'develop': Develop, 'clean': Clean},
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Operating System :: MacOS :: MacOS X',
'Operating System :: POSIX :: Linux',
'Programming Language :: C',
'Programming Language :: Python',
'Topic :: Scientific/Engineering :: Physics',
'Topic :: Scientific/Engineering :: Astronomy',
]
cmdclass={'build_py': Build, 'develop': Develop},
)

0 comments on commit 9a11985

Please sign in to comment.