Closed Bug 1673888 Opened 5 years ago Closed 5 years ago

ModuleNotFoundError: No module named '_cffi_backend' trying to `import glean`

Categories

(Data Platform and Tools :: Glean: SDK, defect)

defect

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: gregtatum, Unassigned)

Details

I get the following error message every time I run a mach command. This has been going on for awhile.

Glean could not be found, so telemetry will not be reported. You may need to run |mach bootstrap|.

I then run:

➤ mach bootstrap --no-interactive --application-choice 'Firefox for Desktop'
Your version of Python 3 (3.8.6) is new enough.
Your version of Python 2 (2.7.17) is new enough.
created virtual environment CPython3.8.6.final.0-64 in 344ms
  creator CPython3Posix(dest=/Users/greg/.mozbuild/_virtualenvs/mach, clear=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/greg/Library/Application Support/virtualenv)
    added seed packages: pip==20.2.2, setuptools==49.6.0, wheel==0.35.1
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
running build_ext
copying build/lib.macosx-10.15-x86_64-3.8/psutil/_psutil_osx.cpython-38-darwin.so -> psutil
copying build/lib.macosx-10.15-x86_64-3.8/psutil/_psutil_posix.cpython-38-darwin.so -> psutil

Error processing command. Ignoring because optional. (optional:packages.txt:comm/build/virtualenv_packages.txt)
Collecting zstandard<=0.13.0,>=0.9.0
  Using cached zstandard-0.13.0-cp38-cp38-macosx_10_9_x86_64.whl (460 kB)
Installing collected packages: zstandard
Successfully installed zstandard-0.13.0
WARNING: You are using pip version 20.1; however, version 20.2.4 is available.
You should consider upgrading via the '/Users/greg/.mozbuild/_virtualenvs/mach/bin/python -m pip install --upgrade pip' command.
Collecting glean_sdk~=32.3.1
  Using cached glean_sdk-32.3.2-cp36-abi3-macosx_10_7_x86_64.whl (789 kB)
Requirement already satisfied: cffi>=1 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean_sdk~=32.3.1) (1.14.0)
Collecting glean-parser==1.28.3
  Using cached glean_parser-1.28.3-py3-none-any.whl (56 kB)
Requirement already satisfied: pycparser in /Users/greg/Library/Python/3.7/lib/python/site-packages (from cffi>=1->glean_sdk~=32.3.1) (2.20)
Requirement already satisfied: PyYAML>=3.13 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (5.3)
Requirement already satisfied: yamllint>=1.18.0 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (1.24.2)
Requirement already satisfied: Jinja2>=2.10.1 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (2.11.2)
Requirement already satisfied: appdirs>=1.4 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (1.4.4)
Requirement already satisfied: diskcache>=4 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (4.1.0)
Requirement already satisfied: Click>=7 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (7.1.2)
Requirement already satisfied: jsonschema>=3.0.2 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (3.2.0)
Collecting pathspec>=0.5.3
  Using cached pathspec-0.8.0-py2.py3-none-any.whl (28 kB)
Requirement already satisfied: MarkupSafe>=0.23 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from Jinja2>=2.10.1->glean-parser==1.28.3->glean_sdk~=32.3.1) (1.1.1)
Requirement already satisfied: six>=1.11.0 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (1.15.0)
Processing /Users/greg/Library/Caches/pip/wheels/3d/22/08/7042eb6309c650c7b53615d5df5cc61f1ea9680e7edd3a08d2/pyrsistent-0.17.3-cp38-cp38-macosx_10_15_x86_64.whl
Requirement already satisfied: attrs>=17.4.0 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (19.3.0)
Requirement already satisfied: setuptools in /Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (49.6.0)
Installing collected packages: glean-parser, glean-sdk, pathspec, pyrsistent
  Attempting uninstall: glean-parser
    Found existing installation: glean-parser 1.28.5
    Not uninstalling glean-parser at /Users/greg/Library/Python/3.7/lib/python/site-packages, outside environment /Users/greg/.mozbuild/_virtualenvs/mach
    Can't uninstall 'glean-parser'. No files were found to uninstall.
  Attempting uninstall: glean-sdk
    Found existing installation: glean-sdk 32.4.0
    Not uninstalling glean-sdk at /Users/greg/Library/Python/3.7/lib/python/site-packages, outside environment /Users/greg/.mozbuild/_virtualenvs/mach
    Can't uninstall 'glean-sdk'. No files were found to uninstall.
Successfully installed glean-parser-1.28.3 glean-sdk-32.3.2 pathspec-0.8.0 pyrsistent-0.17.3
WARNING: You are using pip version 20.1; however, version 20.2.4 is available.
You should consider upgrading via the '/Users/greg/.mozbuild/_virtualenvs/mach/bin/python -m pip install --upgrade pip' command.
Python 3 mach environment created.
... more unrelated changes

After that, I get the same error message:

~/dev/platform-gecko2 at 09:07:24
➤ mach lint tools/profiler/tests/xpcshell/test_feature_mainthreadio.js
✖ 0 problems (0 errors, 0 warnings)
Glean could not be found, so telemetry will not be reported. You may need to run |mach bootstrap|.

I added a print(sys.path) and sys.executable in python/mach/mach/telemetry.py with the following result:

