Push the stub buck.py script into a resource

Summary: Why we didn't do this in the first place escapes me.

Test Plan:
buck kill
ant clean
rm -rf buck-out
find . -name "*.pyc" | xargs rm
buck test --all
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 2952eda..845bada 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -20,6 +20,7 @@
       <entry name="?*.tld" />
       <entry name="?*.ftl" />
       <entry name="?*.soy" />
+      <entry name="*.py" />
     </wildcardResourcePatterns>
     <annotationProcessing>
       <profile default="true" name="Default" enabled="true">
@@ -33,5 +34,4 @@
       </profile>
     </annotationProcessing>
   </component>
-</project>
-
+</project>
\ No newline at end of file
diff --git a/build.xml b/build.xml
index a423cbc..298c5c0 100644
--- a/build.xml
+++ b/build.xml
@@ -10,7 +10,6 @@
   <property name="testrunner.classes.dir" value="${build.dir}/testrunner/classes" />
   <property name="bootstrapper.src.dir" value="com/facebook/buck/cli/bootstrapper/" />
   <property name="bootstrapper.classes.dir" value="${build.dir}/bootstrapper/classes" />
-  <property name="buck.path_to_buck_py" value="${basedir}/src/com/facebook/buck/parser/buck.py" />
   <property name="buck.path_to_compile_asset_catalogs_py" value="${basedir}/src/com/facebook/buck/apple/compile_asset_catalogs.py" />
   <property name="buck.path_to_compile_asset_catalogs_build_phase_sh" value="${basedir}/src/com/facebook/buck/apple/compile_asset_catalogs_build_phase.sh" />
   <property name="buck.path_to_sh_binary_template" value="${basedir}/src/com/facebook/buck/shell/sh_binary_template" />
@@ -365,6 +364,8 @@
         <src path="${immutables.gensrc.dir}" />
       </javac-params>
     </ecj>
+    <!-- Copy in scripts we need at run time when using an unpacked buck -->
+    <copy file="src/com/facebook/buck/json/buck.py" todir="${classes.dir}/com/facebook/buck/json"/>
 
     <!--
       Compile code from AOSP using the default compiler.
@@ -472,6 +473,7 @@
           depends="compile"
           description="build buck.jar"
           >
+
     <jar destfile="${build.dir}/buck.jar" update="true">
       <zipfileset refid="buck.jars" />
       <zipfileset refid="third-party.jars" />
@@ -588,7 +590,6 @@
            showoutput="true"
            forkmode="perBatch"
            haltonerror="on">
-      <sysproperty key="buck.path_to_buck_py" value="${buck.path_to_buck_py}" />
       <sysproperty key="buck.path_to_compile_asset_catalogs_py" value="${buck.path_to_compile_asset_catalogs_py}" />
       <sysproperty key="buck.path_to_compile_asset_catalogs_build_phase_sh" value="${buck.path_to_compile_asset_catalogs_build_phase_sh}" />
       <sysproperty key="buck.logging_config_file" value="${buck.test_logging_config_file}" />
@@ -620,7 +621,7 @@
   <target name="buck-py-test" description="tests the BUCK parser">
     <exec executable="python" failonerror="true">
       <env key="PYTHONPATH" path="${pathlib.dir}" />
-      <arg value="src/com/facebook/buck/parser/buck_test.py" />
+      <arg value="src/com/facebook/buck/json/buck_test.py" />
     </exec>
   </target>
 
diff --git a/programs/BUCK b/programs/BUCK
index 516355d..357f468 100644
--- a/programs/BUCK
+++ b/programs/BUCK
@@ -57,7 +57,6 @@
     'log4j_config_file': '//config:log4j.properties',
     'logging_config_file': '//config:logging.properties',
     'path_to_asm_jar': '//third-party/java/asm:asm',
-    'path_to_buck_py': '//src/com/facebook/buck/parser:buck.py',
     'path_to_compile_asset_catalogs_build_phase_sh': '//src/com/facebook/buck/apple:compile_asset_catalogs_build_phase.sh',
     'path_to_compile_asset_catalogs_py': '//src/com/facebook/buck/apple:compile_asset_catalogs.py',
     'path_to_intellij_py': '//src/com/facebook/buck/command:intellij.py',
diff --git a/programs/buck_tool.py b/programs/buck_tool.py
index af4ae3a..22f6cfa 100644
--- a/programs/buck_tool.py
+++ b/programs/buck_tool.py
@@ -45,7 +45,6 @@
     Resource("abi_processor_classes"),
     Resource("path_to_asm_jar"),
     Resource("logging_config_file"),
