130 Commits

Author SHA1 Message Date
Douglas Eichelberger
a81239ec2d
Enable strict typing in Formula 2025-02-24 10:23:42 -08:00
Michael Cho
c2d3f126ed
language/python: link manpages by default 2024-11-05 11:24:13 -05:00
Michael Cho
fdabc2fd03
language/python: reduce dependencies added to pth file 2024-10-29 23:22:16 -04:00
Mike McQuaid
d1e0c078bc
Merge pull request #18128 from cho-m/python-avoid-modifying-all-links 2024-08-23 08:07:45 +01:00
Michael Cho
36dc83c9e4
language/python: reduce some differences between macOS and Linux venv 2024-08-22 21:09:58 -04:00
Michael Cho
0e8db0155a
language/python: avoid modifying all Python symlinks
Homebrew Python will always have a realpath in HOMEBREW_CELLAR. Instead,
check if the symlink target points to HOMEBREW_CELLAR.
2024-08-22 19:19:19 -04:00
Bo Anderson
6db4ed2793
Replace some include Kernel usages with requires_ancestor 2024-08-20 19:10:14 +01:00
Mike McQuaid
debdc30aa0
language/*: only check required deps in detected_*_shebang
Otherwise, we rewrite this even when we have a e.g. build or test
dependency on NodeJS.

See context in:
https://github.com/Homebrew/homebrew-core/issues/176257#issuecomment-2277602215
2024-08-09 14:08:29 +01:00
William Woodruff
575592d7f9
Update Library/Homebrew/language/python.rb
Co-authored-by: Bo Anderson <mail@boanderson.me>
2024-07-30 11:38:07 -04:00
William Woodruff
9804e58ceb
python: don't assume resources have URLs
Signed-off-by: William Woodruff <william@yossarian.net>
2024-07-30 09:51:33 -04:00
William Woodruff
c6ba4844b3
specialize wheel resource handling
Signed-off-by: William Woodruff <william@yossarian.net>
2024-07-30 08:38:58 -04:00
Markus Reiter
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02:00
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Michael Cho
ecb7daba58
language/python: order args for virtualenv_install_with_resources
Add `without`, `start_with`, and `end_with` to allow basic control over
the order that resources are installed so that the situations where we
have to split up `virtualenv_install_with_resources` is reduced.

Co-authored-by: Kevin <apainintheneck@gmail.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-04-14 22:21:32 -04:00
Mike McQuaid
e600cc6fef
language/python: tweak Pathname syntax.
Co-authored-by: Markus Reiter <me@reitermark.us>
2024-04-01 08:09:42 +01:00
Michael Cho
7931b3cb12
language/python: enable typed: strict
Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-03-29 20:14:01 -04:00
Bo Anderson
28a80a6ebf
Avoid writable_real? 2024-03-27 06:26:32 +00:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Michael Cho
383d774ff7
language/python: add types
Also add `Virtualenv` getters to get `Pathname`s to
the virtualenv's `root` and `site_packages`.

Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-03-03 14:44:22 -05:00
Issy Long
f4218a6316
Fix RuboCop Performance/MapCompact offenses
- Rename an iterator variable since it would make the line too long.
2024-02-25 22:59:59 +00:00
Issy Long
f682147598
Fix RuboCop Style/RedundantFreeze offenses 2024-01-18 22:20:01 +00:00
Bo Anderson
5692c8ecbf
Fix style violations under newer RuboCop 2023-12-14 05:47:12 +00:00
Bo Anderson
b42256d286
Deprecate, disable & delete code for Homebrew 4.2.0 2023-12-07 23:42:13 +00:00
Elan Ruusamäe
132b763242
Fix python: detected_python_shebang python pattern
"python@" is not a valid dependency, must include something after the "@"
2023-09-06 01:38:58 +03:00
Sam Ford
0b3e3b7270
python: refactor to align Shebang modules
This reworks `Language::Python::Shebang` to use constants for
the shebang regex and max length (like the previous Node commit).
Besides that, this also adds type signatures to the existing methods.
2023-08-15 00:53:41 -04:00
Branch Vincent
98323cd7e6
python: create venv's --without-pip 2023-07-31 08:51:47 -07:00
Branch Vincent
9597f455aa
formula: add std_pip_args 2023-07-19 20:02:47 -07:00
Markus Reiter
a1efaf1864
Merge HeadVersion and NullVersion into Version. 2023-05-09 01:13:54 +02:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Douglas Eichelberger
d7d8f2cacb Revert language mixins back to module_function 2023-04-18 06:17:22 -07:00
Douglas Eichelberger
09c679e75f Refactor module_function to reduce rbi need 2023-04-17 10:37:59 -07:00
David Baumgold
a62543f304 forgot splat 2023-04-01 13:36:58 +02:00
David Baumgold
5f51e1549c unless 2023-04-01 12:36:58 +02:00
David Baumgold
38a2703aa7 Python: allow --no-build-isolation for pip install 2023-04-01 11:31:29 +02:00
Douglas Eichelberger
02fd0422aa Enable typing in a few more files 2023-03-09 13:42:06 -08:00
Branch Vincent
db6d3156f2
python: reinstate pip's --no-binary 2022-12-19 23:25:53 -08:00
Tom Forbes
2c378249aa Allow pip to use the local wheel cache while installing dependencies 2022-12-10 15:00:42 +00:00
Michael Cho
776d6b934d
language/python: optionally link manpages 2022-12-08 17:03:59 -08:00
Carlo Cabrera
98a53e4781
language/python: support python3 from PATH in #detected_python_shebang
Some formulae are flexible about the version of Python3 that they use.
However, when we use `#detected_python_shebang` on these formulae, they
become coupled to the specific version of Python3 declared in the
formula.

This is harmful because
1. it prevents us from using `uses_from_macos "python"` even in formulae
   where we should be able to
2. it forces us to rebuild the formula whenever we make changes to the
   Python dependency when nothing but the shebang would have changed as
   a consequence of the rebuild

For an example of this, see Homebrew/homebrew-core#107905.

I'd also like to do this to get rid of some really terrible hacks we
have in `glib-utils` as a means of decoupling `glib` from the specific
versioned Python dependency it used to have.

See Homebrew/homebrew-core#103916, or Homebrew/homebrew-core#106045 for
a proposal to give the same treatment to `gobject-introspection`.
2022-08-13 01:11:09 +08:00
Carlo Cabrera
ab4f1047fb
language/python: use versioned Python name in detected_python_shebang
Needed for Homebrew/homebrew-core#107517.
2022-08-09 22:36:39 +08:00
Carlo Cabrera
c9af8a632d
language/python: add --install-lib to setup_install_args
About 25 formula in homebrew/core pass `--install-lib` to `python3` in
addition to `*setup_install_args` in order to ensure that all files are
installed into the formula's prefix rather than into a `site-packages`
directory in Python's keg.

Let's simplify these formulae by also adding the appropriate
`--install-lib` flag to `setup_install_args`.
2022-07-09 22:22:10 +08:00
Bo Anderson
40bbdc659e
Fix some Style/FetchEnvVar offences 2022-06-17 19:47:57 +01:00
Carlo Cabrera
797c77761a
language/python: bug fix
Fixes a bug introduced in 09570fc7a66af8c43626a869888ebc484745c587.
2021-09-22 20:30:32 +08:00
Carlo Cabrera
09570fc7a6
language/python: allow formulae to restrict access to system site packages
Also, clean up one use of an `options` hash, because this is no longer
needed.

Closes #11885.
2021-09-21 13:21:26 +08:00
Carlo Cabrera
3d3b9874f9
language/python: create venvs with access to system site packages
A user may wish to use two use two brew-installed Python packages
together. For example, one might want to `import numpy` when using
`jupyterlab` or `ptpython`.

Currently, the only ways to do this I'm aware of is with some hacking of
`PYTHONPATH` or the creation of `.pth` files in a formula's prefix.

A better solution is to allow the virtualenvs that `brew` creates to
have access to system site-packages by default, so that `import numpy`
inside `ptpython` or `jupyterlab` just works.

Partially resolves Homebrew/homebrew-core#76950.
2021-06-28 03:20:03 +01:00
Bo Anderson
5f41016267
Support handling of rewriting shebangs with flags
Fixes #11108.
2021-05-10 06:13:58 +01:00
Bo Anderson
728bb547a7
language: raise ShebangDetectionError rather than a generic error 2021-05-10 05:50:08 +01:00
Rylan Polster
4c4dcfa3bb
language/python: remove outdated "homebrew-" resource handling 2021-03-14 14:17:02 -04:00
Dustin Rodrigues
c8e99e5185
python: stop passing no-user flag on installation 2021-02-19 12:49:10 -05:00