sys.path: [
  '/Users/greg/dev/platform-gecko2/tools/lint',
  '/Users/greg/dev/platform-gecko2/obj-ff-release/_virtualenvs/init_py3/lib/python3.8/site-packages',
  '/Users/greg/dev/platform-gecko2/third_party/python/glean_parser',
  '/Users/greg/dev/platform-gecko2/python/mach',
  '/Users/greg/dev/platform-gecko2/python/mozboot',
  '/Users/greg/dev/platform-gecko2/python/mozbuild',
  '/Users/greg/dev/platform-gecko2/python/mozlint',
  '/Users/greg/dev/platform-gecko2/python/mozperftest',
  '/Users/greg/dev/platform-gecko2/python/mozrelease',
  '/Users/greg/dev/platform-gecko2/python/mozterm',
  '/Users/greg/dev/platform-gecko2/python/mozversioncontrol',
  '/Users/greg/dev/platform-gecko2/python/l10n',
  '/Users/greg/dev/platform-gecko2/third_party/python/appdirs',
  '/Users/greg/dev/platform-gecko2/third_party/python/atomicwrites',
  '/Users/greg/dev/platform-gecko2/third_party/python/attrs/src',
  '/Users/greg/dev/platform-gecko2/third_party/python/biplist',
  '/Users/greg/dev/platform-gecko2/third_party/python/blessings',
  '/Users/greg/dev/platform-gecko2/third_party/python/Click',
  '/Users/greg/dev/platform-gecko2/third_party/python/compare-locales',
  '/Users/greg/dev/platform-gecko2/third_party/python/configobj',
  '/Users/greg/dev/platform-gecko2/third_party/python/cookies',
  '/Users/greg/dev/platform-gecko2/third_party/python/cram',
  '/Users/greg/dev/platform-gecko2/third_party/python/diskcache',
  '/Users/greg/dev/platform-gecko2/third_party/python/distro',
  '/Users/greg/dev/platform-gecko2/third_party/python/dlmanager',
  '/Users/greg/dev/platform-gecko2/third_party/python/ecdsa/src',
  '/Users/greg/dev/platform-gecko2/third_party/python/esprima',
  '/Users/greg/dev/platform-gecko2/third_party/python/fluent.migrate',
  '/Users/greg/dev/platform-gecko2/third_party/python/fluent.syntax',
  '/Users/greg/dev/platform-gecko2/third_party/python/funcsigs',
  '/Users/greg/dev/platform-gecko2/third_party/python/importlib_metadata',
  '/Users/greg/dev/platform-gecko2/third_party/python/iso8601',
  '/Users/greg/dev/platform-gecko2/third_party/python/Jinja2/src',
  '/Users/greg/dev/platform-gecko2/third_party/python/jsonschema',
  '/Users/greg/dev/platform-gecko2/third_party/python/MarkupSafe/src',
  '/Users/greg/dev/platform-gecko2/third_party/python/mohawk',
  '/Users/greg/dev/platform-gecko2/third_party/python/more-itertools',
  '/Users/greg/dev/platform-gecko2/third_party/python/mozilla-version',
  '/Users/greg/dev/platform-gecko2/third_party/python/pathlib2',
  '/Users/greg/dev/platform-gecko2/third_party/python/pathspec',
  '/Users/greg/dev/platform-gecko2/third_party/python/pep487/lib',
  '/Users/greg/dev/platform-gecko2/third_party/python/gyp/pylib',
  '/Users/greg/dev/platform-gecko2/third_party/python/pyrsistent',
  '/Users/greg/dev/platform-gecko2/third_party/python/python-hglib',
  '/Users/greg/dev/platform-gecko2/third_party/python/pluggy',
  '/Users/greg/dev/platform-gecko2/third_party/python/jsmin',
  '/Users/greg/dev/platform-gecko2/third_party/python/psutil',
  '/Users/greg/dev/platform-gecko2/third_party/python/pylru',
  '/Users/greg/dev/platform-gecko2/third_party/python/pystache',
  '/Users/greg/dev/platform-gecko2/third_party/python/PyYAML/lib3/',
  '/Users/greg/dev/platform-gecko2/third_party/python/requests',
  '/Users/greg/dev/platform-gecko2/third_party/python/requests-unixsocket',
  '/Users/greg/dev/platform-gecko2/third_party/python/slugid',
  '/Users/greg/dev/platform-gecko2/third_party/python/taskcluster',
  '/Users/greg/dev/platform-gecko2/third_party/python/taskcluster-urls',
  '/Users/greg/dev/platform-gecko2/third_party/python/py',
  '/Users/greg/dev/platform-gecko2/third_party/python/pytest/src',
  '/Users/greg/dev/platform-gecko2/third_party/python/pytoml',
  '/Users/greg/dev/platform-gecko2/third_party/python/redo',
  '/Users/greg/dev/platform-gecko2/third_party/python/responses',
  '/Users/greg/dev/platform-gecko2/third_party/python/sentry-sdk',
  '/Users/greg/dev/platform-gecko2/third_party/python/six',
  '/Users/greg/dev/platform-gecko2/third_party/python/taskcluster-urls',
  '/Users/greg/dev/platform-gecko2/third_party/python/urllib3/src',
  '/Users/greg/dev/platform-gecko2/third_party/python/voluptuous',
  '/Users/greg/dev/platform-gecko2/third_party/python/json-e',
  '/Users/greg/dev/platform-gecko2/third_party/python/yamllint',
  '/Users/greg/dev/platform-gecko2/third_party/python/zipp',
  '/Users/greg/dev/platform-gecko2/build',
  '/Users/greg/dev/platform-gecko2/config',
  '/Users/greg/dev/platform-gecko2/config/mozunit',
  '/Users/greg/dev/platform-gecko2/dom/bindings',
  '/Users/greg/dev/platform-gecko2/dom/bindings/parser',
  '/Users/greg/dev/platform-gecko2/layout/tools/reftest',
  '/Users/greg/dev/platform-gecko2/third_party/python/ply',
  '/Users/greg/dev/platform-gecko2/taskcluster',
  '/Users/greg/dev/platform-gecko2/testing',
  '/Users/greg/dev/platform-gecko2/testing/condprofile',
  '/Users/greg/dev/platform-gecko2/testing/firefox-ui/harness',
  '/Users/greg/dev/platform-gecko2/testing/marionette/client',
  '/Users/greg/dev/platform-gecko2/testing/marionette/harness',
  '/Users/greg/dev/platform-gecko2/testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py',
  '/Users/greg/dev/platform-gecko2/testing/marionette/puppeteer/firefox',
  '/Users/greg/dev/platform-gecko2/testing/raptor',
  '/Users/greg/dev/platform-gecko2/testing/talos',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/manifestparser',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/mozcrash',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/mozdebug',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/mozdevice',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/mozfile',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/mozhttpd',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/mozgeckoprofiler',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/mozinfo',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/mozinstall',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/mozleak',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/mozlog',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/moznetwork',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/mozpower',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/mozprocess',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/mozprofile',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/mozproxy',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/mozrunner',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/mozsystemmonitor',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/mozscreenshot',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/moztest',
  '/Users/greg/dev/platform-gecko2/testing/mozbase/mozversion',
  '/Users/greg/dev/platform-gecko2/tools',
  '/Users/greg/dev/platform-gecko2/testing/web-platform',
  '/Users/greg/dev/platform-gecko2/testing/web-platform/tests/tools/third_party/html5lib',
  '/Users/greg/dev/platform-gecko2/testing/web-platform/tests/tools/third_party/webencodings',
  '/Users/greg/dev/platform-gecko2/testing/web-platform/tests/tools/third_party/h2',
  '/Users/greg/dev/platform-gecko2/testing/web-platform/tests/tools/third_party/hpack',
  '/Users/greg/dev/platform-gecko2/testing/web-platform/tests/tools/third_party/hyperframe',
  '/Users/greg/dev/platform-gecko2/testing/web-platform/tests/tools/third_party/certifi',
  '/Users/greg/dev/platform-gecko2/testing/web-platform/tests/tools/wptserve',
  '/Users/greg/dev/platform-gecko2/testing/web-platform/tests/tools/wptrunner',
  '/Users/greg/dev/platform-gecko2/testing/web-platform/tests/tools/six',
  '/Users/greg/dev/platform-gecko2/testing/xpcshell',
  '/Users/greg/dev/platform-gecko2/third_party/python/mock-1.0.0',
  '/Users/greg/dev/platform-gecko2/xpcom/ds/tools',
  '/Users/greg/dev/platform-gecko2/tools/moztreedocs',
  '/Users/greg/dev/platform-gecko2/third_party/python/cbor2',
  '/Users/greg/dev/platform-gecko2/third_party/python/pyasn1',
  '/Users/greg/dev/platform-gecko2/third_party/python/pyasn1-modules',
  '/Users/greg/dev/platform-gecko2/third_party/python/rsa',
  '/Users/greg/dev/platform-gecko2/toolkit/components/telemetry/tests/marionette/harness',
  '/Users/greg/dev/platform-gecko2/xpcom/idl-parser',
  '/Users/greg/dev/platform-gecko2',
  '/Users/greg/Library/Python/3.7/lib/python/site-packages',
  '/Users/greg/dev/platform-gecko2',
  '/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python38.zip',
  '/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8',
  '/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload',
  '/Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages',
  '/Users/greg/dev/platform-gecko2/python/mozbuild/mozbuild/vendor/../../../third_party/python/voluptuous',
  '/Users/greg/dev/platform-gecko2/python/mozbuild/mozbuild/vendor/../../../third_party/python/pyyaml/lib',
  '/Users/greg/dev/platform-gecko2/testing/awsy',
  '/Users/greg/dev/platform-gecko2/tools/lint/eslint/eslint'
]