-    Resource("path_to_buck_py"),
     Resource("path_to_pathlib_py", basename='pathlib.py'),
     Resource("path_to_compile_asset_catalogs_py"),
     Resource("path_to_compile_asset_catalogs_build_phase_sh"),
diff --git a/src/com/facebook/buck/json/BUCK b/src/com/facebook/buck/json/BUCK
index 443d892..07382cd 100644
--- a/src/com/facebook/buck/json/BUCK
+++ b/src/com/facebook/buck/json/BUCK
@@ -18,6 +18,9 @@
 java_library(
   name = 'json',
   srcs = glob(['*.java'], excludes = RAW_PARSER_SRCS),
+  resources = [
+    "buck.py",
+  ],
   deps = [
     ':raw_parser',
     '//src/com/facebook/buck/event:event',
@@ -38,3 +41,25 @@
     'PUBLIC',
   ],
 )
+
+python_library(
+  name = 'buck',
+  srcs = [
+    'buck.py',
+  ],
+  deps = [
+    '//third-party/py/pathlib:pathlib',
+  ],
+)
+
+python_test(
+  name = 'buck_test',
+  srcs = [
+    'processor_test.py',
+    'buck_test.py',
+  ],
+  deps = [
+    ':buck',
+    '//third-party/py/pathlib:pathlib',
+  ],
+)
diff --git a/src/com/facebook/buck/json/ProjectBuildFileParser.java b/src/com/facebook/buck/json/ProjectBuildFileParser.java
index 4c33a63..03a84f0 100644
--- a/src/com/facebook/buck/json/ProjectBuildFileParser.java
+++ b/src/com/facebook/buck/json/ProjectBuildFileParser.java
@@ -37,7 +37,7 @@
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
-import com.google.common.io.CharStreams;
+import com.google.common.io.Resources;
 
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
@@ -49,6 +49,7 @@
 import java.io.OutputStreamWriter;
 import java.io.Reader;
 import java.io.Writer;
+import java.net.URL;
 import java.nio.channels.ClosedByInterruptException;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -66,8 +67,7 @@
 public class ProjectBuildFileParser implements AutoCloseable {
 
   /** Path to the buck.py script that is used to evaluate a build file. */
-  private static final String PATH_TO_BUCK_PY = System.getProperty("buck.path_to_buck_py",
-      "src/com/facebook/buck/parser/buck.py");
+  private static final String BUCK_PY_RESOURCE = "com/facebook/buck/json/buck.py";
 
   private static final Path PATH_TO_PATHLIB_PY = Paths.get(
       System.getProperty(
@@ -398,8 +398,8 @@
     Files.createDirectories(buckDotPy.getParent());
 
     try (Writer out = Files.newBufferedWriter(buckDotPy, UTF_8)) {
-      Path original = Paths.get(PATH_TO_BUCK_PY);
-      CharStreams.copy(Files.newBufferedReader(original, UTF_8), out);
+      URL resource = Resources.getResource(BUCK_PY_RESOURCE);
+      Resources.asCharSource(resource, UTF_8).copyTo(out);
       out.write("\n\n");
 
       ConstructorArgMarshaller inspector = new ConstructorArgMarshaller();
diff --git a/src/com/facebook/buck/parser/buck.py b/src/com/facebook/buck/json/buck.py
similarity index 100%
rename from src/com/facebook/buck/parser/buck.py
rename to src/com/facebook/buck/json/buck.py
diff --git a/src/com/facebook/buck/parser/buck_test.py b/src/com/facebook/buck/json/buck_test.py
similarity index 100%
rename from src/com/facebook/buck/parser/buck_test.py
rename to src/com/facebook/buck/json/buck_test.py
diff --git a/src/com/facebook/buck/parser/processor_test.py b/src/com/facebook/buck/json/processor_test.py
similarity index 100%
rename from src/com/facebook/buck/parser/processor_test.py
rename to src/com/facebook/buck/json/processor_test.py
diff --git a/src/com/facebook/buck/parser/BUCK b/src/com/facebook/buck/parser/BUCK
index e9c4e32..dfea274 100644
--- a/src/com/facebook/buck/parser/BUCK
+++ b/src/com/facebook/buck/parser/BUCK
@@ -74,31 +74,3 @@
   ],
 )
 
-python_library(
-  name = 'buck',
-  srcs = [
-    'buck.py',
-  ],
-  deps = [
-    '//third-party/py/pathlib:pathlib',
-  ]
-)
-
-python_test(
-  name = 'buck_test',
-  srcs = [
-    'processor_test.py',
-    'buck_test.py',
-  ],
-  deps = [
-    ':buck',
-    '//third-party/py/pathlib:pathlib',
-  ],
-)
-
-export_file(
-  name = 'buck.py',
-  visibility = [
-    'PUBLIC',
-  ],
-)