Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: setup.py can now find numpy #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from setuptools import setup, Extension
import numpy
from setuptools.command.build_ext import build_ext as _build_ext
from fastgrab import metadata

module_info = Extension(
"fastgrab._linux_x11",
include_dirs=[numpy.get_include()],
include_dirs=[], # Populated by build_ext().
libraries=['X11', 'gomp'],
extra_compile_args=[
'-fno-strict-aliasing',
Expand All @@ -15,12 +15,25 @@
sources=["fastgrab/linux_x11/screenshot.c"]
)

class build_ext(_build_ext):
def finalize_options(self):
_build_ext.finalize_options(self)
# Prevent numpy from thinking it's still in its setup process.
# NOTE: Doesn't exist in modern numpy versions.
if "__NUMPY_SETUP__" in __builtins__:
__builtins__.__NUMPY_SETUP__ = False
# Add the numpy header directory to our build process.
import numpy
self.include_dirs.append(numpy.get_include())

setup(
name=metadata.package,
version=metadata.version,
description=metadata.description,
author=metadata.authors,
url=metadata.url,
packages=[metadata.package],
cmdclass={'build_ext':build_ext},
setup_requires=['numpy'],
ext_modules=[module_info]
)