-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Conversation
In that other comment is a short demo: #16439 (comment) how the python block looks. I post this here because the diff in the PR is large. |
Regarding testing. It is fairly difficult to test things that are integrated with Formula due to the amount of things that are coupled to the filesystem. The best strategy is to push as much behavior as possible into external objects that can be tested in isolation. My suggestion would be to push the python code in formula.rb into a new class, and pass the formula object into it so you can still instance_eval stuff in the correct context, e.g. def python(*args, &block)
SomePythonThing.new(self, *args, &block)
end From there it is much easier to write tests without dragging the formula machinery into it. |
I am learning from the best. |
I looked at this a bit more and I see that what I suggested isn't an exact solution, because def some_python_thing
@some_python_thing ||= SomePythonThing.new
end
def python(*args, &block)
some_python_thing.call(*args, &block)
end so that the object is only constructed once. But the principle is still the same. BTW, if we're ever online at the same time we should hop on IRC and chat about the requirements API, I have some ideas I want to run by you. |
Should I still try out the steps you have outlined in #16439 or will it be better to wait until you have this ironed out? Just wanted to check before trying it out. |
@qrider70 you don't have to but I am thankful for feedback. I assume you know to to use git to pull and reset the original state of your homebrew - if not; don't pull this. What should work already is the (re-)installation of |
You have |
@MindTooth thanks for asking. I imagine the following:
It is disputable if depends_on should only allow "python2" and "python3". This allows us to write depends_on :python2
depends_on :python3
def install
python do
<stuff that should be done for 2.x and 3.x>
end
python2 do
<2.x specific handling here>
end
python3 do
<3.x specific handling here>
end
end |
Ok. I haven't used git to do that yet. I could learn. :) At this point, what you mention as working (python, python3, sip, and pyqt) is all that I need afaik. Is there a way to use what you have to get just that, or is it better that I just wait until you have this fully ready? I am flexible either way for now. Thanks for your work on this. :) |
Any news? |
soonish :-) |
Some formulae provide python bindings but don't need further work during the if python do
system 'cmake', *args # python environment set up
end
else
system 'cmake', *args # without python
end This is really the same as if python { system 'cmake', *args }
else
system 'cmake', *args
end where the latter makes it a bit more clear that python takes a block. |
This takes me so long, because I have to rework all python-using formulae a little bit ... |
Is there any progress in PySide for Python3? I would love to see it! Good work so far! :-) |
@freaky-m0 my changes in the core (on which I am working since days) raise the need to adapt each formula that uses python. That takes a bit of time. Therefore, I concentrate to first enable python 2.x support (that is the status-quo, but with my new system). Then I will push the changes, and after that, I will care to see which packages work with python3 (sometimes I have to rename executable scripts etc.) To answer your question, I have not yet added the I got working alraedy python3 bindings for numpy, pillow (PIL), PyQt, PyQwt, sip. But not yet pyside. |
So with these changes, when you get the error |
rebased on current master. For the guys who want to try out. |
I am almost done with this. I'll rebase and make the commits more beautiful and then push. Even if I succesfully built each and every of the above listed formulae on my Mac (successfully), I except some rough edges with other OS X versions and with system python in few cases. So I'll watch the tracker. Maintainers, please tag issues with "python". All: Please mention my name in Python related topics. Then, I will update the Wiki and the formulae in homebrew/science (and homebrew/versions etc). |
New `depends_on :python` Dependency. New `depends_on :python3` Dependency. To avoid having multiple formulae with endings -py2 and -py3, we will handle support for different pythons (2.x vs. 3.x) in the same formula. Further brewed vs. external python will be transparently supported. The formula also gets a new object `python`, which is false if no Python is available or the user has disabled it. Otherwise it is defined and provides several support methods: python.site_packages # the site-packages in the formula's Cellar python.global_site_packages python.binary # the full path to the python binary python.prefix python.version python.version.major python.version.minor python.xy # => e.g. "python2.7" python.incdir # includes of python python.libdir # the python dylib library python.pkg_config_path # used internally by brew python.from_osx? python.framework? python.universal? python.pypy? python.standard_caveats # Text to set PYTHONPATH for python.from_osx? python.if3then3 # => "" for 2.x and to "3" for 3.x. Further, to avoid code duplication, `python` takes an optional block that is run twice if the formula defines depends_on :python AND :python3. python do system python, 'setup.py', "--prefix=#{prefix}" end Read more in the Homebrew wiki.
Some build systems still set the DEVELOPER_DIR to /Developer and then nothing works any more (xcrun, xcodebuild etc.) I am looking at you MacVim.
Introduction
To avoid having multiple formulae with endings
-py2
and-py3
, we will handle support for different pythons (2.x vs. 3.x) in the same formula. Further brewed vs. external python will be transparently supported.New python Requirements:
Most formulae should just work with this little change.
The
python
object that will support formula devIn the Formula class there will be a
python
object available (python2
andpython3
, too), that supports some convenience methods which do the complicated work of figuring out the information no matter which python version or brewed vs. python from OS X:Instead of using
python
, there is alsopython2
andpython3
to explicitly refer to 2.x and 3.x resp..Executing code only for 2.x or 3.x
It is also possible to
The
python do ... end
blockAnd one of the most important features is the
python
-block which creates thepython.site_packages
dir and already sets thePYTHONPATH
correctly. This block is executes once for each python requirement.Formulae that use a
setup.py
to install python bindings, can doAre now all formulae automatically available for python 3.x?
No.
Adding Python 3.x support for individual formulae and testing that will take longer and I won't do this right now for all of the formulae. However, I did this for some to test things out.
Tasks:
depends_on :python
Requirement (python is a synonym for python2 here)depends_on :python3
Requirementsetup.py --prefix=#{prefix}
instead of the complicated stuff as is.pip
will install executable scripts toHOMEBREW_PREFIX
(solves a few issues)python.standard_caveats
python.global_site_packages
python.binary
to indirect the call to pythonwhich_python
bypython.xy
python do
blockpython2 do
block which is only run if a python 2.x has been found and unless--without-python
.python.incdir
(sometimes needed for cmake based projects)python.libdir
(sometimes needed for cmake based projects)python.version.major
andpython.version.minor
python.if3then3
which evaluates to "" for 2.x and to "3" for 3.x.python.framework
(isnil
for non-framework builds)python.universal?
python.pypy?
python.brewed?
python.from_osx?
brew create --python
?python -> python3
symlink, which is not recommended.Formulae in homebrew core to update accordingly (list created via grep for python):