{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/30831455","id":30831455,"diff_hunk":"@@ -693,23 +701,71 @@ def clearFiles(self):\n         Clear the job's list of files added by L{addFile} or L{addPyFile} so\n         that they do not get downloaded to any new nodes.\n         \"\"\"\n-        # TODO: remove added .py or .zip files from the PYTHONPATH?\n+        # TODO: remove added .py, .whl, .egg or .zip files from the PYTHONPATH?\n         self._jsc.sc().clearFiles()\n \n     def addPyFile(self, path):\n         \"\"\"\n-        Add a .py or .zip dependency for all tasks to be executed on this\n-        SparkContext in the future.  The C{path} passed can be either a local\n-        file, a file in HDFS (or other Hadoop-supported filesystems), or an\n-        HTTP, HTTPS or FTP URI.\n+        Add a .py, .whl, .egg or .zip dependency for all tasks to be\n+        executed on this SparkContext in the future.  The C{path} passed can\n+        be either a local file, a file in HDFS (or other Hadoop-supported\n+        filesystems), or an HTTP, HTTPS or FTP URI.\n         \"\"\"\n         self.addFile(path)\n-        (dirname, filename) = os.path.split(path)  # dirname may be directory or HDFS/S3 prefix\n+        self._include_python_packages(paths=(path,))\n+        self._install_wheel_files(paths=(path,))\n \n-        if filename[-4:].lower() in self.PACKAGE_EXTENSIONS:\n-            self._python_includes.append(filename)\n-            # for tests in local mode\n-            sys.path.insert(1, os.path.join(SparkFiles.getRootDirectory(), filename))\n+    def _include_python_packages(self, paths):\n+        \"\"\"\n+        Add Python package dependencies. Python packages (except for .whl) are\n+        added to PYTHONPATH.\n+        \"\"\"\n+        root_dir = SparkFiles.getRootDirectory()\n+        for path in paths:\n+            basename = os.path.basename(path)\n+            extname = os.path.splitext(basename)[1].lower()\n+            if extname in self.PACKAGE_EXTENSIONS \\\n+                    and basename not in self._python_includes:\n+                self._python_includes.append(basename)\n+                if extname != '.whl':\n+                    # Prepend the python package (except for *.whl) to sys.path\n+                    sys.path.insert(1, os.path.join(root_dir, basename))\n+\n+    def _install_wheel_files(\n+        self,","path":"python/pyspark/context.py","position":113,"original_position":113,"commit_id":"369e96c4bd0cddd43efa6d19b5fff72216741498","original_commit_id":"369e96c4bd0cddd43efa6d19b5fff72216741498","user":{"login":"davies","id":40902,"avatar_url":"https://avatars.githubusercontent.com/u/40902?v=3","gravatar_id":"","url":"https://api.github.com/users/davies","html_url":"https://github.com/davies","followers_url":"https://api.github.com/users/davies/followers","following_url":"https://api.github.com/users/davies/following{/other_user}","gists_url":"https://api.github.com/users/davies/gists{/gist_id}","starred_url":"https://api.github.com/users/davies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davies/subscriptions","organizations_url":"https://api.github.com/users/davies/orgs","repos_url":"https://api.github.com/users/davies/repos","events_url":"https://api.github.com/users/davies/events{/privacy}","received_events_url":"https://api.github.com/users/davies/received_events","type":"User","site_admin":false},"body":"Could you change this to match the style with others?","created_at":"2015-05-21T18:23:02Z","updated_at":"2015-05-21T18:23:02Z","html_url":"https://github.com/apache/spark/pull/5408#discussion_r30831455","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/5408","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/30831455"},"html":{"href":"https://github.com/apache/spark/pull/5408#discussion_r30831455"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/5408"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/5408","id":32830157,"html_url":"https://github.com/apache/spark/pull/5408","diff_url":"https://github.com/apache/spark/pull/5408.diff","patch_url":"https://github.com/apache/spark/pull/5408.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/5408","number":5408,"state":"open","locked":false,"title":"[SPARK-6764] Add wheel package support for PySpark","user":{"login":"takaomag","id":234209,"avatar_url":"https://avatars.githubusercontent.com/u/234209?v=3","gravatar_id":"","url":"https://api.github.com/users/takaomag","html_url":"https://github.com/takaomag","followers_url":"https://api.github.com/users/takaomag/followers","following_url":"https://api.github.com/users/takaomag/following{/other_user}","gists_url":"https://api.github.com/users/takaomag/gists{/gist_id}","starred_url":"https://api.github.com/users/takaomag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/takaomag/subscriptions","organizations_url":"https://api.github.com/users/takaomag/orgs","repos_url":"https://api.github.com/users/takaomag/repos","events_url":"https://api.github.com/users/takaomag/events{/privacy}","received_events_url":"https://api.github.com/users/takaomag/received_events","type":"User","site_admin":false},"body":"Support wheel packaging for PySpark.\r\n","created_at":"2015-04-08T05:45:32Z","updated_at":"2015-05-21T18:23:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f5085bdeeb4ec6a7ef2dcea1ca0334ed1c85719d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/5408/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/5408/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/5408/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/369e96c4bd0cddd43efa6d19b5fff72216741498","head":{"label":"takaomag:spike_pyspark-wheel-support","ref":"spike_pyspark-wheel-support","sha":"369e96c4bd0cddd43efa6d19b5fff72216741498","user":{"login":"takaomag","id":234209,"avatar_url":"https://avatars.githubusercontent.com/u/234209?v=3","gravatar_id":"","url":"https://api.github.com/users/takaomag","html_url":"https://github.com/takaomag","followers_url":"https://api.github.com/users/takaomag/followers","following_url":"https://api.github.com/users/takaomag/following{/other_user}","gists_url":"https://api.github.com/users/takaomag/gists{/gist_id}","starred_url":"https://api.github.com/users/takaomag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/takaomag/subscriptions","organizations_url":"https://api.github.com/users/takaomag/orgs","repos_url":"https://api.github.com/users/takaomag/repos","events_url":"https://api.github.com/users/takaomag/events{/privacy}","received_events_url":"https://api.github.com/users/takaomag/received_events","type":"User","site_admin":false},"repo":{"id":33399378,"name":"spark","full_name":"takaomag/spark","owner":{"login":"takaomag","id":234209,"avatar_url":"https://avatars.githubusercontent.com/u/234209?v=3","gravatar_id":"","url":"https://api.github.com/users/takaomag","html_url":"https://github.com/takaomag","followers_url":"https://api.github.com/users/takaomag/followers","following_url":"https://api.github.com/users/takaomag/following{/other_user}","gists_url":"https://api.github.com/users/takaomag/gists{/gist_id}","starred_url":"https://api.github.com/users/takaomag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/takaomag/subscriptions","organizations_url":"https://api.github.com/users/takaomag/orgs","repos_url":"https://api.github.com/users/takaomag/repos","events_url":"https://api.github.com/users/takaomag/events{/privacy}","received_events_url":"https://api.github.com/users/takaomag/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/takaomag/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/takaomag/spark","forks_url":"https://api.github.com/repos/takaomag/spark/forks","keys_url":"https://api.github.com/repos/takaomag/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/takaomag/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/takaomag/spark/teams","hooks_url":"https://api.github.com/repos/takaomag/spark/hooks","issue_events_url":"https://api.github.com/repos/takaomag/spark/issues/events{/number}","events_url":"https://api.github.com/repos/takaomag/spark/events","assignees_url":"https://api.github.com/repos/takaomag/spark/assignees{/user}","branches_url":"https://api.github.com/repos/takaomag/spark/branches{/branch}","tags_url":"https://api.github.com/repos/takaomag/spark/tags","blobs_url":"https://api.github.com/repos/takaomag/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/takaomag/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/takaomag/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/takaomag/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/takaomag/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/takaomag/spark/languages","stargazers_url":"https://api.github.com/repos/takaomag/spark/stargazers","contributors_url":"https://api.github.com/repos/takaomag/spark/contributors","subscribers_url":"https://api.github.com/repos/takaomag/spark/subscribers","subscription_url":"https://api.github.com/repos/takaomag/spark/subscription","commits_url":"https://api.github.com/repos/takaomag/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/takaomag/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/takaomag/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/takaomag/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/takaomag/spark/contents/{+path}","compare_url":"https://api.github.com/repos/takaomag/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/takaomag/spark/merges","archive_url":"https://api.github.com/repos/takaomag/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/takaomag/spark/downloads","issues_url":"https://api.github.com/repos/takaomag/spark/issues{/number}","pulls_url":"https://api.github.com/repos/takaomag/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/takaomag/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/takaomag/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/takaomag/spark/labels{/name}","releases_url":"https://api.github.com/repos/takaomag/spark/releases{/id}","created_at":"2015-04-04T08:38:42Z","updated_at":"2015-04-08T04:53:41Z","pushed_at":"2015-04-08T05:33:41Z","git_url":"git://github.com/takaomag/spark.git","ssh_url":"git@github.com:takaomag/spark.git","clone_url":"https://github.com/takaomag/spark.git","svn_url":"https://github.com/takaomag/spark","homepage":null,"size":99257,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"8d2a36c0fdfbea9f58271ef6aeb89bb79b22cf62","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","created_at":"2014-02-25T08:00:08Z","updated_at":"2015-05-21T11:33:07Z","pushed_at":"2015-05-21T18:22:10Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":1686077,"stargazers_count":4046,"watchers_count":4046,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3558,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":310,"forks":3558,"open_issues":310,"watchers":4046,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/5408"},"html":{"href":"https://github.com/apache/spark/pull/5408"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/5408"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/5408/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/5408/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/5408/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/369e96c4bd0cddd43efa6d19b5fff72216741498"}}}}