sys.executable: /Users/greg/.mozbuild/_virtualenvs/mach/bin/python

➤ /Users/greg/.mozbuild/_virtualenvs/mach/bin/python --version
Python 3.8.6

Is this EVERY mach command, or only mach lint? Like for example do you get the same message on mach build?

Does ~/.mozbuild/_virtualenvs/mach/bin/python -c 'import glean' succeed or fail?

Flags: needinfo?(gtatum)

Ah, here is a new error I haven't seen:

~/dev/platform-gecko2 at 13:44:44
➤ ~/.mozbuild/_virtualenvs/mach/bin/python -c 'import glean'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/greg/Library/Python/3.7/lib/python/site-packages/glean/__init__.py", line 17, in <module>
    from .glean import Glean
  File "/Users/greg/Library/Python/3.7/lib/python/site-packages/glean/glean.py", line 22, in <module>
    from .config import Configuration
  File "/Users/greg/Library/Python/3.7/lib/python/site-packages/glean/config.py", line 13, in <module>
    from . import net
  File "/Users/greg/Library/Python/3.7/lib/python/site-packages/glean/net/__init__.py", line 14, in <module>
    from .ping_upload_worker import PingUploadWorker
  File "/Users/greg/Library/Python/3.7/lib/python/site-packages/glean/net/ping_upload_worker.py", line 14, in <module>
    from .upload_task_tag import UploadTaskTag
  File "/Users/greg/Library/Python/3.7/lib/python/site-packages/glean/net/upload_task_tag.py", line 8, in <module>
    from .. import _ffi
  File "/Users/greg/Library/Python/3.7/lib/python/site-packages/glean/_ffi.py", line 14, in <module>
    from ._glean_ffi import ffi  # type: ignore
  File "/Users/greg/Library/Python/3.7/lib/python/site-packages/glean/_glean_ffi.py", line 2, in <module>
    import _cffi_backend
