25 Commits

Author SHA1 Message Date
Mike McQuaid
07142a2a32 PythonHelper: move old_env outside begin block. 2013-09-14 12:21:49 +01:00
Mike McQuaid
315c7a1212 Rename PythonInstalled to PythonDependency.
Make it more consistent with other requirements.
2013-09-14 12:21:49 +01:00
Samuel John
59a0c1e1b5 Improve python tests for brew bots
Allow `build.with?` and similar methods to be used during the test
phase. The BuildOptions (`build`) are initialized with the
`Tab.used_options` unless explicitly overwritten on the command line.

So basically `build.with?` works in `def install` and in `test do` as
one would naively expect. (For the test, gramatically it should be
`built.with?` but who cares)

If a formula was installed `--with-python`, now the tests are also
run `--with-python`. This enables us to use the `python do ... end` in
a meaningful manner.

Using `python do ... end` blocks for the tests, because the bot.brew.sh has
system python per default and we need to set the PYTHONPATH for the test.
Potentially to different values for Python 2.x and 3.x.
2013-09-05 15:26:57 +02:00
Samuel John
dbaac79f17 PythonInstalled: Adding a private_site_packages
that live in the `libexec` dir of a `Cellar`.
2013-09-03 10:41:54 +02:00
Samuel John
0d75de42bb python_helper: Comment wording 2013-09-03 10:36:58 +02:00
Samuel John
ed461359a7 PythonInstalled: set PYTHONPATH, not prepend
An issue could arise when brewing a formula that
has Python 2.x and 3.x support and 2.x is the system Python
but 3.x is a brewed one. The idea about prepending was that
user configured PYTHONPATH could be used in formulae.
Now, instead and if needed, inside the `python do` block
one can still append to PYTHONPATH.
2013-08-27 16:34:31 +02:00
Jack Nagel
4a3dac82ef Use ENV.prepend_path 2013-08-19 17:21:13 -05:00
Amos Wenger
52ace99f14 Use File::PATH_SEPARATOR globally instead of ':'
On Unix, the path separator is ':', whereas on Windows,
it is ';'. This is the first of a series of patch to bring
macbrew's and winbrew's codebases closer together.

The main places the magic constant ':' was being used were:
  - the $PATH environment variable
  - CMAKE-related environment variables
  - pkg-config related environment variables

Closes Homebrew/homebrew#21921.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2013-08-19 13:35:44 -05:00
Jack Nagel
fb187e2132 Correct comment 2013-08-14 14:20:25 -05:00
Jack Nagel
c9a4e1e1c9 Use each instead of while loop 2013-08-14 14:13:03 -05:00
Jack Nagel
7ddc432c9e Replace long conditional with guard clauses 2013-08-14 14:13:03 -05:00
Samuel John
fe61524e03 python_helper prepends PYTHONPATH
…instead of appending. This should be safer against any
malformed user-defined values in the PYTHONPATH.
2013-08-08 11:48:16 +02:00
Samuel John
e143c3a799 Fix multiple execution of python do ... end blocks
Only run the `python do ... end` loop once even if
multiple `depends_on :python => 'module-name'` are
present.
2013-07-15 21:28:37 +02:00
Adam Vandenberg
53c97c3c96 Remove more nesting in python_helper 2013-07-02 10:21:45 -07:00
Adam Vandenberg
eafa7a141d Reduce nesting and remove extra whitespace in python_helper 2013-07-02 10:19:31 -07:00
Samuel John
a3a0146d7c Python module deps, ext. python fix and 10.6 fix
* Fixes Homebrew/homebrew#20572 by tweaking the logic that decides
  which python is used by the `python` object
  inside a formula. There was a bug when on 10.6
  there is no Python 2.7 but a :recommended
  Python was still treated as being available.

* Use the user's PATH when looking for an external
  Python. Until now only brewed or OS X system's
  python have been found by `depends_on :python`.

  But now we support any Python in PATH (e.g.
  pyenv's python).

* Further, instead of handling python modules
  and import tests in LanguageModuleDependency,
  these are now handled by:

        depends_on :python => 'numpy'  # for example

  The old style

        depends_on 'numpy' => :python

  is still supported and is only an alias
  for the newer style (only for :python, the
  other languages are not altered by this commit).

  The reasoning is that if a formula requires
  a python module, it basically also needs
  python itself - and further that specific
  version of python has to provide the module.
  So the `PythonInstalled` is the natural place
  to check for the availability of a python
  module.

  Using a python module and other tags like
  :optional or :recommended is done like so:

        depends_on :python => [:optional, 'numpy']

  Specifying another PyPi (Python Package index)
  name than the module import name is seldom used
  but supported, too:

         depends_on :python => ['enchant'=>'pyenchant']

  A last note: For clarity, you can define
  multiple depends_on statements with different
  modules to be importable.`
2013-06-18 10:30:17 +02:00
Samuel John
386373da40 python_helper.rb: Little comment improvement 2013-06-07 17:58:56 +02:00
Samuel John
515578723e depends_on :python don't set any LDFLAGS
Setting LDFLAGS to `-F HOMEBREW_PREFIX/opt/python/Frameworks`
breaks at least the scipy build. Perhaps others, too.
2013-06-06 14:24:15 +02:00
Samuel John
1c95045033 Hotfix: Revert Python module 2013-06-06 13:18:32 +02:00
Samuel John
4e8aa8637f PythonInstalled: Don't require superenv
* The python do ... end block does no longer
  require 'superenv' but saves and restores
  the ENV by using ENV.to_hash and `ensure`.
  This should resolve some build problems
  with formulae using `env :std`!
* `python_helper` is now in a module `Python`.
* Imporoved some comments in python_dependency.rb
2013-06-06 12:33:28 +02:00
Samuel John
a3a8bee5b9 depends_on :python sets PYTHONPATH internally
This applies only to non-brewed python:
The user will still have to set his PYTHONPATH
in order to import python modules in an
external python interpreter. However, a
warning will be displayed, now.

Further, during the build, the PYTHONPATH
will be set to Homebrew's global site-packages
so that software (like PyQt and others) that
need to `import sipconfig` in python can
find the brewed sip and its python module.
2013-06-05 17:37:32 +02:00
Samuel John
7aa2bcc3d5 Python add -F#{python.framework} for brewed Python
Since Python has been removed from superenv and
added as an explicit `depends_on :python`,
we should add
`-F#{HOMEBREW_PREFIX}/opt/python/Framewoks`
so that build tools that don't use
`python-config --ldflags` (as they should!)
can link against brewed Python.
2013-06-05 14:46:02 +02:00
Samuel John
441f7f4576 python_helper style bit 2013-06-04 22:07:15 +02:00
Samuel John
135eb31d6f Python is less verbose with "brew: Using python.."
Now it is only shown for an `python do ... end` block
and not for ordinary python.site_packages or other
methods.
2013-06-04 21:10:39 +02:00
Samuel John
c524895666 Python 2.x and 3.x support
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.
2013-06-03 17:29:43 +02:00