Commit Graph
49 Commits
Author SHA1 Message Date
Mike McQuaid 07786ed383 python_dependency: only set PYTHONPATH for system. 2014-02-10 18:49:26 +00:00
Mike McQuaid 9ead3a1b08 python_dependency: cleanup and fix build env.
* Only set PYTHONPATH for Python 2.
* Set the Python binary for superenv.

References #24842.
Closes #26197.
Closes #26216.
Closes #26218.
Closes #26228.
2014-01-29 17:49:57 +01:00
Mike McQuaid fc518378ab python_dependency: cleanup, fix satisfy.
Closes #26067.
2014-01-20 23:30:32 -08:00
Mike McQuaid b3f4929f9d PythonDependency: massive refactoring.
Closes #24842.
2014-01-20 15:42:52 -08:00
Mike McQuaid 3c86d2b8ff Update docs, comment mxcl/homebrew refs. 2013-12-14 18:18:35 +00:00
MinRK 34304bfef4 safer check for sys.executable in sitecustomize.py
make sure it doesn't actually point to something else

since sitecustomize.py is put in a location found by pypy,
it breaks pypy by setting sys.executable to a path that is definitely wrong,
and may not even exist.

Closes #24581.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2013-11-25 20:48:41 -08:00
Jack Nagel 256a8aae55 Python might not be up-to-date, so use opt_prefix
Fixes #24456.
2013-11-18 17:08:04 -06:00
Adam Vandenberg c496c93e3a grammar edits 2013-11-13 20:23:27 -08:00
Mike McQuaid dcd2907ee2 python_dependency: fix includes location on 10.9.
Fixes #23837.
Fixes #23866.
2013-11-01 11:19:23 -07:00
Jack Nagel facc83091b Avoid the need to defensively flatten tags array 2013-10-15 13:26:23 -05:00
Mike McQuaid 0675ba2946 Rename PythonInstalled to PythonDependency.
Make it more consistent with other requirements.
2013-09-14 12:21:49 +01:00
Samuel John d2fea17e17 PythonInstalled: Allow formulae to set/append PYTHONPATH
Improve robustness of `PYTHONPATH` by first unsetting it (during
`satisfy`) so that the `PythonInstalled` can get the `python.version`
and so forth and then, after that, setting the `PYTHONPATH` to our
`global_site_packages`.
In the `python_helper` we append to the `PYTHONPATH` so if that var has
been set in a formula, it is respected.
Brew audit does no longer complain about setting the
`ENV['PYTHONPATH']`.
2013-09-03 10:46:06 +02:00
Samuel John 9f7c616c1c 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 08cd419b03 PythonInstalled, name includes modules
If `depends_on :python => ['modulename', :optional]` then the generated
option is now `--with-python-modulename`, so that it is possible to
actually make depending on python modules optional.
Further, `brew options` becomes more meaningful.
2013-08-27 09:48:12 +02:00
Samuel John 6596db2bd9 PythonInstalled: Unset PYTHONPATH for satisfied?
When a formula `depends_on :python` *and* `depends_on :python3`
the `modify_build_environment` method sets the PYTHONPATH
and the Python 3.x requirement then fails because it finds
the sitecustomize.py from Python 2.x in the PYTHONPATH.
2013-08-23 20:26:47 +02:00
Jack Nagel d911acbde2 Use ENV.prepend_path 2013-08-19 17:21:13 -05:00
Jack Nagel 79e06fc9ea Use ENV.append_path 2013-08-19 17:21:13 -05:00
Jack Nagel 042e84cc64 which in requirements always uses ORIGINAL_PATHS now
Fixes #22002.
2013-08-19 13:54:09 -05:00
Amos Wenger 13c2776795 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 #21921.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2013-08-19 13:35:44 -05:00
Samuel John 0b269c3af7 Unlinked brewed python -> use system python
Up to now a brewed Python, even if not linked, was preferred over
and external Python, so that you had to completely `brew rm python`
to have a formula link against external (mostly system) Python.

From now on it is okay to `brew unlink python`.
2013-08-15 02:03:55 +02:00
Jack Nagel e1695f0e67 Iterate over these directly rather than mapping first 2013-08-14 13:02:50 -05:00
Jack Nagel b6bb9f6a33 Return value of modify_build_environment is unimportant 2013-08-14 13:01:35 -05:00
Jack Nagel 8dcc870e81 Reverse conditional 2013-08-14 12:46:37 -05:00
Jack Nagel 279a077c6c Collapse to one-liner 2013-08-14 12:46:12 -05:00
Jack Nagel ef00a3f3de No need to map, all? takes a block 2013-08-14 12:45:54 -05:00
Jack Nagel 4ff80b4b22 Add missing false 2013-08-14 12:41:52 -05:00
Jack Nagel 792f7aed04 Remove stray space 2013-08-14 12:41:15 -05:00
Jack Nagel 8508bdf985 Allow specifying a custom PATH for which method
Closes #21794.
2013-08-10 19:01:50 -05:00
Samuel John 36ad1d552b Python: Exit if PYTHONPATH is wrong
In our sitecustomize.py we instruct python to exit with an error message
if the PYTHONPATH is pointing to a wrong homebrew site-packages dir.
With wrong meaning another major python version.

If you set the PYTHONPATH to include
    $(brew --prefix)/lib/python2.7/site-packages
and start python3, it may pick up modules from there, wich can result
in errors for non pure python modules (such as PyQt).
2013-08-08 11:54:42 +02:00
Samuel John b024703426 For brewed python, make sure to unset the PYTHONPATH
during building of python software inside of a `python do … end` block.
2013-08-08 11:50:46 +02:00
Adam Vandenberg 90ccfc36e6 Remove ARCHFLAGS fixme from Python dependency
This will be handled by env/superenv, not Python.
2013-08-03 10:28:57 -07:00
Jack Nagel cc5ad63609 Silence warnings 2013-07-22 11:41:47 -05:00
Jack Nagel 90ec8297d3 Fix python dependency hash equality
eql? should not depend on the hash value as hash values of uneql objects
can collide, but eql values may only collide for objects that are
actually eql.

Further, python dependencies are uniquely identified by the combination
of the name and imports attributes, so there is no reason to involved
the expensive binary computation for simple equality checks.

Fixes #20840.
2013-07-22 11:41:46 -05:00
Jack Nagel 0b77b3a134 Remove redundant reader method 2013-07-22 11:41:46 -05:00
Samuel John 3edd010021 Typo in comments 2013-07-17 09:52:30 +02:00
Samuel John 606749c0de Allow specifying version in depends_on :python
Note, in the explict form:

    PythonInstalled.new('2.7') => :recommended

the tag :recommended is ignored (not a limitation
of PythonInstalled itself). One solution was to write

    PythonInstalled.new('2.7', [:recommended])

but that is not as beautiful as we like it.

Therefore, now it is possible to:

    depends_on :python => ['2.7', :recommended]

Only the first tag is attempted to be parsed as
a version specifyer "x" or "x.y" or "x.y.z"...
2013-07-16 11:04:57 +02:00
Jack Nagel ba90af7946 Use old #eql? for python reqs, for now 2013-06-27 01:43:30 -05:00
Samuel John e00f1a998e depends_on :python => 'module' allow user packages
Some prefer to install with `--user` into their
home. For example to avoid `sudo` with system's
python. Now Homebrew can use those modules to
satisfy a python dependency on a certain module.
2013-06-19 12:18:48 +02:00
Samuel John 2c8c8d07f6 Python module deps, ext. python fix and 10.6 fix
* Fixes #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
Jack Nagel c947c674ab Remove Version#to_a alias
Exposing this as "to_a" was a mistake, versions are not arrays and it
causes incorrect behavior when splatted or using Kernel#Array(). Use the
more correct name "tokens" instead.
2013-06-14 18:37:27 -05:00
Samuel John 9c8ee2d757 PythonInstalled: Fix libdir for Python 3.x 2013-06-09 20:37:30 +02:00
Samuel John fe896570a6 Python: Don't print warning about PYTHONPATH
Authors should use `python.standard_caveats` instead.

* Accessor for python.binary
* Made `python.brewed?` more robust if no python found at all
* python.brewed? is more relaxed now and allows older versions
  of the Python formula.
* Only print about wrining sitecustomize.py and distutils.cfg if
verbose and debug.
2013-06-07 17:58:56 +02:00
Samuel John 432545f258 Hotfix: Revert Python module 2013-06-06 13:18:32 +02:00
Samuel John 02ddd442f2 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 aab704358b 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 306a89ca3b 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 af4a66b0cf Python: Don't use named tuples to get the version
sys.version_info.major is only possible on 2.7+ or so.
Therefore, we now use [0] instead.
2013-06-04 17:14:15 +02:00
Samuel John bac0d416e7 depends_on :python Default to min vers 2.6 not 2.7
To support system python on OS X
2013-06-03 21:18:05 +02:00
Samuel John 0b50110107 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