Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build system + tox #297

Merged
merged 3 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ docs:
- docs/_static/*
- docs/_templates/*
- licenses/*
- synphot/docstrings.py
- '*.md'
- any: ['*.rst', '!CHANGES.rst']

Expand All @@ -27,9 +26,8 @@ binning:
- synphot/binning.py

C-extension:
- synphot/docstrings.py
- synphot/setup_package.py
- synphot/src/*
- synphot/include/*

config:
- synphot/config.py
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
if: matrix.language == 'cpp'
run: |
pip install -U pip setuptools_scm wheel
pip install extension-helpers numpy astropy
pip install numpy astropy
python setup.py build_ext --inplace

- name: Perform CodeQL Analysis
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ include CITATION.md

include setup.cfg
include pyproject.toml
include synphot/include/.gitignore

recursive-include synphot/include *.h
recursive-include synphot *.c
recursive-include docs *
recursive-include licenses *
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
requires = ["setuptools>=30.3.0",
"setuptools_scm",
"wheel",
"oldest-supported-numpy",
"extension-helpers"]
"oldest-supported-numpy"]
build-backend = "setuptools.build_meta"
24 changes: 0 additions & 24 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,6 @@ docs =
[options.package_data]
synphot.tests = data/*

[extension=synphot.synphot_utils]
optional = True
fail_message =
*********************************************************
Build failed, trying without C extension.
This removes no functionality but may affect performance.
*********************************************************

[flake8]
# Ignoring these for now:
# I100: import statements are in the wrong order
Expand All @@ -78,27 +70,11 @@ ignore = I100,I201,W504
source = synphot
omit =
synphot/_astropy_init*
synphot/cython_version*
synphot/setup_package*
synphot/*/setup_package*
synphot/*/*/setup_package*
synphot/tests/*
synphot/*/tests/*
synphot/*/*/tests/*
synphot/version*
synphot/extern/*
synphot/docstrings.py
*/synphot/_astropy_init*
*/synphot/cython_version*
*/synphot/setup_package*
*/synphot/*/setup_package*
*/synphot/*/*/setup_package*
*/synphot/tests/*
*/synphot/*/tests/*
*/synphot/*/*/tests/*
*/synphot/version*
*/synphot/extern/*
*/synphot/docstrings.py

[coverage:report]
exclude_lines =
Expand Down
25 changes: 16 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
#!/usr/bin/env python
# Licensed under a 3-clause BSD style license - see LICENSE.rst

import os
import sys
from setuptools import setup
from setuptools import setup, Extension

try:
from extension_helpers import get_extensions
except ModuleNotFoundError:
print("""
extension-helpers is not detected, please install with:

pip install -e .
""")
sys.exit(1)
def get_extensions():
from collections import defaultdict
import numpy

cfg = defaultdict(list)
cfg['include_dirs'].extend([
numpy.get_include(),
os.path.join('synphot', 'include')])
cfg['sources'] = [
os.path.join('synphot', 'src', 'synphot_utils.c')]
cfg = dict((str(key), val) for key, val in cfg.items())

return [Extension('synphot.synphot_utils', **cfg)]


TEST_HELP = """
Note: running tests is no longer done using 'python setup.py test'. Instead
Expand Down
2 changes: 1 addition & 1 deletion synphot/binning.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _slow_calcbinflux(len_binwave, i_beg, i_end, avflux, deltaw):
This is only used if ``synphot.synphot_utils`` C-extension
import fails.

See docstrings.py
See ``include/synphot_utils.h``.

"""
binflux = np.empty(shape=(len_binwave, ), dtype=np.float64)
Expand Down
39 changes: 0 additions & 39 deletions synphot/docstrings.py

This file was deleted.

1 change: 0 additions & 1 deletion synphot/include/.gitignore

This file was deleted.

38 changes: 38 additions & 0 deletions synphot/include/synphot_utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef SYNPHOT_UTILS__H
#define SYHPHOT_UTILS__H

#define doc_calcbinflux \
"\
\n\
\n\
\n\
calcbinflux(len_binwave, i_beg, i_end, avflux, deltaw)\n\
\n\
Sum over each bin.\n\
\n\
Parameters\n\
----------\n\
len_binwave : int\n\
Number of wavelength bin centers.\n\
\n\
i_beg, i_end : array-like\n\
Locations of bin edges in ``deltaw``.\n\
\n\
avflux : array-like\n\
Average flux associated with ``deltaw``.\n\
\n\
deltaw : array-like\n\
Delta of merge wavelengths (native + centers + edges).\n\
Values are in ascending order.\n\
\n\
Returns\n\
-------\n\
binflux : array-like\n\
Integrated flux associated with given bins in ascending order.\n\
\n\
intwave : array-like\n\
Integrated delta wavelength associated with ``binflux``.\n\
\n\
\0"

#endif
117 changes: 0 additions & 117 deletions synphot/setup_package.py

This file was deleted.

5 changes: 0 additions & 5 deletions synphot/src/.gitignore

This file was deleted.

3 changes: 1 addition & 2 deletions synphot/src/synphot_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

#include "Python.h"
#include <numpy/arrayobject.h>

#include "docstrings.h"
#include "synphot_utils.h"


static PyObject * py_calcbinflux(PyObject *self, PyObject *args) {
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ extras =

commands =
# FIXME: Not sure why need this for tox to see the C-ext
python -m pip install extension-helpers
python setup.py build_ext --inplace
# End of FIXME
pip freeze
Expand Down