Commit Graph
484 Commits
Author SHA1 Message Date
ogiorgis d6b7028e1d Bug 1822030 - mach setup - make sure to take the correct README for the description r=sylvestre DONTBUILD
Differential Revision: https://phabricator.services.mozilla.com/D172409
2023-03-14 13:04:09 +00:00
Mike Hommey 7d02d9dc56 Bug 1819783 - Avoid logging errors when dealing with records with no params. r=ahal
Under some conditions, logging fails with messages like:

```
--- Logging error ---
Traceback (most recent call last):
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/logging/__init__.py", line 1083, in emit
    msg = self.format(record)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/logging/__init__.py", line 927, in format
    return fmt.format(record)
  File "/Users/glandium/mozilla-unified/python/mach/mach/logging.py", line 156, in format
    formatted_msg = record.msg.format(**record.params)
AttributeError: 'LogRecord' object has no attribute 'params'
```

In those cases, the record does have a message, as expected, but it's
preformatted and there are no params in the record at all, rather than
an empty dict.

Differential Revision: https://phabricator.services.mozilla.com/D171408
2023-03-07 21:04:39 +00:00
Alex Hochheiden 1b18e2053f Bug 1734402 - Regenerate lockfile with Python 3.7 as the minimum version r=ahal
Differential Revision: https://phabricator.services.mozilla.com/D171628
2023-03-07 08:08:44 +00:00
Cristian Tuns 8e9b64bcad Backed out 6 changesets (bug 1734402, bug 1774569) for causing build bustages Python related CLOSED TREE
Backed out changeset c8fefbece0f6 (bug 1774569)
Backed out changeset 5ae4dd2cfcbe (bug 1774569)
Backed out changeset e027acb00eb5 (bug 1774569)
Backed out changeset 5b820a21a13c (bug 1774569)
Backed out changeset 2b022e4e2607 (bug 1774569)
Backed out changeset 39ff773cfa63 (bug 1734402)
2023-03-07 00:46:00 -05:00
Alex Hochheiden d42ddcbea2 Bug 1734402 - Regenerate lockfile with Python 3.7 as the minimum version r=ahal
Differential Revision: https://phabricator.services.mozilla.com/D171628
2023-03-07 04:15:59 +00:00
ogiorgis d9ef1c2863 Bug 1749473 - fix docstring for autodoc r=firefox-source-docs-reviewers,sylvestre
Differential Revision: https://phabricator.services.mozilla.com/D171436
2023-03-03 09:37:42 +00:00
ogiorgis 4e44d78531 Bug 1749473 - fix some typos in doc r=firefox-source-docs-reviewers,sylvestre DONTBUILD
Differential Revision: https://phabricator.services.mozilla.com/D171191
2023-03-01 09:35:11 +00:00
Andrew Halberstadt ebe1373bd7 Bug 1808609 - Ignore non .txt files in test_site_compatibility.py, r=ahochheiden
This ensures we aren't accidentally mistaking e.g, .rej files as valid sites.

Depends on D165998

Differential Revision: https://phabricator.services.mozilla.com/D165999
2023-01-05 01:39:00 +00:00
Andrew Halberstadt 5bc5b87d16 Bug 1808609 - Improve error message in 'test_site_compatibility.py', r=ahochheiden
This should make it a little easier to understand what's happening.

Differential Revision: https://phabricator.services.mozilla.com/D165998
2023-01-05 01:38:59 +00:00
Sylvestre Ledru 1fd63074c1 Bug 1807899 - Remove the trailing whitespace and Windows CR on md files r=linter-reviewers,necko-reviewers,marco,jesup
Differential Revision: https://phabricator.services.mozilla.com/D165662
2022-12-30 15:23:21 +00:00
ahochheiden dcc634e2f9 Bug 1806736 - Wrap .egg-info deletion in a try to handle the scenario where a VCS isn't installed r=firefox-build-system-reviewers,glandium
Differential Revision: https://phabricator.services.mozilla.com/D165576
2022-12-29 11:39:40 +00:00
Marco Castelluccio f2004b2001 Bug 1801836 - Remove no longer necessary 'from __future__' imports under python/. r=linter-reviewers,glandium,ahal DONTBUILD
Differential Revision: https://phabricator.services.mozilla.com/D165398
2022-12-23 01:26:15 +00:00
Marco Castelluccio 9905632fd2 Bug 1790816 - Reformat python/ with isort. r=#linter-reviewers CLOSED TREE
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D162656
2022-12-21 09:56:15 +00:00
Ray Kraesig 2ac9c7b290 Bug 1804178 - [6/6] Switch from pytoml to toml in (almost) all other contexts r=firefox-build-system-reviewers,releng-reviewers,glandium,ahal
Convert all other imports of `pytoml` within mozilla-central to imports
of `toml`.

As both libraries patterned their API on that of the Python standard-
library module `json`, this is mostly a straight replace, with two
caveats:

  * pytoml's exception messages when loading a file provide the file
    name; toml's do not. Some additional machinery has been added or
    repurposed in a few places to ensure that the relevant filename is
    printed.

  * In `python_lockfile.py`, the order of arguments to `dump` needed to
    be reversed. (`toml` follows `json` in this; `pytoml` differs.)

This patchset does not remove pytoml from `requirements.in`, as `pytoml`
is still used by `compare-locales`.

Differential Revision: https://phabricator.services.mozilla.com/D164155
2022-12-20 23:01:26 +00:00
Shane Hughes 6058393486 Bug 1803225 - [docs] Link to MSYS2 setup guide. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D163385
2022-11-30 04:10:42 +00:00
ahochheiden d727302513 Bug 1801153 - If "pip check" fails, try purging all first-party ".egg-info" dirs then run "pip check" again r=firefox-build-system-reviewers,glandium
Differential Revision: https://phabricator.services.mozilla.com/D162807
2022-11-24 05:53:12 +00:00
ahochheiden 02cd9e0ec9 Bug 1800225 - Only realpath the prefix when resolving the sysconfig packages path r=firefox-build-system-reviewers,glandium
On POSIX platforms there can be `lib` and `lib64` for `site-packages`.
On Fedora35 once a virtualenv is created, `lib64` is a symlink of `lib`.
Since we can determine what these paths will be before the virtualenv is
created, `realpath` has different results before/after, which is
problematic for our `pthfile`.

