diff --git a/.github/workflows/sdist.yml b/.github/workflows/sdist.yml new file mode 100644 index 0000000..fed37df --- /dev/null +++ b/.github/workflows/sdist.yml @@ -0,0 +1,23 @@ +name: Tests build sdist + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + build_sdist: + name: Build diffpy.pdffit2 sdist + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + + - name: Build sdist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v4 + with: + name: cibw-sdist + path: ./dist/*.tar.gz diff --git a/news/sdist.rst b/news/sdist.rst new file mode 100644 index 0000000..a2d8095 --- /dev/null +++ b/news/sdist.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* Changed setup.py to lazy evaluate gsl installation. + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/setup.py b/setup.py index 504267b..4633f1a 100755 --- a/setup.py +++ b/setup.py @@ -141,53 +141,54 @@ def run(self): shutil.copy(str(dll_file), str(dest_path)) -# Compile and link options---------------------------------------------------- - -os_name = os.name -gcfg = get_gsl_config() - -# On macOS, dynamic linking may not be needed -if sys.platform == "darwin": - libraries = [] -else: - libraries = ["gsl"] - -include_dirs = [MYDIR] + gcfg["include_dirs"] -library_dirs = gcfg["library_dirs"] -define_macros = [] -extra_objects = [] -extra_compile_args = [] -extra_link_args = [] - -compiler_type = get_compiler_type() -if compiler_type in ("unix", "cygwin", "mingw32"): - extra_compile_args = ["-std=c++11", "-Wall", "-Wno-write-strings", "-O3", "-funroll-loops", "-ffast-math"] - # Check for static GSL libraries and add them if found. - static_libs = [ - os.path.join(p, "libgsl.a") for p in gcfg["library_dirs"] if os.path.isfile(os.path.join(p, "libgsl.a")) - ] - if static_libs: - extra_objects += static_libs - # Use static linking: remove "-lgsl" to avoid dynamic linking conflicts. - libraries = [] -elif compiler_type == "msvc": - define_macros += [("_USE_MATH_DEFINES", None)] - extra_compile_args = ["/EHs"] - -# Extension keyword arguments. -ext_kws = { - "include_dirs": include_dirs, - "libraries": libraries, - "library_dirs": library_dirs, - "define_macros": define_macros, - "extra_compile_args": extra_compile_args, - "extra_link_args": extra_link_args, - "extra_objects": extra_objects, -} - - def create_extensions(): """Create the list of Extension objects for the build.""" + # lazy evaluation prevents build sdist failure + try: + gcfg = get_gsl_config() + except EnvironmentError: + return [] + + # On macOS, dynamic linking may not be needed + if sys.platform == "darwin": + libraries = [] + else: + libraries = ["gsl"] + + include_dirs = [MYDIR] + gcfg["include_dirs"] + library_dirs = gcfg["library_dirs"] + define_macros = [] + extra_objects = [] + extra_compile_args = [] + extra_link_args = [] + + compiler_type = get_compiler_type() + if compiler_type in ("unix", "cygwin", "mingw32"): + extra_compile_args = ["-std=c++11", "-Wall", "-Wno-write-strings", "-O3", "-funroll-loops", "-ffast-math"] + # Check for static GSL libraries and add them if found. + static_libs = [ + os.path.join(p, "libgsl.a") + for p in gcfg["library_dirs"] + if os.path.isfile(os.path.join(p, "libgsl.a")) + ] + if static_libs: + extra_objects += static_libs + # Use static linking: remove "-lgsl" to avoid dynamic linking conflicts. + libraries = [] + elif compiler_type == "msvc": + define_macros += [("_USE_MATH_DEFINES", None)] + extra_compile_args = ["/EHs"] + + # Extension keyword arguments. + ext_kws = { + "include_dirs": include_dirs, + "libraries": libraries, + "library_dirs": library_dirs, + "define_macros": define_macros, + "extra_compile_args": extra_compile_args, + "extra_link_args": extra_link_args, + "extra_objects": extra_objects, + } ext = Extension("diffpy.pdffit2.pdffit2", glob.glob("src/extensions/**/*.cc"), **ext_kws) return [ext]