<commit_before>(ns leiningen.compile
  "Compile the namespaces listed in project.clj or all namespaces in src."
  (:require lancet)
  (:use [clojure.contrib.java-utils :only [file]]
        [clojure.contrib.find-namespaces :only [find-namespaces-in-dir]]
        [leiningen.deps :only [deps]])
  (:refer-clojure :exclude [compile])
  (:import org.apache.tools.ant.taskdefs.Java
           (org.apache.tools.ant.types Environment$Variable Path)))

(defn namespaces-to-compile
  "Returns a seq of the namespaces which need compiling."
  [project]
  (for [n (or (:namespaces project)
              (find-namespaces-in-dir (file (:source-path project))))
        :let [ns-file (str (-> (name n)
                               (.replaceAll "\\." "/")
                               (.replaceAll "-" "_")))]
        :when (> (.lastModified (file (:source-path project)
                                      (str ns-file ".clj")))
                 (.lastModified (file (:compile-path project)
                                      (str ns-file "__init.class"))))]
    n))

(defn find-lib-jars
  "Returns a seq of Files for all the jars in the project's library directory."
  [project]
  (filter #(.endsWith (.getName %) ".jar")
          (file-seq (file (:library-path project)))))

(def native-dir-names
     {"Mac OS X" "macosx"
      "Windows" "windows"
      "Linux" "linux"
      "SunOS" "solaris"
      "amd64" "x86_64"
      "x86_64" "x86_64"
      "x86" "x86"
      "i386" "x86"
      "arm" "arm"
      "sparc" "sparc"})

(defn get-native-dir-name
  [prop-value]
  (native-dir-names 
   (first (drop-while #(nil? (re-find (re-pattern %) prop-value))
		      (keys native-dir-names)))))

(defn find-native-lib-path
  "Returns a File representing the directory where native libs for the
  current platform are located."
  [project]
  (let [osdir (get-native-dir-name (System/getProperty "os.name"))
	archdir (get-native-dir-name (System/getProperty "os.arch"))
	sep (System/getProperty "file.separator")
	f (file (str "native" sep osdir sep archdir sep))]
    (if (.exists f)
      f
      nil)))

(defn make-path
  "Constructs an ant Path object from Files and strings."
  [& paths]
  (let [ant-path (Path. nil)]
    (doseq [path paths]
      (.addExisting ant-path (Path. nil (str path))))
    ant-path))

(defn eval-in-project
  "Executes form in an isolated classloader with the classpath and compile path
  set correctly for the project. Pass in a handler function to have it called
  with the java task right before executing if you need to customize any of its
  properties (classpath, library-path, etc)."
  [project form & [handler]]
  (let [java (Java.)]
    (.setProject java lancet/ant-project)
    (.addSysproperty java (doto (Environment$Variable.)
                            (.setKey "clojure.compile.path")
                            (.setValue (:compile-path project))))
    (when-let [path (or (:native-path project)
			(find-native-lib-path project))]
      (.addSysproperty java (doto (Environment$Variable.)
			    (.setKey "java.library.path")
			    (.setValue (cond 
					(= java.io.File (class path))
					(.getAbsolutePath path)
					(fn? path) (path)
					:default path)))))
    (.setClasspath java (apply make-path
                               (:source-path project)
                               (:test-path project)
                               (:compile-path project)
                               (:resources-path project)
                               (find-lib-jars project)))
    (.setClassname java "clojure.main")<commit_msg>made changes as suggested by technomancy<commit_after>(ns leiningen.compile
  "Compile the namespaces listed in project.clj or all namespaces in src."
  (:require lancet)
  (:use [clojure.contrib.java-utils :only [file]]
        [clojure.contrib.find-namespaces :only [find-namespaces-in-dir]]
        [leiningen.deps :only [deps]])
  (:refer-clojure :exclude [compile])
  (:import org.apache.tools.ant.taskdefs.Java
           (org.apache.tools.ant.types Environment$Variable Path)))

(defn namespaces-to-compile
  "Returns a seq of the namespaces which need compiling."
  [project]
  (for [n (or (:namespaces project)
              (find-namespaces-in-dir (file (:source-path project))))
        :let [ns-file (str (-> (name n)
                               (.replaceAll "\\." "/")
                               (.replaceAll "-" "_")))]
        :when (> (.lastModified (file (:source-path project)
                                      (str ns-file ".clj")))
                 (.lastModified (file (:compile-path project)
                                      (str ns-file "__init.class"))))]
    n))

(defn find-lib-jars
  "Returns a seq of Files for all the jars in the project's library directory."
  [project]
  (filter #(.endsWith (.getName %) ".jar")
          (file-seq (file (:library-path project)))))

(def native-dir-names
     {"Mac OS X" "macosx"
      "Windows" "windows"
      "Linux" "linux"
      "SunOS" "solaris"
      "amd64" "x86_64"
      "x86_64" "x86_64"
      "x86" "x86"
      "i386" "x86"
      "arm" "arm"
      "sparc" "sparc"})

(defn get-native-dir-name
  "Gets a value from the native-dir-names map, but uses a regex
  to check the prop-value for a match against keys instead of just
  doing a map lookup. Reason for this is that e.g. windows may
  report different names for different OS versions but will likely
  always contain the string 'Windows'"
  [prop-value]
  (native-dir-names
   (first (drop-while #(nil? (re-find (re-pattern %) prop-value))
                      (keys native-dir-names)))))

(defn find-native-lib-path
  "Returns a File representing the directory where native libs for the
  current platform are located."
  [project]
  (let [osdir (get-native-dir-name (System/getProperty "os.name"))
        archdir (get-native-dir-name (System/getProperty "os.arch"))
        f (file "native" osdir archdir)]
    (if (.exists f)
      f
      nil)))

(defn make-path
  "Constructs an ant Path object from Files and strings."
  [& paths]
  (let [ant-path (Path. nil)]
    (doseq [path paths]
      (.addExisting ant-path (Path. nil (str path))))
    ant-path))

(defn eval-in-project
  "Executes form in an isolated classloader with the classpath and compile path
  set correctly for the project. Pass in a handler function to have it called
  with the java task right before executing if you need to customize any of its
  properties (classpath, library-path, etc)."
  [project form & [handler]]
  (let [java (Java.)]
    (.setProject java lancet/ant-project)
    (.addSysproperty java (doto (Environment$Variable.)
                            (.setKey "clojure.compile.path")
                            (.setValue (:compile-path project))))
    (when-let [path (or (:native-path project)
                        (find-native-lib-path project))]
      (.addSysproperty java (doto (Environment$Variable.)
                              (.setKey "java.library.path")
                              (.setValue (cond
                                          (= java.io.File (class path))
                                          (.getAbsolutePath path)
                                          (fn? path) (path)
                                          :default path)))))
    (.setClasspath java (apply make-path
                               (:source-path project)
                               (:test-path project)
                               (:compile-path project)
                               (:resources-path project)
                               (find-lib-jars project)))
    (.setClassname java "clojure.main")
{'fraction_non_alphanumeric': 0.1280240617235517, 'fraction_numerical': 0.006015430887929907, 'mean_word_length': 2.0003923107100823, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '891761', 'n_tokens_mistral': 2365, 'n_tokens_neox': 2223, 'n_words': 677}