<commit_before># -*- coding: utf-8 -*-
# Copyright 2016 <NAME>, <NAME>
#     https://www.tu-ilmenau.de/it-ems/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
'''Setup script for installation of fastmat package

  Usecases:
    - install fastmat package system-wide on your machine (needs su privileges)
        EXAMPLE:        'python setup.py install'

    - install fastmat package for your local user only (no privileges needed)
        EXAMPLE:        'python setup.py install --user'

    - compile all cython source files locally
        EXAMPLE:        'python setup.py build_ext --inplace'
'''

# import modules
import platform
import sys
import os
import re
import subprocess
from distutils import sysconfig

packageName     = 'fastmat'
packageVersion  = '0.1.2'           # provide a version tag as fallback
fullVersion     = packageVersion
strVersionFile  = "%s/version.py" %(packageName)

VERSION_PY = """
# -*- coding: utf-8 -*-
# This file carries the module's version information which will be updated
# during execution of the installation script, setup.py. Distribution tarballs
# contain a pre-generated copy of this file.

__version__ = '%s'
"""


def WARNING(string):
    print("\033[91m WARNING:\033[0m %s" % (string))


# load setup and extensions from setuptools. If that fails, try distutils
try:
    from setuptools import setup, Extension
except ImportError:
    WARNING("Could not import setuptools.")
    raise


# Determine package version
def getCurrentVersion():
    global packageVersion
    global fullVersion

    # check if there is a manual version override
    if os.path.isfile(".version"):
        with open(".version", "r") as f:
            stdout = f.read().split('\n')[0]
        print("Override of version string to '%s' (from .version file )" % (
            stdout))

        packageVersion = stdout

    else:
        # check if source directory is a git repository
        if not os.path.exists(".git"):
            print(("Installing from something other than a Git repository; " +
                   "Version file '%s' untouched.") % (strVersionFile))
            return

        # fetch current tag and commit description from git
        try:
            p = subprocess.Popen(
                ["git", "describe", "--tags", "--dirty", "--always"],
                stdout=subprocess.PIPE
            )
        except EnvironmentError:
            print("Not a git repository; Version file '%s' not touched." % (
                strVersionFile))
            return

        stdout = p.communicate()[0].strip()
        if stdout is not str:
            stdout = stdout.decode()

        if p.returncode != 0:
            print(("Unable to fetch version from git repository; " +
                   "leaving version file '%s' untouched.") % (strVersionFile))
            return

        # output results to version string, extract package version number
        # from git tag
        fullVersion = stdout
        versionMatch = re.match(r"[.+\d+]+\d*[abr]\d*", fullVersion)
        if versionMatch:
            packageVersion = versionMatch.group(0)
            print("Fetched package version number from git tag (%s)." % (
                packageVersion))


# get version from git and update fastmat/__init__.py accordingly
getCurrentVersion()

# make sure there exists a version.py file in the project
with open(strVersionFile, "w") as f:
    f.write(VERSION_PY % (fullVersion))
print("Set %s to '%s'" % (strVersionFile, fullVersion))


# Prepare other files and construct compile arguments

# get the long description from the README file.
# CAUTION: Python2/3 utf encoding shit calls needs some adjustments
fileName = os.path.join(
    os.path.abspath(os.path.dirname(__file__)),
    'README.md'
)

f = (open(fileName, 'r') if sys.version_info < (3, 0)
     else open(fileName, 'r', encoding='utf-8'))
longDescription = f.read()
f.close()

if '--generic' in sys.argv:
    marchFlag = '-march=x86-64'
    mtuneFlag = '-mtune=core2'
    sys.argv.remove("--generic")
else:
    marchFlag = '-march=native'
    mtuneFlag = '-mtune=native'

# define different compiler arguments for each platform
strPlatform = platform.system()
compilerArguments = []
linkerArguments = []
if strPlatform == 'Windows':
    # Microsoft Visual C++ Compiler 9.0
    compilerArguments += ['/O2', '/fp:precise', marchFlag]
elif strPlatform == 'Linux':
    # assuming Linux and gcc
    compilerArguments += ['-Ofast', marchFlag, mtuneFlag]
elif strPlatform == 'Darwin':
    # assuming Darwin and gcc
    compilerArguments += ['-Ofast', marchFlag, mtuneFlag]
