https://github.com/Chandra-MARX/marxs
Raw File
Tip revision: 5388f52dd892f630d593ea186eee6ad3f6f92723 authored by H. Moritz Günther on 03 May 2024, 17:26:46 UTC
Typo (extra white space)
Tip revision: 5388f52
setup.py
#!/usr/bin/env python
# Licensed under a 3-clause BSD style license - see LICENSE.rst

# NOTE: The configuration for the package, including the name, version, and
# other information are set in the setup.cfg file.

import os
import sys

from setuptools import setup

# To get MARX binary info
from configparser import ConfigParser, NoOptionError

# First provide helpful messages if contributors try and run legacy commands
# for tests or docs.

TEST_HELP = """
Note: running tests is no longer done using 'python setup.py test'. Instead
you will need to run:

    tox -e test

If you don't already have tox installed, you can install it with:

    pip install tox

If you only want to run part of the test suite, you can also use pytest
directly with::

    pip install -e .[test]
    pytest

For more information, see:

  http://docs.astropy.org/en/latest/development/testguide.html#running-tests
"""

if 'test' in sys.argv:
    print(TEST_HELP)
    sys.exit(1)

DOCS_HELP = """
Note: building the documentation is no longer done using
'python setup.py build_docs'. Instead you will need to run:

    tox -e build_docs

If you don't already have tox installed, you can install it with:

    pip install tox

You can also build the documentation with Sphinx directly using::

    pip install -e .[docs]
    cd docs
    make html

For more information, see:

  http://docs.astropy.org/en/latest/install.html#builddocs
"""

if 'build_docs' in sys.argv or 'build_sphinx' in sys.argv:
    print(DOCS_HELP)
    sys.exit(1)

# check is MARX C code is configured in setup.py and if it is, add to
# appropriate arguments to setup args
conf = ConfigParser()
conf.read(['setup.cfg'])
setup_args = {}
try:
    marxscr = conf.get('MARX', 'srcdir')
    marxlib = conf.get('MARX', 'libdir')
    if marxscr and marxlib:
        setup_args['cffi_modules'] = ["marxs/optics/marx_build.py:ffi"]
        print('Using MARX C code at {0}\n and compiled libraries at {1}'.format(marxscr, marxlib))
    else:
        print('MARX C code is not configured in setup.cfg - modules will be disabled.')
except NoOptionError:
    print('MARX C code is not configured in setup.cfg - modules will be disabled.')


VERSION_TEMPLATE = """
# Note that we need to fall back to the hard-coded version if either
# setuptools_scm can't be imported or setuptools_scm can't determine the
# version, so we catch the generic 'Exception'.
try:
    from setuptools_scm import get_version
    version = get_version(root='..', relative_to=__file__)
except Exception:
    version = '{version}'
""".lstrip()

setup(use_scm_version={'write_to': os.path.join('marxs', 'version.py'),
                       'write_to_template': VERSION_TEMPLATE},
      #ext_modules=get_extensions(),
      **setup_args
      )
back to top