Since we only care about resolving the symlink in the prefix (to keep it
in line with the `topobjdir`, we can simply only `realpath` that and
disregard that there's a symlink between `lib` and `lib64`, which makes
our `pthfile` that's created and expected always the same on all
platforms.

Differential Revision: https://phabricator.services.mozilla.com/D162136
2022-11-16 03:26:58 +00:00
ahochheiden abc021b800 Bug 1798827 - Use packaging.version instead of LooseVersion when comparing MozillaBuild versions r=firefox-build-system-reviewers,glandium
`packaging.version` can handle additional text in the version number (eg: `4.0pre1` and `4.0.2rc1`) that `LooseVersion` cannot.

Differential Revision: https://phabricator.services.mozilla.com/D161756
2022-11-10 16:47:51 +00:00
ahochheiden f4274fd5ce Bug 1795158 - Apply os.path.realpath to topsrcdir and topobjdir in MozbuildObject and in site.py r=firefox-build-system-reviewers,glandium
Differential Revision: https://phabricator.services.mozilla.com/D161553
2022-11-09 22:17:48 +00:00
ahochheiden 23ab1c9513 Bug 1744340 - Enable colored output on Windows - r=firefox-build-system-reviewers,glandium
- The bug that was constantly disabling `VIRTUAL_TERMINAL_PROCESSING` has been fixed upstream in CYGWIN (https://github.com/cygwin/cygwin/commit/fdbd1539329ad669606767ab5a63a16f825b4c45) and merged into MSYS2 (https://github.com/msys2/msys2-runtime/commit/e4fdb0cb73cc48a2db473b525b6ba0a33ecabf97)
- The upcoming MozillaBuild `4.0.2` release will have the updated MSYS2 that contains this fix, allowing us to enable colored output on Windows.
- We will enable `ENABLE_VIRTUAL_TERMINAL_PROCESSING` once (For each stdout and stderr) on initializing the formatter to ensure that `VIRTUAL_TERMINAL_PROCESSING` is enabled whenever Mach is called..
- These changes will only be active if the MozillaBuild version is greater than or equal to Release `4.0.2`

Differential Revision: https://phabricator.services.mozilla.com/D138256
2022-11-09 04:33:19 +00:00
ahochheiden 2d60680597 Bug 1744340 - Swap uses of blessings to blessed r=firefox-build-system-reviewers,glandium
Differential Revision: https://phabricator.services.mozilla.com/D160406
2022-11-09 04:33:18 +00:00
Butkovits Atila de5c43cb0f Backed out 7 changesets (bug 1744340, bug 1798827) for causing mach failures at test_commands.py. CLOSED TREE
Backed out changeset 9cb83a8d1f28 (bug 1798827)
Backed out changeset ebff36a14737 (bug 1744340)
Backed out changeset 5d6aabaf72c4 (bug 1744340)
Backed out changeset 8efafab5495f (bug 1744340)
Backed out changeset 8a873505f17d (bug 1744340)
Backed out changeset 3024fff68f6c (bug 1744340)
Backed out changeset 42a0a61583f0 (bug 1744340)
2022-11-09 04:21:47 +02:00
ahochheiden b3a464f74b Bug 1744340 - Enable colored output on Windows - r=firefox-build-system-reviewers,glandium
- The bug that was constantly disabling `VIRTUAL_TERMINAL_PROCESSING` has been fixed upstream in CYGWIN (https://github.com/cygwin/cygwin/commit/fdbd1539329ad669606767ab5a63a16f825b4c45) and merged into MSYS2 (https://github.com/msys2/msys2-runtime/commit/e4fdb0cb73cc48a2db473b525b6ba0a33ecabf97)
- The upcoming MozillaBuild `4.0.2` release will have the updated MSYS2 that contains this fix, allowing us to enable colored output on Windows.
- We will enable `ENABLE_VIRTUAL_TERMINAL_PROCESSING` once (For each stdout and stderr) on initializing the formatter to ensure that `VIRTUAL_TERMINAL_PROCESSING` is enabled whenever Mach is called..
- These changes will only be active if the MozillaBuild version is greater than or equal to Release `4.0.2`

Differential Revision: https://phabricator.services.mozilla.com/D138256
2022-11-09 00:40:56 +00:00
ahochheiden ede7f5f0e0 Bug 1744340 - Swap uses of blessings to blessed r=firefox-build-system-reviewers,glandium
Differential Revision: https://phabricator.services.mozilla.com/D160406
2022-11-09 00:40:55 +00:00
ahochheiden e08aea9374 Bug 1766497 - Manually copy pyvenv.cfg on Windows to workaround a bug with venv on Python 3.6 r=firefox-build-system-reviewers,glandium
Depends on D159196

Differential Revision: https://phabricator.services.mozilla.com/D160599
2022-11-01 07:48:07 +00:00
Alex Hochheiden d2539fe338 Bug 1766497: Mach: use venv instead of virtualenv r=ahal
Brew's Python 3.10 causes `virtualenv==20.7.2` to produce a wonky folder
structure (`$venv/opt/homebrew/lib/python3.10/site-packages`?).

This is likely fixed with newer `virtualenv`, but the simpler workaround
here is to use `venv` instead now that Python 3 is always used.

Adds `python3-venv` to docker image so that tests and debian-based tasks
can leverage it.

Differential Revision: https://phabricator.services.mozilla.com/D144872
2022-11-01 07:48:00 +00:00
Cristian Tuns 3e54e59e0c Backed out 5 changesets (bug 1766497) for causing build bustages with "No module named 'encodings'" CLOSED TREE
Backed out changeset 09f7f3d1c6dd (bug 1766497)
Backed out changeset 6bb5f754957a (bug 1766497)
Backed out changeset aedf2d7af408 (bug 1766497)
Backed out changeset 394555265c86 (bug 1766497)
Backed out changeset 41be40696e00 (bug 1766497)
2022-10-12 22:51:51 -04:00
Alex Hochheiden 823bd49b81 Bug 1766497: Mach: use venv instead of virtualenv r=ahal
Brew's Python 3.10 causes `virtualenv==20.7.2` to produce a wonky folder
structure (`$venv/opt/homebrew/lib/python3.10/site-packages`?).

This is likely fixed with newer `virtualenv`, but the simpler workaround
here is to use `venv` instead now that Python 3 is always used.

Adds `python3-venv` to docker image so that tests and debian-based tasks
can leverage it.

Differential Revision: https://phabricator.services.mozilla.com/D144872
2022-10-13 00:40:05 +00:00
ahochheiden 1b89a6364c Bug 1793828 - Always print the reason why the site is not 'up-to-date' r=firefox-build-system-reviewers,nalexander
Previously most 'reasons' could only be seen if using a debugger, which
was not helpful when there was a problem in CI.

Depends on D158703

Differential Revision: https://phabricator.services.mozilla.com/D158704
2022-10-06 18:18:32 +00:00
ahochheiden 31c5393497 Bug 1793828 - Also use normcase in addition to normpath for site_package_dirs r=firefox-build-system-reviewers,nalexander
This will resolve issues of drive letter uppercase/lowercase mismatch
causing the venv/site to be considered 'out-of'date'.

Differential Revision: https://phabricator.services.mozilla.com/D158703
2022-10-06 18:02:00 +00:00
Alex Ionescu a96e732d84 Bug 1774181 - Provide a mozperftest command to generate a side-by-side comparison r=perftest-reviewers,sparky
Differential Revision: https://phabricator.services.mozilla.com/D149230
2022-09-02 15:52:42 +00:00
Sean Pedigo c71f7fc3df Bug 1752202 - Updated documentation to better inform contributers how to debug Mach. r=ahal
Depends on D137058

Differential Revision: https://phabricator.services.mozilla.com/D137066
2022-08-17 21:18:08 +00:00
Butkovits Atila 14541a95d5 Bug 1782857 - Lint fix. a=fix. CLOSED TREE 2022-08-03 18:04:17 +03:00
Nick Alexander bd1c6c216b Bug 1782857 - Ignore (drive letter, on Windows) case in Python path. r=firefox-build-system-reviewers,ahochheiden
Differential Revision: https://phabricator.services.mozilla.com/D153546
2022-08-03 14:29:52 +00:00
Marian-Vasile Laza 48a4d00f65 Backed out 3 changesets (bug 1776642) for Pip version update causes CI tasks to fail. CLOSED TREE
Backed out changeset 450e42238ace (bug 1776642)
Backed out changeset 40cfebba22ac (bug 1776642)
Backed out changeset c4534787d467 (bug 1776642)
2022-07-21 15:50:20 +03:00
Sylvestre Ledru 5cbc63e635 no bug - Fix a few typo found by the next version of codespell r=marco
Differential Revision: https://phabricator.services.mozilla.com/D150321
2022-07-20 15:26:22 +00:00
Johan Lorenzo 66db3ad816 Bug 1776642 - part 2: Stop installing 'carrot' in mach tests and use a more recent package instead r=jcristau
carrot has been unmaintained since 2010[1]. setuptools>=58 cannot install it (same error as previous commit)

[1] https://pypi.org/project/carrot/#history

Differential Revision: https://phabricator.services.mozilla.com/D150969
2022-07-08 15:58:05 +00:00
ahochheiden c236ff78f4 Bug 1761849 - Consistently apply os.path.normpath to paths that end up in the same list r=firefox-build-system-reviewers,glandium
Depends on D148177

Differential Revision: https://phabricator.services.mozilla.com/D148204
2022-06-08 16:11:17 +00:00
Mike Hommey a536287502 Bug 1772459 - Ignore --help after -- in mach subcommand invocations. r=ahal
Differential Revision: https://phabricator.services.mozilla.com/D148229
2022-06-07 20:39:09 +00:00
ahochheiden cbf025e19c Bug 1761849 - Added missing pathlib conversions in mach.util r=firefox-build-system-reviewers,mhentges
Differential Revision: https://phabricator.services.mozilla.com/D142274
2022-06-02 22:16:39 +00:00
Norisz Fay f19c8ddbe7 Backed out changeset 4b6378a06816 (bug 1766497) for causing docker images bustages CLOSED TREE 2022-05-04 17:50:36 +03:00
Mitchell Hentges 596bbf1125 Bug 1766497: Mach: use venv instead of virtualenv r=ahal
Brew's Python 3.10 causes `virtualenv==20.7.2` to produce a wonky folder
structure (`$venv/opt/homebrew/lib/python3.10/site-packages`?).

This is likely fixed with newer `virtualenv`, but the simpler workaround
here is to use `venv` instead now that Python 3 is always used.

Adds `python3-venv` to docker image so that tests and debian-based tasks
can leverage it.

Differential Revision: https://phabricator.services.mozilla.com/D144872
2022-05-04 14:17:04 +00:00
Mitchell Hentges 144e9e9f25 Bug 1764534: Maintain site_packages_dir order r=emilio
De-duping with `set` causes order to no longer be maintained when the
items are distinct. Use the `OrderedDict` technique to de-dupe
consistently instead.

Differential Revision: https://phabricator.services.mozilla.com/D143604
2022-04-13 14:44:06 +00:00
Mitchell Hentges 66c58cefa1 Bug 1763244: Write tests for site activation logic r=ahal
Verify that activating mach and command sites in various configurations
affects the `sys.path` accurately.
Also verify that the `sys.path` is correct between the "activated
process" and fresh processes spawned from created virtualenvs.

Finally, tweak existing path-management behaviour to be more consistent:
* Don't unnecessarily sort `pths` from requirement definitions - it's
  more consistent (and more dependable) to keep the provided order.
* Continue removing unwanted `venv` entries from the `sys.path`, but
  don't add them back (such as the `$prefix` entry)
* Always remove `venv` entries from the `sys.path` when the venv isn't
  being populated. Though this doesn't affect behaviour, it makes
  assertions easier and simplifies the runtime state a bit.

Differential Revision: https://phabricator.services.mozilla.com/D143201
2022-04-12 21:28:50 +00:00
Mitchell Hentges 0adecbdafd Bug 1761150: Mach should use fresh system python, don't inherit sys.path r=ahal
Previously, when using the system Python packages, Mach would reuse the
values already existing in the `sys.path`. This had two benefits:
1. We didn't have to do work to calculate which paths the "system
   Python" specifically referred to.
2. This allowed us to support nested Mach calls
   (such as `./mach --virtualenv psutil ./mach build`).

However, it came with its own headaches, specifically around "consistent
imports" and Python subprocesses, such as in the following example
1. Mach runs "using system Python"
2. The "build" site (for example) would be activated. The current
   `sys.path` is included in the virtualenv's `mach.pth` file so that
   subprocesses will have access to the same packages as the primary
   Mach process
3. //Something// adds something to the `sys.path`
4. The build virtualenv is redundantly re-activated (such as due to
   generic setup code for some module). Though we don't physically
   re-activate the virtualenv, we //do// check that it's up-to-date to
   validate assumptions - **and it's not!** It's missing the
   //something// that was added to the `sys.path`.
5. We can't re-create the build virtualenv because it's already active,
   so:
6. An error is raised so that unexpected out-of-date-ness doesn't fly
   under the radar.

-----

This patch solves this by calculating the "system Python" paths in a
deterministic way. Then, even when using the system Python, the Mach and
command sites use define themselves in a consistent way.

This means that we can't do `./mach --virtualenv <venv> ./mach ...` to
shares `venv`'s packages with the whole new Mach process. Fortunately,
this has been replaced with  moving such packages into the nested Mach
command's requirements  definition instead.

TL;DR: more consistent, less failures. 👍

-----

One more detail, this time around the `sys_path()` function:
Ideally, we could calculate the standard library paths *and* the
"system" paths with only one Python subprocess. Unfortunately,
that's not the case:
* If `-S` isn't provided, then it's tricky to separate the standard
  library paths from the system paths
* If `-S` is provided, then doing `site.getsitepackages()` in a
  virtualenv returns the *system* site packages, not the virtualenv's.

To work around this, we call the external python twice, and in
parallel. This allows resolving the information we need while avoiding
performance costs.

Differential Revision: https://phabricator.services.mozilla.com/D143200
2022-04-12 18:40:14 +00:00
Mitchell Hentges d62f3b8a4e Bug 1659593: Make ./mach vendor python cross-platform r=ahal
Use `poetry` instead of `pip-compile`, then leverage `pip` to assert
that there's no conflicts between environments.

This enables simplifying `requirements.in`, since `colorama` is now
automatically picked up, as vendoring is no longer linux-py3.6-specific.

`poetry==1.2.0a2` was chosen because it was the first version that would
include `pip`/`setuptools`/`wheel` in the `requirements.txt`, yet it was
also the last version that supports Python 3.6 (as still used in CI in
some spots).

Sorry about the `requirements.txt` noise, that's because poetry doesn't
sort hashes yet [1]. Fortunately, you can be confident in
`requirements.txt` changes by checking that this patch doesn't include
changes to vendored packages themselves (I'm including the results of a
`./mach vendor python`).

[1] https://github.com/python-poetry/poetry/issues/5408

Differential Revision: https://phabricator.services.mozilla.com/D142884
2022-04-07 18:00:28 +00:00
Mitchell Hentges 048b437d66 Bug 1755516: Simplify "site.py" handling of command site package source r=ahal
Now that we are gleaning a site packages source in a process-global way
(that is *not* conditional on the site that's being managed), we've
removed an edge case from occurring: the case where Mach would use
`SitePackagesSource.NONE`, but the command site would use
`SitePackagesSource.SYSTEM`. This would've occurred if none of Mach's
dependencies were found in the system Python, but instead once the
command site was initialized, one of *its* dependencies were located.

Since that can no longer happen:
* Command sites that don't populate their VENV will *always* use the
  same site packages source as Mach
* `pthfile` generation is simplified (the priority of the system paths
  is no longer variable)
* We no longer need to track `site_packages_source` in metadata, since
  we can use `mach_site_packages_source` instead.

While here, I moved the "`PIP_NETWORK_INSTALL_RESTRICTED_VIRTUALENVS`
sites shouldn't have `pypi_requirements`" check to a test, since there's
no need for it to happen at runtime.

Differential Revision: https://phabricator.services.mozilla.com/D140668
2022-04-04 15:27:08 +00:00
Mitchell Hentges 54b05e1e01 Bug 1755516: Remove "use system Python packages" inference r=ahal
Simplify Mach's decision-making in CI for where to find native Python
packages: unless `MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system` is
provided, always ignore system packages.

Removes optional dependency on system's `pip`, instead leaning on
vendored `pip` copy to see what package versions are installed.

Differential Revision: https://phabricator.services.mozilla.com/D140258
2022-04-04 13:26:53 +00:00
Mitchell Hentges 16bf6deb6c Bug 1727819: Guard against command site -> another site activations r=ahal
The Mach site is asserted to be compatible with all command sites, but
command sites are deliberately //not// asserted to be compatible with
each other - they're //supposed// to have the flexibility of being
able to be incompatible.

Accordingly, let's fail loudly if code tries to activate from one
command site to another.

Note that, due to the Mach site being a superset of common, it's safe to
activate from "common" to "<other command site>". This is needed for
cases like `./mach python --virtualenv ...`.

This required updating the `mozproxy` tests, who would deliberately
activate the `common` site so they could call a `mozproxy` entry point
script. These tests were fixed by instead invoking `mozproxy` as a
module (`-m`) of the current `python-test` site.

Differential Revision: https://phabricator.services.mozilla.com/D141659
2022-03-24 14:27:49 +00:00
Mitchell Hentges eb3080a220 Bug 1724274: Move virtualenv dependency manifests to python/virtualenvs r=ahal
This is needed for a few reasons:
* All mach commands can use virtualenvs, not just `build`-related
  commands, so the files don't make sense to be in `build/`.
* When locking is added, more files associated with virtualenvs will be
  added, and this will change will ease the related directory structure
  setup.
* This removes the need for a redundant "_virtualenv_packages" keyword
  as part of the manifest filenames.

Differential Revision: https://phabricator.services.mozilla.com/D140382
2022-03-24 14:04:34 +00:00