{"action":"opened","issue":{"url":"https://api.github.com/repos/pantsbuild/pants/issues/1658","labels_url":"https://api.github.com/repos/pantsbuild/pants/issues/1658/labels{/name}","comments_url":"https://api.github.com/repos/pantsbuild/pants/issues/1658/comments","events_url":"https://api.github.com/repos/pantsbuild/pants/issues/1658/events","html_url":"https://github.com/pantsbuild/pants/issues/1658","id":86777453,"number":1658,"title":"pants 0.0.32 cannot build/run python3 binaries","user":{"login":"jsirois","id":157586,"avatar_url":"https://avatars.githubusercontent.com/u/157586?v=3","gravatar_id":"","url":"https://api.github.com/users/jsirois","html_url":"https://github.com/jsirois","followers_url":"https://api.github.com/users/jsirois/followers","following_url":"https://api.github.com/users/jsirois/following{/other_user}","gists_url":"https://api.github.com/users/jsirois/gists{/gist_id}","starred_url":"https://api.github.com/users/jsirois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsirois/subscriptions","organizations_url":"https://api.github.com/users/jsirois/orgs","repos_url":"https://api.github.com/users/jsirois/repos","events_url":"https://api.github.com/users/jsirois/events{/privacy}","received_events_url":"https://api.github.com/users/jsirois/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-10T00:11:11Z","updated_at":"2015-06-10T00:11:11Z","closed_at":null,"body":"As initially reported by Grant here: https://groups.google.com/d/topic/pants-devel/dr_vUO_gG_4/discussion\r\n> On Tue, Jun 9, 2015 at 5:43 PM, Grant Wu <grantwu2@gmail.com> wrote:\r\n Hello!\r\n \r\n \r\n> Grant here. Member of a team of avid Pants-wearers. Running into an issue for which I've failed to  find a solution.\r\n \r\n> I have Python code that uses 'raise...from' syntax as outlined here. And here is a Gist containing  some test code I'm trying to run.\r\n \r\n> A file named \"test.py\" containing only the contents of the above Gist fails to run / bundle with Pants.  Error:\r\n \r\n> \"Exception message: invalid syntax (test.py, line 4)\"\r\n \r\n> The same test.py runs successfully when invoked with Python3.4.3, and gives the expected syntax error with Python2.\r\n \r\n> Here is my pants.ini. I'm specifying \"interpreter_requirement: CPython>=3.4,<3.5\".\r\n \r\n \r\n> I'm specifying a version of Python that should support 'raise...from', so I can't figure out why Pants is  giving me a syntax error. I'm wondering if there's something else I need to do to tell Pants which  version of Python I'm using. \r\n \r\n> Am I missing something? Thanks so much in advance for your help.\r\n \r\nI did a minimal repo like so:\r\n\r\n1. Setup a pants python repo:\r\n\r\n  ```console\r\n  jsirois@gill ~ $ mkdir /tmp/test\r\n  jsirois@gill ~ $ cd /tmp/test\r\n  jsirois@gill /tmp/test $ virtualenv -p python2 build-support/pants.venv\r\n  ...\r\n  jsirois@gill /tmp/test $ source build-support/pants.venv/bin/activate\r\n  (pants.venv)jsirois@gill /tmp/test $ pip install pantsbuild.pants\r\n  ...\r\n  (pants.venv)jsirois@gill /tmp/test $ cat << EOF > pants.ini\r\n  > [python-setup]\r\n  > interpreter_requirement: CPython>=3.4,<3.5\r\n  > EOF\r\n  ```\r\n2. Setup your case:\r\n\r\n  ```console\r\n  (pants.venv)jsirois@gill /tmp/test $ cat << EOF > main.py\r\n  > try:\r\n  >     print(1 / 0)\r\n  > except Exception as exc:\r\n  >     raise RuntimeError(\"Something bad happened\") from exc\r\n  > EOF\r\n  (pants.venv)jsirois@gill /tmp/test $ cat << EOF > BUILD\r\n  > python_binary(\r\n  >   name='main',\r\n  >   source='main.py'\r\n  > )\r\n  > EOF\r\n  ```\r\n3. Repro the run ... _not quite so fast_\r\n\r\n  ```console\r\n  (pants.venv)jsirois@gill /tmp/test $ pants run :main\r\n  ...\r\n  17:50:25 00:00   [resolve]\r\n  17:50:25 00:00     [ivy]\r\n                     Failed to resolve target for tool: //:nailgun-server.\r\n                     This target was obtained from option nailgun-server in scope resolve.ivy.\r\n                     You probably need to add this target to your tools BUILD file(s), usually located in the workspace root.\r\n                     \r\n  FAILURE\r\n  ...\r\n  ```\r\n  **URG** - tracked here: https://github.com/pantsbuild/pants/issues/940\r\n\r\n4. Add the nailgun tool dep:\r\n\r\n  ```console\r\n  (pants.venv)^jsirois@gill /tmp/test $ cat << EOF > BUILD.tools\r\n  > jar_library(\r\n  >   name='nailgun-server',\r\n  >   jars=[\r\n  >     jar('com.martiansoftware', 'nailgun-server', '0.9.1')\r\n  >   ]\r\n  > )\r\n  > EOF\r\n  ```\r\n5.) Really do the repro:\r\n\r\n  ```console\r\n  (pants.venv)jsirois@gill /tmp/test $ pants binary :main --print-exception-stacktrace\r\n  ...\r\n  17:52:22 00:00   [binary]\r\n  17:52:22 00:00     [python-binary-create]\r\n                     Detected interpreter /home/jsirois/.pyenv/versions/3.4.2/bin/python3.4: CPython-3.4.2\r\n                     Detected interpreter /usr/bin/python3.4: CPython-3.4.3fatal: Not a git repository (or any parent up to mount point /tmp)\r\n  Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).\r\n\r\n  17:52:23 00:01       [chroot]\r\n                 FAILURE\r\n\r\n  Exception caught:\r\n    File \"/tmp/test/build-support/pants.venv/bin/pants\", line 9, in <module>\r\n      load_entry_point('pantsbuild.pants==0.0.32', 'console_scripts', 'pants')()\r\n    File \"/tmp/test/build-support/pants.venv/lib/python2.7/site-packages/pants/bin/pants_exe.py\", line 81, in main\r\n      _run(exiter)\r\n    File \"/tmp/test/build-support/pants.venv/lib/python2.7/site-packages/pants/bin/pants_exe.py\", line 74, in _run\r\n      result = goal_runner.run()\r\n    File \"/tmp/test/build-support/pants.venv/lib/python2.7/site-packages/pants/bin/goal_runner.py\", line 174, in run\r\n      result = self._do_run()\r\n    File \"/tmp/test/build-support/pants.venv/lib/python2.7/site-packages/pants/bin/goal_runner.py\", line 230, in _do_run\r\n      return engine.execute(context, self.goals)\r\n    File \"/tmp/test/build-support/pants.venv/lib/python2.7/site-packages/pants/engine/engine.py\", line 26, in execute\r\n      self.attempt(context, goals)\r\n    File \"/tmp/test/build-support/pants.venv/lib/python2.7/site-packages/pants/engine/round_engine.py\", line 212, in attempt\r\n      goal_executor.attempt(explain)\r\n    File \"/tmp/test/build-support/pants.venv/lib/python2.7/site-packages/pants/engine/round_engine.py\", line 45, in attempt\r\n      task.execute()\r\n    File \"/tmp/test/build-support/pants.venv/lib/python2.7/site-packages/pants/backend/python/tasks/python_binary_create.py\", line 38, in execute\r\n      self.create_binary(binary)\r\n    File \"/tmp/test/build-support/pants.venv/lib/python2.7/site-packages/pants/backend/python/tasks/python_binary_create.py\", line 51, in create_binary\r\n      with self.temporary_chroot(interpreter=interpreter, pex_info=pexinfo, targets=[binary], platforms=binary.platforms) as chroot:\r\n    File \"/usr/lib64/python2.7/contextlib.py\", line 17, in __enter__\r\n      return self.gen.next()\r\n    File \"/tmp/test/build-support/pants.venv/lib/python2.7/site-packages/pants/backend/python/tasks/python_task.py\", line 104, in temporary_chroot\r\n      chroot.dump()\r\n    File \"/tmp/test/build-support/pants.venv/lib/python2.7/site-packages/pants/backend/python/python_chroot.py\", line 178, in dump\r\n      self._dump_library(lib)\r\n    File \"/tmp/test/build-support/pants.venv/lib/python2.7/site-packages/pants/backend/python/python_chroot.py\", line 112, in _dump_library\r\n      copy_to_chroot(library.target_base, relpath, self._builder.add_source)\r\n    File \"/tmp/test/build-support/pants.venv/lib/python2.7/site-packages/pants/backend/python/python_chroot.py\", line 107, in copy_to_chroot\r\n      add_function(src, path)\r\n    File \"/tmp/test/build-support/pants.venv/lib/python2.7/site-packages/pex/pex_builder.py\", line 136, in add_source\r\n      pyc_object = CodeMarshaller.from_py(fp.read(), env_filename)\r\n    File \"/tmp/test/build-support/pants.venv/lib/python2.7/site-packages/pex/marshaller.py\", line 70, in from_py\r\n      code = compile(py.replace('\\r\\n', '\\n').replace('\\r', '\\n'), filename, 'exec')\r\n\r\n  Exception message: invalid syntax (main.py, line 4)\r\n  ```"}}