From 00f5a980c94b33761fb9f6f1a9962d608dc959b1 Mon Sep 17 00:00:00 2001 From: Laurent Rene de Cotret Date: Wed, 1 May 2024 10:10:52 -0400 Subject: [PATCH] Updated setup script --- setup.py | 70 ++------------------------------------------------------ 1 file changed, 2 insertions(+), 68 deletions(-) diff --git a/setup.py b/setup.py index 39a59e7..775d4af 100644 --- a/setup.py +++ b/setup.py @@ -1,25 +1,18 @@ # -*- encoding: utf-8 -*- -import os -import platform import re -import shutil -import tempfile from glob import glob from itertools import chain from pathlib import Path -import numpy -from setuptools import Extension, find_packages, setup -from setuptools.command.build_ext import build_ext -from distutils.errors import CompileError, LinkError +from setuptools import find_packages, setup PACKAGE_NAME = "crystals" DESCRIPTION = "Data structures for crystallography" URL = "http://crystals.readthedocs.io" DOWNLOAD_URL = "http://github.com/LaurentRDC/crystals" AUTHOR = "Laurent P. René de Cotret" -AUTHOR_EMAIL = "laurent.renedecotret@mail.mcgill.ca" +AUTHOR_EMAIL = "laurent.decotret@outlook.com" CIF_FILES = chain.from_iterable([glob("crystals\\cifs\\*.cif")]) @@ -40,64 +33,6 @@ REQUIREMENTS = [line for line in f.read().split("\n") if len(line.strip())] -# Support for openmp -# This idea is from scikit-image: -# https://github.com/scikit-image/scikit-image/ -class BuildExtWithOpenMP(build_ext): - """ - Try to compile extensions with OpenMP if possible - """ - - def can_compile_link(self, compile_flags, link_flags): - cc = self.compiler - fname = "test.c" - cwd = os.getcwd() - tmpdir = tempfile.mkdtemp() - - code = "#include " "int main(int argc, char** argv) { return(0); }" - - if self.compiler.compiler_type == "msvc": - # make sure we build a DLL on Windows - local_link_flags = link_flags + ["/DLL"] - else: - local_link_flags = link_flags - - try: - os.chdir(tmpdir) - with open(fname, "wt") as fobj: - fobj.write(code) - try: - objects = cc.compile([fname], extra_postargs=compile_flags) - except CompileError: - return False - try: - # Link shared lib rather then executable to avoid - # http://bugs.python.org/issue4431 with MSVC 10+ - cc.link_shared_lib(objects, "testlib", extra_postargs=local_link_flags) - except (LinkError, TypeError): - return False - finally: - os.chdir(cwd) - shutil.rmtree(tmpdir) - return True - - def build_extensions(self): - """Hook into extension building to set compiler flags""" - if self.compiler.compiler_type == "msvc": - compile_flags = ["/openmp"] - link_flags = [] - else: - compile_flags = ["-fopenmp"] - link_flags = ["-fopenmp"] - - if self.can_compile_link(compile_flags, link_flags): - for ext in self.extensions: - ext.extra_compile_args += compile_flags - ext.extra_link_args += link_flags - - return super().build_extensions() - - if __name__ == "__main__": setup( name=PACKAGE_NAME, @@ -122,7 +57,6 @@ def build_extensions(self): packages=find_packages(), data_files=[("crystals\\cifs", CIF_FILES)], include_package_data=True, - cmdclass=dict(build_ext=BuildExtWithOpenMP), zip_safe=False, entry_points={"console_scripts": ["crystals = crystals.__main__:main"]}, # list of possible classifiers: