Skip to content

Commit

Permalink
Merge pull request astropy#10581 from pllim/distutils-wcs-ext-test
Browse files Browse the repository at this point in the history
MNT: Replace distutils with setuptools in wcs extension test
  • Loading branch information
embray authored Jun 29, 2021
2 parents 1ff9035 + d2cf590 commit 00b7498
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
8 changes: 2 additions & 6 deletions astropy/wcs/tests/extension/setup.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst


import os
import sys

if __name__ == '__main__':
astropy_path = sys.argv[-1]
sys.argv = sys.argv[:-1]
sys.path.insert(0, astropy_path)
from setuptools import setup, Extension

from astropy import wcs
import numpy as np
from distutils.core import setup, Extension
from astropy import wcs

if sys.platform == 'win32':
# These are written into wcsconfig.h, but that file is not
Expand Down
16 changes: 13 additions & 3 deletions astropy/wcs/tests/extension/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@

import pytest

import astropy


def test_wcsapi_extension(tmpdir):
# Test that we can build a simple C extension with the astropy.wcs C API

build_dir = tmpdir.mkdir('build').strpath
install_dir = tmpdir.mkdir('install').strpath
record_file = os.path.join(build_dir, 'record.txt')

setup_path = os.path.dirname(__file__)
astropy_path = os.path.abspath(
os.path.join(setup_path, '..', '..', '..', '..'))
astropy_path = os.path.dirname(astropy.__path__[0])

env = os.environ.copy()
paths = [install_dir, astropy_path]
Expand All @@ -30,10 +32,18 @@ def test_wcsapi_extension(tmpdir):
# *unless* the output is redirected. This bug also did not occur in an
# interactive session, so it likely had something to do with pytest's
# output capture
#
# --single-version-externally-managed --record is essentially equivalent to
# what pip does; otherwise setuptools' `setup.py install` will try to build
# and install an egg (deprecated behavior, but still the default for
# backwards-compat).
# In the future we might change this to just run pip.
p = subprocess.Popen([sys.executable, 'setup.py', 'build',
f'--build-base={build_dir}', 'install',
f'--install-lib={install_dir}',
astropy_path], cwd=setup_path, env=env,
'--single-version-externally-managed',
f'--record={record_file}'],
cwd=setup_path, env=env,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)

# Whether the process fails or not this isn't likely to produce a great
Expand Down

0 comments on commit 00b7498

Please sign in to comment.