python3Packages.astropy-extension-helpers: init at 0.1

This commit is contained in:
Robert T. McGibbon
2020-12-27 19:15:59 -05:00
parent 182945f285
commit 7ef5a93fe1
4 changed files with 53 additions and 43 deletions

View File

@@ -0,0 +1,31 @@
{ lib
, buildPythonPackage
, fetchPypi
, pytestCheckHook
}:
buildPythonPackage rec {
pname = "extension-helpers";
version = "0.1";
format = "pyproject";
src = fetchPypi {
inherit pname version;
sha256 = "10iqjzmya2h4sk765dlm1pbqypwlqyh8rw59a5m9i63d3klnz2mc";
};
patches = [ ./permissions.patch ];
checkInputs = [ pytestCheckHook ];
pythonImportsCheck = [
"extension_helpers"
];
meta = with lib; {
description = "Utilities for building and installing packages in the Astropy ecosystem";
homepage = "https://github.com/astropy/extension-helpers";
license = licenses.bsd3;
maintainers = [ maintainers.rmcgibbo ];
};
}

View File

@@ -0,0 +1,20 @@
diff --git a/extension_helpers/_setup_helpers.py b/extension_helpers/_setup_helpers.py
index ec3e547..e2419f7 100644
--- a/extension_helpers/_setup_helpers.py
+++ b/extension_helpers/_setup_helpers.py
@@ -79,8 +79,13 @@ def get_extensions(srcdir='.'):
if len(ext_modules) > 0:
main_package_dir = min(packages, key=len)
src_path = os.path.join(os.path.dirname(__file__), 'src')
- shutil.copy(os.path.join(src_path, 'compiler.c'),
- os.path.join(srcdir, main_package_dir, '_compiler.c'))
+ a = os.path.join(src_path, 'compiler.c')
+ b = os.path.join(srcdir, main_package_dir, '_compiler.c')
+ try:
+ os.unlink(b)
+ except OSError:
+ pass
+ shutil.copy(a, b)
ext = Extension(main_package_dir + '.compiler_version',
[os.path.join(main_package_dir, '_compiler.c')])
ext_modules.append(ext)