110 Commits

Author SHA1 Message Date
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
Dustin Rodrigues
425535e32b python: add --no-user when doing pip install 2021-01-09 10:09:44 -05:00
Dustin Rodrigues
19a47d7c50 python: use built-in venv instead of virtualenv when installing formulae 2021-01-09 10:09:44 -05:00
Rylan Polster
7f260f92b9 language/python: update homebrew-virtualenv resource 2020-12-12 14:24:58 -05:00
Francois-Xavier Coudert
0670ec4d09 python: update virtualenv 2020-12-02 09:54:18 +01:00
Dustin Rodrigues
84de3c1eb6 python: allow multi-digit minor versions 2020-11-22 10:45:06 -05:00
Markus Reiter
0184e271d8 Fix RuboCop offenses. 2020-11-17 11:09:55 +01:00
Markus Reiter
da9289eff0 Add more type signatures. 2020-11-13 12:26:36 +01:00
EricFromCanada
3768b7a6e9 apidoc: update comment wording, punctuation, formatting 2020-11-06 00:21:02 -05:00
EricFromCanada
4f7719ac2e apidoc: update examples' syntax 2020-11-05 23:50:55 -05:00
FX Coudert
b4ad930b5d
python: update virtualenv 2020-10-30 18:04:54 +01:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Michka Popoff
ddc73ffa0c python: do not add main brewed Python site-package to virtualenv
If added, this makes the virtualenv read the main site-package from brewed Python,
and especially makes it read our sitecustomize.py file, which will
modify the sys.executable path.

See the full discussion at:
https://github.com/Homebrew/brew/pull/8873

I also took the opportunity to not include test deps, as these will
be not be installed, so the .pth file should not contains references
to site-packages from test deps.

Previous packages on Linux did already contain the wrong lines in the pth file,
for example:
cat /home/linuxbrew/.linuxbrew/Cellar/aws-google-auth/0.0.36_1/libexec/lib/python3.8/site-packages/homebrew_deps.pth
import site; site.addsitedir('/home/linuxbrew/.linuxbrew/opt/python@3.8/lib/python3.8/site-packages')
import site; site.addsitedir('/home/linuxbrew/.linuxbrew/opt/libxml2/lib/python3.8/site-packages')

This might have caused subtle bugs for some packages but not for others.
2020-10-08 19:03:51 +02:00
Rylan Polster
0109ce58be update references to homebrew-virtualenv resources 2020-10-06 23:39:52 -04:00
Rylan Polster
43648100b4 virtualenv: use version 20 to support Python 3.9 2020-10-06 22:27:52 -04:00
Mike McQuaid
f04b014210
language/python: build python binary names dynamically.
Co-authored-by: Alexander Bayandin <a.bayandin@gmail.com>
2020-09-16 12:47:20 +01:00
FX Coudert
57c136e848
python.rb: prepare for Python 3.9 2020-09-15 22:41:15 +02:00
Markus Reiter
da0ff4feb0 Remove PYTHON_VIRTUALENV_* constants. 2020-08-19 10:45:56 +02:00
Markus Reiter
e909ea2471 Refactor and document Language::Python. 2020-08-19 10:45:56 +02:00
Jonathan Chang
76709d82c5 Fix brew style. 2020-07-13 23:24:14 +10:00
Bo Anderson
1c73393b47 language/python: raise if we can't detect the Python to use for venv 2020-07-09 15:43:36 +01:00