else:
    WARNING("Your platform is currently not supported by %s: %s" % (<commit_msg>Update setup.py: Add generic warning<commit_after># -*- coding: utf-8 -*-
# Copyright 2016 <NAME>, <NAME>
#     https://www.tu-ilmenau.de/it-ems/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
'''Setup script for installation of fastmat package

  Usecases:
    - install fastmat package system-wide on your machine (needs su privileges)
        EXAMPLE:        'python setup.py install'

    - install fastmat package for your local user only (no privileges needed)
        EXAMPLE:        'python setup.py install --user'

    - compile all cython source files locally
        EXAMPLE:        'python setup.py build_ext --inplace'
'''

# import modules
import platform
import sys
import os
import re
import subprocess
from distutils import sysconfig

packageName     = 'fastmat'
packageVersion  = '0.1.2'           # provide a version tag as fallback
fullVersion     = packageVersion
strVersionFile  = "%s/version.py" %(packageName)

VERSION_PY = """
# -*- coding: utf-8 -*-
# This file carries the module's version information which will be updated
# during execution of the installation script, setup.py. Distribution tarballs
# contain a pre-generated copy of this file.

__version__ = '%s'
"""


def WARNING(string):
    print("\033[91m WARNING:\033[0m %s" % (string))


# load setup and extensions from setuptools. If that fails, try distutils
try:
    from setuptools import setup, Extension
except ImportError:
    WARNING("Could not import setuptools.")
    raise


# Determine package version
def getCurrentVersion():
    global packageVersion
    global fullVersion

    # check if there is a manual version override
    if os.path.isfile(".version"):
        with open(".version", "r") as f:
            stdout = f.read().split('\n')[0]
        print("Override of version string to '%s' (from .version file )" % (
            stdout))

        packageVersion = stdout

    else:
        # check if source directory is a git repository
        if not os.path.exists(".git"):
            print(("Installing from something other than a Git repository; " +
                   "Version file '%s' untouched.") % (strVersionFile))
            return

        # fetch current tag and commit description from git
        try:
            p = subprocess.Popen(
                ["git", "describe", "--tags", "--dirty", "--always"],
                stdout=subprocess.PIPE
            )
        except EnvironmentError:
            print("Not a git repository; Version file '%s' not touched." % (
                strVersionFile))
            return

        stdout = p.communicate()[0].strip()
        if stdout is not str:
            stdout = stdout.decode()

        if p.returncode != 0:
            print(("Unable to fetch version from git repository; " +
                   "leaving version file '%s' untouched.") % (strVersionFile))
            return

        # output results to version string, extract package version number
        # from git tag
        fullVersion = stdout
        versionMatch = re.match(r"[.+\d+]+\d*[abr]\d*", fullVersion)
        if versionMatch:
            packageVersion = versionMatch.group(0)
            print("Fetched package version number from git tag (%s)." % (
                packageVersion))


# get version from git and update fastmat/__init__.py accordingly
getCurrentVersion()

# make sure there exists a version.py file in the project
with open(strVersionFile, "w") as f:
    f.write(VERSION_PY % (fullVersion))
print("Set %s to '%s'" % (strVersionFile, fullVersion))


# Prepare other files and construct compile arguments

# get the long description from the README file.
# CAUTION: Python2/3 utf encoding shit calls needs some adjustments
fileName = os.path.join(
    os.path.abspath(os.path.dirname(__file__)),
    'README.md'
)

f = (open(fileName, 'r') if sys.version_info < (3, 0)
     else open(fileName, 'r', encoding='utf-8'))
longDescription = f.read()
f.close()

if '--generic' in sys.argv:
    marchFlag = '-march=x86-64'
    mtuneFlag = '-mtune=core2'
    sys.argv.remove("--generic")
    WARNING("Building package for generic architectures")
else:
    marchFlag = '-march=native'
    mtuneFlag = '-mtune=native'

# define different compiler arguments for each platform
strPlatform = platform.system()
compilerArguments = []
linkerArguments = []
if strPlatform == 'Windows':
    # Microsoft Visual C++ Compiler 9.0
    compilerArguments += ['/O2', '/fp:precise', marchFlag]
elif strPlatform == 'Linux':
    # assuming Linux and gcc
    compilerArguments += ['-Ofast', marchFlag, mtuneFlag]
elif strPlatform == 'Darwin':
    # assuming Darwin and gcc
    compilerArguments += ['-Ofast', marchFlag, mtuneFlag]
else:
    WARNING("Your platform is currently not supported by %s: %s" % (
{'fraction_non_alphanumeric': 0.1075785227163577, 'fraction_numerical': 0.0074920756891749115, 'mean_word_length': 2.852016278209397, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 2, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '430320', 'n_tokens_mistral': 2937, 'n_tokens_neox': 2818, 'n_words': 1051}