<commit_before>#!/usr/bin/env python

import shutil
from distutils.core import setup, Extension
import distutils.sysconfig
import os
import stat
import commands
import sys

gnofract4d_version = '3.14.1'

if float(sys.version[:3]) < 2.4:
    print "Sorry, you need Python 2.4 or higher to run Gnofract 4D."
    print "You have version %s. Please upgrade." % sys.version
    sys.exit(1)

# by default python uses all the args which were used to compile it. But Python is C and some
# extension files are C++, resulting in annoying '-Wstrict-prototypes is not supported' messages.
# tweak the cflags to override
os.environ["CFLAGS"]= distutils.sysconfig.get_config_var("CFLAGS").replace("-Wstrict-prototypes","")
os.environ["OPT"]= distutils.sysconfig.get_config_var("OPT").replace("-Wstrict-prototypes","")

from buildtools import my_install_lib

# Extensions need to link against appropriate libs
# We use pkg-config to find the appropriate set of includes and libs

def call_package_config(package,option,optional=False):
    '''invoke pkg-config, if it exists, to find the appropriate
    arguments for a library'''
    cmd = "pkg-config %s %s" % (package, option)
    (status,output) = commands.getstatusoutput(cmd)
    if status != 0:
        if optional:
            print >>sys.stderr, "Can't find '%s'" % package
            print >>sys.stderr, "Some functionality will be disabled"
            return []
        else:
            print >>sys.stderr, "Can't set up. Error running '%s'." % cmd
            print >>sys.stderr, output
            print >>sys.stderr, "Possibly you don't have one of these installed: '%s'." % package
            sys.exit(1)

    return output.split()

extra_macros = []

png_flags = call_package_config("libpng", "--cflags", True)
if png_flags != []:
    extra_macros.append(('PNG_ENABLED', 1))
else:
    print "NO PNG HEADERS FOUND, install libpng-dev"
    
png_libs = call_package_config("libpng", "--libs", True)

jpg_lib = "jpeg"
if os.path.isfile("/usr/include/jpeglib.h"):
    extra_macros.append(('JPG_ENABLED', 1))
    jpg_libs = [ jpg_lib ]
else:
    print "NO JPEG HEADERS FOUND, install libjpeg-dev"
    jpg_libs = []

#not ready yet. 
have_gmp = False # os.path.isfile("/usr/include/gmp.h")
<commit_msg>make it so we completely fail if PNG and JPG headers are missing, compiling anyway is just confusing people<commit_after>#!/usr/bin/env python

import shutil
from distutils.core import setup, Extension
import distutils.sysconfig
import os
import stat
import commands
import sys

gnofract4d_version = '3.14.1'

if float(sys.version[:3]) < 2.4:
    print "Sorry, you need Python 2.4 or higher to run Gnofract 4D."
    print "You have version %s. Please upgrade." % sys.version
    sys.exit(1)

# by default python uses all the args which were used to compile it. But Python is C and some
# extension files are C++, resulting in annoying '-Wstrict-prototypes is not supported' messages.
# tweak the cflags to override
os.environ["CFLAGS"]= distutils.sysconfig.get_config_var("CFLAGS").replace("-Wstrict-prototypes","")
os.environ["OPT"]= distutils.sysconfig.get_config_var("OPT").replace("-Wstrict-prototypes","")

from buildtools import my_install_lib

# Extensions need to link against appropriate libs
# We use pkg-config to find the appropriate set of includes and libs

def call_package_config(package,option,optional=False):
    '''invoke pkg-config, if it exists, to find the appropriate
    arguments for a library'''
    cmd = "pkg-config %s %s" % (package, option)
    (status,output) = commands.getstatusoutput(cmd)
    if status != 0:
        if optional:
            print >>sys.stderr, "Can't find '%s'" % package
            print >>sys.stderr, "Some functionality will be disabled"
            return []
        else:
            print >>sys.stderr, "Can't set up. Error running '%s'." % cmd
            print >>sys.stderr, output
            print >>sys.stderr, "Possibly you don't have one of these installed: '%s'." % package
            sys.exit(1)

    return output.split()

extra_macros = []

png_flags = call_package_config("libpng", "--cflags", True)
if png_flags != []:
    extra_macros.append(('PNG_ENABLED', 1))
else:
    raise Exception("NO PNG HEADERS FOUND, you need to install libpng-dev")
    
png_libs = call_package_config("libpng", "--libs", True)

jpg_lib = "jpeg"
if os.path.isfile("/usr/include/jpeglib.h"):
    extra_macros.append(('JPG_ENABLED', 1))
    jpg_libs = [ jpg_lib ]
else:
    raise Exception("NO JPEG HEADERS FOUND, you need to install libjpeg-dev")
    jpg_libs = []

#not ready yet. 
have_gmp = False # os.path.isfile("/usr/include/gmp.h")

{'fraction_non_alphanumeric': 0.12214562688496337, 'fraction_numerical': 0.006893580353295993, 'mean_word_length': 3.5653883972468043, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '841132', 'n_tokens_mistral': 1497, 'n_tokens_neox': 1442, 'n_words': 468}