ModuleNotFoundError: No module named '_cffi_backend'

Here is a truncated build, where i hit "ctrl-c" on mac to quit it.

~/dev/platform-gecko2 at 13:44:10
➤ ./mach build
...
KeyboardInterrupt
 1:48.23 /usr/local/bin/terminal-notifier -title Mozilla Build System -group mozbuild -message Build failed
Glean could not be found, so telemetry will not be reported. You may need to run |mach bootstrap

mach help does not emit this message.
mach xpcshell-test does.

~/dev/platform-gecko2 at 13:49:52
➤ mach xpcshell-test tools/profiler/tests
...
~~~~~~~~
Ran 16 checks (16 tests)
Expected results: 12
Skipped: 4 tests
Unexpected results: 0
OK
 0:02.76 INFO Node moz-http2 server shutting down ...
 0:02.77 INFO http3Server server shutting down ...
Glean could not be found, so telemetry will not be reported. You may need to run |mach bootstrap|.
Flags: needinfo?(gtatum)

Importing cffi does not create an error.

~/dev/platform-gecko2 at 13:53:04
➤ ~/.mozbuild/_virtualenvs/mach/bin/python -c 'import cffi'

Are you at the latest mozilla-central? If you're at an old version of the code, we've made a lot of fixes over time.

What platform are you on? macOS? Which version?

If you ~/.mozbuild/_virtualenvs/mach/bin/pip install glean_sdk~=32.3.1, does that succeed/does it fix the problem?

Flags: needinfo?(gtatum)

Are you at the latest mozilla-central? If you're at an old version of the code, we've made a lot of fixes over time.

I was within a week. I did a fresh pull, mach bootstrap, and it's still reproducing.

What platform are you on? macOS? Which version?

macOS Catalina 10.15.7

If you /.mozbuild/_virtualenvs/mach/bin/pip install glean_sdk=32.3.1, does that succeed/does it fix the problem?

Here was my first run, which I think succeeded but gave warnings of local packages.

Collecting glean_sdk~=32.3.1
  Using cached glean_sdk-32.3.2-cp36-abi3-macosx_10_7_x86_64.whl (789 kB)
Collecting glean-parser==1.28.3
  Using cached glean_parser-1.28.3-py3-none-any.whl (56 kB)
Requirement already satisfied: cffi>=1 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean_sdk~=32.3.1) (1.14.0)
Requirement already satisfied: PyYAML>=3.13 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (5.3)
Requirement already satisfied: yamllint>=1.18.0 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (1.24.2)
Requirement already satisfied: jsonschema>=3.0.2 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (3.2.0)
Requirement already satisfied: Jinja2>=2.10.1 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (2.11.2)
Requirement already satisfied: diskcache>=4 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (4.1.0)
Requirement already satisfied: Click>=7 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (7.1.2)
Requirement already satisfied: appdirs>=1.4 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (1.4.4)
Requirement already satisfied: pycparser in /Users/greg/Library/Python/3.7/lib/python/site-packages (from cffi>=1->glean_sdk~=32.3.1) (2.20)
Requirement already satisfied: pathspec>=0.5.3 in /Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages (from yamllint>=1.18.0->glean-parser==1.28.3->glean_sdk~=32.3.1) (0.8.0)
Requirement already satisfied: six>=1.11.0 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (1.15.0)
Requirement already satisfied: setuptools in /Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (49.6.0)
Requirement already satisfied: attrs>=17.4.0 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (19.3.0)
Requirement already satisfied: pyrsistent>=0.14.0 in /Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (0.17.3)
Requirement already satisfied: MarkupSafe>=0.23 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from Jinja2>=2.10.1->glean-parser==1.28.3->glean_sdk~=32.3.1) (1.1.1)
Installing collected packages: glean-parser, glean-sdk
  Attempting uninstall: glean-parser
    Found existing installation: glean-parser 1.28.5
    Not uninstalling glean-parser at /Users/greg/Library/Python/3.7/lib/python/site-packages, outside environment /Users/greg/.mozbuild/_virtualenvs/mach
    Can't uninstall 'glean-parser'. No files were found to uninstall.
  Attempting uninstall: glean-sdk
    Found existing installation: glean-sdk 32.4.0
    Not uninstalling glean-sdk at /Users/greg/Library/Python/3.7/lib/python/site-packages, outside environment /Users/greg/.mozbuild/_virtualenvs/mach
    Can't uninstall 'glean-sdk'. No files were found to uninstall.
Successfully installed glean-parser-1.28.3 glean-sdk-32.3.2

I ran:

➤ pip uninstall glean-parser
➤ pip uninstall glean-sdk

A few times until all of files were removed (it did take multiple runs).

I ran mach bootstrap between steps and tested.

