Skip to content
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

Change shebangs to specify python2 instead of system default #83

Closed
wants to merge 1 commit into from
Closed

Change shebangs to specify python2 instead of system default #83

wants to merge 1 commit into from

Conversation

Mitame
Copy link
Contributor

@Mitame Mitame commented Dec 3, 2015

This replaces all shebangs in the python scripts to use python2 instead of system default. This is because not all of the python scripts support running in python3. The new shebangs use #!/usr/bin/env python2

@Mitame Mitame changed the title Change hashbangs to specify python2 instead of system default Change shebangs to specify python2 instead of system default Dec 3, 2015
@harlanhaskins
Copy link
Contributor

OS X doesn't have a python2 binding by default.

It does have a python2.7

@Mitame
Copy link
Contributor Author

Mitame commented Dec 3, 2015

Really? That sounds very odd indeed... does env not account for that?

@harlanhaskins
Copy link
Contributor

harlan@nietzsche ~> /usr/bin/env python2
env: python2: No such file or directory
harlan@nietzsche ~> /usr/bin/env python2.6
Python 2.6.9 (unknown, Oct 23 2015, 18:17:02)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

@alexwlchan
Copy link
Contributor

Have you changed all the scripts, or just the ones which fail under Python 3?

I’d be happy to work on getting them to run cleanly on either version. :-)


I’m also getting “No such file or directory” when I run env python2.

@brks
Copy link

brks commented Dec 3, 2015

@harlanhaskins It does for me. python2

@Mitame
Copy link
Contributor Author

Mitame commented Dec 3, 2015

I changed the header for all those that just specified "python" and am building swift right now. ArchLinux defaults to python3 for python so it doesn't build correctly with the scripts unless you force python2. Basically, i replaced #!/usr/bin/python and #!/usr/bin/env python with #!/usr/bin/env python2.

@Mitame
Copy link
Contributor Author

Mitame commented Dec 3, 2015

For reference, this is the error you get if you try to run utils/build-script with python3:

emati@mita:~/git/swift/swift$ python3 utils/build-script
Traceback (most recent call last):
  File "utils/build-script", line 24, in <module>
    from SwiftBuildSupport import *
  File "/home/emati/git/swift/swift/utils/SwiftBuildSupport.py", line 15, in <module>
    import ConfigParser
ImportError: No module named 'ConfigParser'```

@alexwlchan
Copy link
Contributor

@Mitame Fix for that particular issue is in 5796230.

@nico
Copy link
Contributor

nico commented Dec 3, 2015

This will break things on OS X. #90 is a better fix that will also make things to on arch. This should be closed.

@Mitame
Copy link
Contributor Author

Mitame commented Dec 3, 2015

Yea, i was waiting for #90 to be accepted before closing this.

@cnd
Copy link

cnd commented Dec 25, 2015

cuurently with master

λ ./utils/update-checkout --clone                                                                                                                                                                     ~/H/swift/ ∅
Traceback (most recent call last):
  File "./utils/update-checkout", line 20, in <module>
    from SwiftBuildSupport import (
  File "/root/H/swift/utils/SwiftBuildSupport.py", line 135
    except ConfigParser.InterpolationMissingOptionError, e:
                                                       ^
SyntaxError: invalid syntax
λ python --version                                                                                                                                                                                    ~/H/swift/ ∅
Python 3.4.3

and same with ConfigParser

@gribozavr
Copy link
Contributor

@Heather Would you mind trying again? I just pushed 259fb78.

@cnd
Copy link

cnd commented Dec 25, 2015

@gribozavr there are still being a lot of missing stuff from #90

@gribozavr
Copy link
Contributor

@Heather I understand, but I can run python3 build-script successfully with that change. #90 includes many changes to scripts that are not on the critical path to building Swift.

@cnd
Copy link

cnd commented Dec 25, 2015

@gribozavr I don't know how your python3 is working

λ cd swift                                                                                                                                                                                                    ~/ Π
λ ./utils/update-checkout --clone                                                                                                                                                                       ~/swift/ Π
Traceback (most recent call last):
  File "./utils/update-checkout", line 125, in <module>
    sys.exit(main())
  File "./utils/update-checkout", line 98, in main
    obtain_additional_swift_sources()
  File "./utils/update-checkout", line 69, in obtain_additional_swift_sources
    for dir_name, repo in additional_repos.iteritems():
AttributeError: 'dict' object has no attribute 'iteritems'
λ                                                                                                                                                                                                       ~/swift/ ∅

@cnd
Copy link

cnd commented Dec 25, 2015

@gribozavr by the way there are other python files with similar issues... for now I just manually set them to python2. I can elaborate consistent patch for python3 compatibility but not sure if there is already work in progress by @alexwlchan or not

@gribozavr
Copy link
Contributor

@Heather I didn't catch it because I had all repositories checked out and that code wasn't executed. Pushed a fix e0479df.

@cnd
Copy link

cnd commented Dec 25, 2015

@gribozavr thanks but at least build scripts either should be updated...

@harlanhaskins
Copy link
Contributor

So, macOS Sierra doesn't have an alias for python2 in the default PATH either, so I'm going to close this until we find a better solution. I think we need to figure out a better solution for the python2/3 discrepancy here. In the meantime, if you have python3 as your system python, I'd recommend making a virtual environment such that python2 resolves as python:

pip install virtualenv
virtualenv .swift-environment -p $(which python2)
source .swift-environment/bin/activate

dabelknap pushed a commit to dabelknap/swift that referenced this pull request Aug 2, 2018
dabelknap pushed a commit to dabelknap/swift that referenced this pull request Sep 17, 2018
slavapestov pushed a commit to slavapestov/swift that referenced this pull request Nov 27, 2018
Adjust pass/fail criteria in dispatch_concur
maldahleh pushed a commit to maldahleh/swift that referenced this pull request Oct 26, 2020
…ic-rawsyntax-calls

[TokenSyntax] Use the token-specific RawSyntax functions for the TokenSyntax implementation, NFC
freak4pc pushed a commit to freak4pc/swift that referenced this pull request Sep 28, 2022
[run_cperf] Fix typo in anchor-making call.
DougGregor pushed a commit to DougGregor/swift that referenced this pull request Apr 28, 2024
motivation: cleanup

changes:
* better name for docker container
* group source moving together and sort them
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants