Use python3 by default in a formula #3773
Replies: 4 comments 6 replies
-
To be clear, do you only need to make sure that you can invoke Python3 as If so, declaring a dependency on one of the Python formulae should suffice. |
Beta Was this translation helpful? Give feedback.
-
Yes
Are you sure? On a fresh GitHub CI runner with brew and python 2 & 3 pre-installed, an explicit "brew install python3 python" results in "already installed" messages and python linked to python2. And the build failed. Is there some "sandbox" to test Homebrew formulae? To make sure it works in a Homebrew CI runner. Because all brew testing commands run on my Mac, using my python config, potentially not the same as the one in a Homebrew CI runner. I would not like to submit a PR resulting in a failing build in homebrew-core when the new version is ready and released everywhere else. |
Beta Was this translation helpful? Give feedback.
-
Using
I would expect a dependency on Isn't there a way to say "depends on Python3, the latest one, no need to accumulate some many different Python environments"? |
Beta Was this translation helpful? Give feedback.
-
I submitted that PR: Homebrew/homebrew-core#113051 This is a small standalone test, not a pre-release of the full project which takes time to build. Not to be merged of course, just to run the CI. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
This sounds like a recurrent topic but I couldn't find a nice way to solve it in the context of a formula. I do not even know if this is a problem in the context of a formula.
Consider a C++ tool with complex build scripts and an existing formula for previous versions. Python is now used during the build because some build scripts are now written in Python and I need to adapt the formula. Those scripts start with
#!/usr/bin/env python
. Note "python", not "python3". But Python3 is required. So, the commandpython
must be set topython3
by default.The scripts cannot be modified with
#!/usr/bin/env python3
because it won't work on Windows and some Linux distros. I needpython3
as default. Many Linux distros have clean ways to do this, either usingalternatives
or packages such aspython-is-python3
.What is the right way to do this in Homebrew, and specifically in the context of a formula?
On my Mac,
python
is linked topython3
in/usr/local/bin
but I suspect I did someln -s
years ago. On a fresh install, in amacos-latest
CI runner of GitHub for instance,brew install python3
leavespython
linked topython2
.How would I solve this in a Homebrew formula? Is it acceptable to force the
ln -sf python3 python
? How do you solve/usr/local
vs./opt/homebrew
in a portable way?Thanks
Beta Was this translation helpful? Give feedback.
All reactions