➤ ~/.mozbuild/_virtualenvs/mach/bin/pip install glean_sdk~=32.3.1
Requirement already satisfied: glean_sdk~=32.3.1 in /Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages (32.3.2)
Requirement already satisfied: cffi>=1 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean_sdk~=32.3.1) (1.14.0)
Requirement already satisfied: glean-parser==1.28.3 in /Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages (from glean_sdk~=32.3.1) (1.28.3)
Requirement already satisfied: pycparser in /Users/greg/Library/Python/3.7/lib/python/site-packages (from cffi>=1->glean_sdk~=32.3.1) (2.20)
Requirement already satisfied: yamllint>=1.18.0 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (1.24.2)
Requirement already satisfied: Jinja2>=2.10.1 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (2.11.2)
Requirement already satisfied: diskcache>=4 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (4.1.0)
Requirement already satisfied: Click>=7 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (7.1.2)
Requirement already satisfied: jsonschema>=3.0.2 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (3.2.0)
Requirement already satisfied: PyYAML>=3.13 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (5.3)
Requirement already satisfied: appdirs>=1.4 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (1.4.4)
Requirement already satisfied: pathspec>=0.5.3 in /Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages (from yamllint>=1.18.0->glean-parser==1.28.3->glean_sdk~=32.3.1) (0.8.0)
Requirement already satisfied: MarkupSafe>=0.23 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from Jinja2>=2.10.1->glean-parser==1.28.3->glean_sdk~=32.3.1) (1.1.1)
Requirement already satisfied: setuptools in /Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (49.6.0)
Requirement already satisfied: attrs>=17.4.0 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (19.3.0)
Requirement already satisfied: pyrsistent>=0.14.0 in /Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (0.17.3)
Requirement already satisfied: six>=1.11.0 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (1.15.0)
WARNING: You are using pip version 20.1; however, version 20.2.4 is available.
You should consider upgrading via the '/Users/greg/.mozbuild/_virtualenvs/mach/bin/python -m pip install --upgrade pip' command.

The following was empty:

➤ ls /Users/greg/Library/Python/3.7/lib/python/site-packages | grep glean

However, after messing with it for awhile, the issue is still reproducing. Also, I have a new error with the new mach lint.

~/dev/platform-gecko2 at 14:30:01
➤ mach lint tools/profiler/tests/xpcshell
error: problem with lint setup, skipping android-api-lint, android-checkstyle, android-javadoc, android-lint, android-test
Traceback (most recent call last):
  File "/Users/greg/dev/platform-gecko2/python/mozlint/mozlint/roller.py", line 64, in _run_worker
    res = func(paths, config, **lintargs) or []
  File "/Users/greg/dev/platform-gecko2/python/mozlint/mozlint/types.py", line 57, in __call__
    return self._lint(paths, config, **lintargs)
  File "/Users/greg/dev/platform-gecko2/python/mozlint/mozlint/types.py", line 148, in _lint
    return func(files, config, **lintargs)
  File "/Users/greg/dev/platform-gecko2/tools/lint/python/black.py", line 131, in lint
    return run_black(config, files, fix=fix, log=lintargs["log"])
  File "/Users/greg/dev/platform-gecko2/tools/lint/python/black.py", line 118, in run_black
    log.debug("Black version {}".format(get_black_version(binary)))
  File "/Users/greg/dev/platform-gecko2/tools/lint/python/black.py", line 43, in get_black_version
    output = subprocess.check_output(
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 489, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/greg/.mozbuild/_virtualenvs/mach/bin/black'
A failure occurred in the black linter.
✖ 1 problem (0 errors, 0 warnings, 1 failure)
Glean could not be found, so telemetry will not be reported. You may need to run |mach bootstrap|.

I'm not sure if this is related, or a red herring.

Here is the path import order.

➤ ~/.mozbuild/_virtualenvs/mach/bin/python -c 'import sys; print(sys.path)'
[
  '',
  '/Users/greg/Library/Python/3.7/lib/python/site-packages',
  '/Users/greg/dev/platform-gecko2',
  '/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python38.zip',
  '/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8',
  '/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload',
  '/Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages'
]
Flags: needinfo?(gtatum)

The black thing is unrelated (that's bug 1660338).

This is interesting to me:

Not uninstalling glean-parser at /Users/greg/Library/Python/3.7/lib/python/site-packages, outside environment /Users/greg/.mozbuild/_virtualenvs/mach

Looks like it's skipping the install because you have the same packages installed globally? So if you do a pip3 uninstall glean-sdk glean-parser (note that's the global pip3, not the one in ~/.mozbuild), then rm -rf ~/.mozbuild/_virtualenvs, then re-bootstrap, does that fix it?

I believe I cleaned these out already in the last series of commands:

➤ pip3 uninstall glean-sdk glean-parser
WARNING: Skipping glean-sdk as it is not installed.
WARNING: Skipping glean-parser as it is not installed.

I did rm -rf ~/.mozbuild/_virtualenvs + boostrap and it's still reproducing.

I don't currently see a reason to believe this has anything to do with bootstrap or mach, so I'm wondering if this is an issue with the Python package itself.

Hey Glean folks: this user is encountering an issue where they can install glean-sdk in their virtualenv, but then trying to import glean after the fact fails due to missing the _cffi_backend package. Are you aware of this issue/is there a workaround? Here are the latest logs:

~/dev/platform-gecko2 at 14:58:23
➤ ~/.mozbuild/_virtualenvs/mach/bin/pip install glean_sdk~=32.3.1
Requirement already satisfied: glean_sdk~=32.3.1 in /Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages (32.3.2)
Requirement already satisfied: cffi>=1 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean_sdk~=32.3.1) (1.14.0)
Requirement already satisfied: glean-parser==1.28.3 in /Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages (from glean_sdk~=32.3.1) (1.28.3)
Requirement already satisfied: pycparser in /Users/greg/Library/Python/3.7/lib/python/site-packages (from cffi>=1->glean_sdk~=32.3.1) (2.20)
Requirement already satisfied: Jinja2>=2.10.1 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (2.11.2)
Requirement already satisfied: PyYAML>=3.13 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (5.3)
Requirement already satisfied: Click>=7 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (7.1.2)
Requirement already satisfied: diskcache>=4 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (4.1.0)
Requirement already satisfied: yamllint>=1.18.0 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (1.24.2)
Requirement already satisfied: appdirs>=1.4 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (1.4.4)
Requirement already satisfied: jsonschema>=3.0.2 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (3.2.0)
Requirement already satisfied: MarkupSafe>=0.23 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from Jinja2>=2.10.1->glean-parser==1.28.3->glean_sdk~=32.3.1) (1.1.1)
Requirement already satisfied: pathspec>=0.5.3 in /Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages (from yamllint>=1.18.0->glean-parser==1.28.3->glean_sdk~=32.3.1) (0.8.0)
Requirement already satisfied: six>=1.11.0 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (1.15.0)
Requirement already satisfied: pyrsistent>=0.14.0 in /Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (0.17.3)
Requirement already satisfied: setuptools in /Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (49.6.0)
Requirement already satisfied: attrs>=17.4.0 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (19.3.0)
WARNING: You are using pip version 20.1; however, version 20.2.4 is available.
You should consider upgrading via the '/Users/greg/.mozbuild/_virtualenvs/mach/bin/python -m pip install --upgrade pip' command.~/dev/platform-gecko2 at 14:58:28
➤  ~/.mozbuild/_virtualenvs/mach/bin/python -c 'import glean'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages/glean/__init__.py", line 17, in <module>
    from .glean import Glean
  File "/Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages/glean/glean.py", line 22, in <module>
    from .config import Configuration
  File "/Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages/glean/config.py", line 13, in <module>
    from . import net
  File "/Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages/glean/net/__init__.py", line 14, in <module>
    from .ping_upload_worker import PingUploadWorker
  File "/Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages/glean/net/ping_upload_worker.py", line 14, in <module>
    from .upload_task_tag import UploadTaskTag
  File "/Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages/glean/net/upload_task_tag.py", line 8, in <module>
    from .. import _ffi
  File "/Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages/glean/_ffi.py", line 14, in <module>
    from ._glean_ffi import ffi  # type: ignore
  File "/Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages/glean/_glean_ffi.py", line 2, in <module>
    import _cffi_backend
ModuleNotFoundError: No module named '_cffi_backend'
Component: General → Glean: SDK
Product: Firefox Build System → Data Platform and Tools
Summary: Glean could not be found, so telemetry will not be reported → ModuleNotFoundError: No module named '_cffi_backend' trying to `import glean`

_cffi_backend is a shared object that ships with the cffi python package. Does import _cffi_backend work on its own (in the same environment).

Is there _cffi_backend * .dylib in the PYTHONPATH?

_cffi_backend is a shared object that ships with the cffi python package. Does import _cffi_backend work on its own (in the same environment).

It doesn't appear to load, but the cffi package does.

➤ ~/.mozbuild/_virtualenvs/mach/bin/python -c 'import _cffi_backend'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named '_cffi_backend'

Is there _cffi_backend * .dylib in the PYTHONPATH?

Here's what I've got:

➤ echo $PYTHONPATH
/Users/greg/Library/Python/3.7/lib/python/site-packages:
~/dev/platform-gecko2 at 15:47:06
➤ ~/.mozbuild/_virtualenvs/mach/bin/python -c 'import sys; print(sys.path)'
['', '/Users/greg/Library/Python/3.7/lib/python/site-packages', '/Users/greg/dev/platform-gecko2', '/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python38.zip', '/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8', '/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload', '/Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages']

Is there a _cffi_backend.*.dylib in any of those paths in sys.path? If not, the cffi package has been installed incorrectly and maybe needs a force reinstall. Relevant is the message that pip reports it as already being installed when mach bootstrap runs.

I first tried:

pip uninstall cffi
pip install cffi

This first attempt still reproduces the error.

The second attempt I did the following which fixed the error:

pip uninstall cffi
./mach bootstrap
Your version of Python 3 (3.8.6) is new enough.
Your version of Python 2 (2.7.17) is new enough.
created virtual environment CPython3.8.6.final.0-64 in 304ms
  creator CPython3Posix(dest=/Users/greg/.mozbuild/_virtualenvs/mach, clear=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/greg/Library/Application Support/virtualenv)
    added seed packages: pip==20.2.2, setuptools==49.6.0, wheel==0.35.1
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
running build_ext
copying build/lib.macosx-10.15-x86_64-3.8/psutil/_psutil_osx.cpython-38-darwin.so -> psutil
copying build/lib.macosx-10.15-x86_64-3.8/psutil/_psutil_posix.cpython-38-darwin.so -> psutil

Error processing command. Ignoring because optional. (optional:packages.txt:comm/build/virtualenv_packages.txt)
Collecting zstandard<=0.13.0,>=0.9.0
  Using cached zstandard-0.13.0-cp38-cp38-macosx_10_9_x86_64.whl (460 kB)
Installing collected packages: zstandard
Successfully installed zstandard-0.13.0
Collecting glean_sdk~=32.3.1
  Using cached glean_sdk-32.3.2-cp36-abi3-macosx_10_7_x86_64.whl (789 kB)
Collecting glean-parser==1.28.3
  Using cached glean_parser-1.28.3-py3-none-any.whl (56 kB)
Collecting cffi>=1
  Using cached cffi-1.14.3-2-cp38-cp38-macosx_10_9_x86_64.whl (176 kB)
Requirement already satisfied: PyYAML>=3.13 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (5.3)
Requirement already satisfied: jsonschema>=3.0.2 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (3.2.0)
Requirement already satisfied: appdirs>=1.4 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (1.4.4)
Requirement already satisfied: yamllint>=1.18.0 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (1.24.2)
Requirement already satisfied: diskcache>=4 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (4.1.0)
Requirement already satisfied: Click>=7 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (7.1.2)
Requirement already satisfied: Jinja2>=2.10.1 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (2.11.2)
Requirement already satisfied: pycparser in /Users/greg/Library/Python/3.7/lib/python/site-packages (from cffi>=1->glean_sdk~=32.3.1) (2.20)
Requirement already satisfied: setuptools in /Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (49.6.0)
Requirement already satisfied: attrs>=17.4.0 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (19.3.0)
Processing /Users/greg/Library/Caches/pip/wheels/3d/22/08/7042eb6309c650c7b53615d5df5cc61f1ea9680e7edd3a08d2/pyrsistent-0.17.3-cp38-cp38-macosx_10_15_x86_64.whl
Requirement already satisfied: six>=1.11.0 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (1.15.0)
Collecting pathspec>=0.5.3
  Using cached pathspec-0.8.0-py2.py3-none-any.whl (28 kB)
Requirement already satisfied: MarkupSafe>=0.23 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from Jinja2>=2.10.1->glean-parser==1.28.3->glean_sdk~=32.3.1) (1.1.1)
Installing collected packages: glean-parser, cffi, glean-sdk, pyrsistent, pathspec
  Attempting uninstall: glean-parser
    Found existing installation: glean-parser 1.28.6
    Not uninstalling glean-parser at /Users/greg/Library/Python/3.7/lib/python/site-packages, outside environment /Users/greg/.mozbuild/_virtualenvs/mach
    Can't uninstall 'glean-parser'. No files were found to uninstall.
  Attempting uninstall: glean-sdk
    Found existing installation: glean-sdk 33.0.4
    Not uninstalling glean-sdk at /Users/greg/Library/Python/3.7/lib/python/site-packages, outside environment /Users/greg/.mozbuild/_virtualenvs/mach
    Can't uninstall 'glean-sdk'. No files were found to uninstall.
Successfully installed cffi-1.14.3 glean-parser-1.28.3 glean-sdk-32.3.2 pathspec-0.8.0 pyrsistent-0.17.3
...

This fixed the error 🎉

I'm a bit surprised how much my local pip installations affect the tooling. Is there a reason why we don't install all of the packages in the virtualenv, rather than use the more brittle and variable packages in the user space? moz-phab is also relying on glean, so I need things installed in my user packages as well.

Given that we have a fix, I'm closing this.

We DO install all of the packages in the virtualenv. Your local installation shouldn't affect the virtualenv whatsoever. If it is, that's either an issue in the way we're interfacing with virtualenv and/or pip, or an issue with your Python environment. I DO have cffi installed in my global Python environment, and it doesn't break my virtualenv in the way you've described, so I'm inclined to think that it's the latter... but if we can reproduce this issue on someone else's machine then maybe we can revisit this.

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → WORKSFORME

I guess I don't understand why in the mach bootstrap it would be considering anything in my user directory:

For instance, my log above shows:

Collecting glean_sdk~=32.3.1
  Using cached glean_sdk-32.3.2-cp36-abi3-macosx_10_7_x86_64.whl (789 kB)
Requirement already satisfied: cffi>=1 in /Users/greg/Library/Python/3.7/lib/python/site-packages (

I'm trying to intentionally create this behavior again, and it's not reproducing.

Perhaps because it's inheriting my $PYTHONPATH configuration?

➤ echo $PYTHONPATH
/Users/greg/Library/Python/3.7/lib/python/site-packages:

I guess I don't understand why in the mach bootstrap it would be considering anything in my user directory:

It doesn't. mach bootstrap just defers to pip to install glean-sdk.

Perhaps because it's inheriting my $PYTHONPATH configuration?

I could see that making a difference. Unless you have your PYTHONPATH set globally for a particular reason (if you're using the system Python or one installed with Homebrew, I don't see why you would), you might want to clear that, or at least do so when you're trying to work with mozilla-central.

Ok, I believe having a $PYTHONPATH set is the root cause here. I re-ran mach bootstrap after un-setting it and it no longer considered my user packages.

Here is the bad behavior, with $PYTHONPATH set, and considering my user packages.


➤ ./mach bootstrap

Collecting glean-parser==1.28.3
  Using cached glean_parser-1.28.3-py3-none-any.whl (56 kB)
Requirement already satisfied: pycparser in /Users/greg/Library/Python/3.7/lib/python/site-packages (from cffi>=1->glean_sdk~=32.3.1) (2.20)
Requirement already satisfied: appdirs>=1.4 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (1.4.4)
Requirement already satisfied: PyYAML>=3.13 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (5.3)
Requirement already satisfied: yamllint>=1.18.0 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (1.24.2)
Requirement already satisfied: diskcache>=4 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (4.1.0)
Requirement already satisfied: Click>=7 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (7.1.2)
Requirement already satisfied: Jinja2>=2.10.1 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (2.11.2)
Requirement already satisfied: jsonschema>=3.0.2 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from glean-parser==1.28.3->glean_sdk~=32.3.1) (3.2.0)
Collecting pathspec>=0.5.3
  Using cached pathspec-0.8.0-py2.py3-none-any.whl (28 kB)
Requirement already satisfied: MarkupSafe>=0.23 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from Jinja2>=2.10.1->glean-parser==1.28.3->glean_sdk~=32.3.1) (1.1.1)
Requirement already satisfied: attrs>=17.4.0 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (19.3.0)
Requirement already satisfied: six>=1.11.0 in /Users/greg/Library/Python/3.7/lib/python/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (1.15.0)
Processing /Users/greg/Library/Caches/pip/wheels/3d/22/08/7042eb6309c650c7b53615d5df5cc61f1ea9680e7edd3a08d2/pyrsistent-0.17.3-cp38-cp38-macosx_10_15_x86_64.whl
Requirement already satisfied: setuptools in /Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (49.6.0)
Installing collected packages: cffi, glean-parser, glean-sdk, pathspec, pyrsistent
  Attempting uninstall: glean-parser
    Found existing installation: glean-parser 1.28.6
    Not uninstalling glean-parser at /Users/greg/Library/Python/3.7/lib/python/site-packages, outside environment /Users/greg/.mozbuild/_virtualenvs/mach
    Can't uninstall 'glean-parser'. No files were found to uninstall.
  Attempting uninstall: glean-sdk
    Found existing installation: glean-sdk 33.0.4
    Not uninstalling glean-sdk at /Users/greg/Library/Python/3.7/lib/python/site-packages, outside environment /Users/greg/.mozbuild/_virtualenvs/mach
    Can't uninstall 'glean-sdk'. No files were found to uninstall.
Successfully installed cffi-1.14.3 glean-parser-1.28.3 glean-sdk-32.3.2 pathspec-0.8.0 pyrsistent-0.17.3

Then here is another run where I unset it:


➤ unset PYTHONPATH
➤ ./mach bootstrap

...

Collecting glean_sdk~=32.3.1
  Using cached glean_sdk-32.3.2-cp36-abi3-macosx_10_7_x86_64.whl (789 kB)
Collecting cffi>=1
  Using cached cffi-1.14.3-2-cp38-cp38-macosx_10_9_x86_64.whl (176 kB)
Collecting glean-parser==1.28.3
  Using cached glean_parser-1.28.3-py3-none-any.whl (56 kB)
Collecting pycparser
  Using cached pycparser-2.20-py2.py3-none-any.whl (112 kB)
Collecting Click>=7
  Using cached click-7.1.2-py2.py3-none-any.whl (82 kB)
Collecting Jinja2>=2.10.1
  Using cached Jinja2-2.11.2-py2.py3-none-any.whl (125 kB)
Collecting appdirs>=1.4
  Using cached appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)
Processing /Users/greg/Library/Caches/pip/wheels/13/90/db/290ab3a34f2ef0b5a0f89235dc2d40fea83e77de84ed2dc05c/PyYAML-5.3.1-cp38-cp38-macosx_10_15_x86_64.whl
Collecting jsonschema>=3.0.2
  Using cached jsonschema-3.2.0-py2.py3-none-any.whl (56 kB)
Collecting diskcache>=4
  Downloading diskcache-5.0.3-py3-none-any.whl (43 kB)
     |████████████████████████████████| 43 kB 1.4 MB/s 
Collecting yamllint>=1.18.0
  Downloading yamllint-1.25.0-py2.py3-none-any.whl (60 kB)
     |████████████████████████████████| 60 kB 3.6 MB/s 
Collecting MarkupSafe>=0.23
  Downloading MarkupSafe-1.1.1-cp38-cp38-macosx_10_9_x86_64.whl (16 kB)
Collecting six>=1.11.0
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting attrs>=17.4.0
  Using cached attrs-20.2.0-py2.py3-none-any.whl (48 kB)
Requirement already satisfied: setuptools in /Users/greg/.mozbuild/_virtualenvs/mach/lib/python3.8/site-packages (from jsonschema>=3.0.2->glean-parser==1.28.3->glean_sdk~=32.3.1) (49.6.0)
Processing /Users/greg/Library/Caches/pip/wheels/3d/22/08/7042eb6309c650c7b53615d5df5cc61f1ea9680e7edd3a08d2/pyrsistent-0.17.3-cp38-cp38-macosx_10_15_x86_64.whl
Collecting pathspec>=0.5.3
  Using cached pathspec-0.8.0-py2.py3-none-any.whl (28 kB)
Installing collected packages: pycparser, cffi, Click, MarkupSafe, Jinja2, appdirs, PyYAML, six, attrs, pyrsistent, jsonschema, diskcache, pathspec, yamllint, glean-parser, glean-sdk
Successfully installed Click-7.1.2 Jinja2-2.11.2 MarkupSafe-1.1.1 PyYAML-5.3.1 appdirs-1.4.4 attrs-20.2.0 cffi-1.14.3 diskcache-5.0.3 glean-parser-1.28.3 glean-sdk-32.3.2 jsonschema-3.2.0 pathspec-0.8.0 pycparser-2.20 pyrsistent-0.17.3 six-1.15.0 yamllint-1.25.0

I guess, my feedback here is it would be good to protect users from this issue if possible. At the very least warning a user who runs mach bootstrap that they have this variable set, and it can create undefined behavior. I believe I set the PYTHONPATH to fix other issues related to python 2 vs python 3 on my system. My hg evolve package is broken with this unset. I will now try and fix that issue... Thanks for your help with me sorting this out!

I followed up here with: Bug 1674189

You need to log in before you can comment on or make changes to this bug.