-
Notifications
You must be signed in to change notification settings - Fork 694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docker_pull fails on syntax error #57
Comments
Try |
This is a known problem with ArchLinux: https://www.python.org/dev/peps/pep-0394/ "... however, end users should be aware that python refers to python3 on at least Arch Linux (that change is what prompted the creation of this PEP), so python should be used in the shebang line only for scripts that are source compatible with both Python 2 and 3." But making the code also work under Python3 would be a laudable goal. |
Hi, thanks for the suggestions. I will try again tonight, with and without a virtualenv to try and make it work. I had another problem related to Python 3 when using pkg_tar and somehow I managed to make it work by using a virtualenv, but when I first tried it it didn't work..not sure why. Anyway I'll do more experimenting and let you know |
I did some more testing and I can't make it work. Tried with Running with a virtualenv doesn't work either. Looking at the output of
it runs with Anyway, for now I've been unable to find a good solution/ |
Oh I just realized the failure is in docker_pull. @mattmoor: maybe we should make sure that puller is compatible with python 2 or test the python on the path in docker_pull... |
The puller is certainly python 2 compatible. From the stack trace it seems it isn't python 3 compatible. Given where it's exploding that makes sense because I specifically import the python 2 version of @steren @damienmg @duggelz Do we have any reasonable documentation for how to ensure a Bazel project is python 2 and 3 compliant? I know we have some flags internally, but I'm not sure what's publicly available here, or what the level of support is in the toolchain (including subpar). |
It's hard to do something non-hacky when Subpar works under Python 2 and 3, which I test via BUILD files like this: [py_test(
name = "%s_%s_test" % (src_name, version),
size = "small",
srcs = [src_name + "_test.py"],
default_python_version = version,
main = src_name + "_test.py",
srcs_version = "PY2AND3",
deps = [
":compiler_lib",
":test_utils",
],
) for src_name in [
"cli",
"manifest_parser",
"python_archive",
"stored_resource",
] for version in [
"PY2",
"PY3",
]] As a stop-gap, you could add |
Does ArchLinux even have Python 2 installed? We could try something hacky in the puller like re-execing itself under |
yes, it's under |
I just ran into this problem. If you want to go down the hacky re- #!/usr/bin/python
import os
import sys
import distutils.spawn
if sys.version_info[0] > 2:
py2 = distutils.spawn.find_executable('python2')
if py2 is None:
sys.exit('Not compatible with Python 3')
print('Re-executing as python 2')
os.execl(py2, py2, *sys.argv)
print("Hello world") |
Bazel in version 0.53 broke essentially all Python 3 usage. I'm still not sure why they thought that was ok. So the example I have above for subpar doesn't work at all any more. I don't have a good answer, but "write code that works under Python 2 and 3" seems like the best option at present. Also, we might look into the 'requests' library as a generally superior alternative to 'httplib2' that works on both Python 2 and 3. |
@damienmg Are you aware of this? |
See bazelbuild/bazel#3517 for Python 2/3 issues with 0.53 |
I stumbled on this bug right now. a quick fix is to set the export BAZEL_PYTHON=$HOME/miniconda2/bin/python2.7 |
Yeah, this workaround was probably made possible by this recent PR. You should now be able to alias I don't think passing |
Trying to make this code work under Python 2/3, and ran into the problem that Bazel itself has code that doesn't work under Python 3: bazelbuild/bazel#3816 |
Running on bazel@master I am able to get past this, however bazel then fails with
Setting |
@hwright has been fixing all of our Python3 problems, this looks like one he just fixed, which hasn't merged yet because Bazel broke all our CI with 0.8 :( |
@tanner-bruce #255 should resolve that specific issue, but if you find more, please let us know. |
is this still an issue? please reopen if so. |
Hi,
I'm using ArchLinux and I get an error when adding that to my workspace:
the error is:
By default Arch uses Python 3, looks like this is the problem ?
Is there a way to tell bazel to use python 2 ? I tried to run bazel with
--python2_path=/usr/bin/python2
when it doesn't work.The text was updated successfully, but these errors were encountered: