Closed Bug 1644845 Opened 4 years ago Closed 4 years ago

Unable to build with python 2.7/3.5 on Ubuntu 16.04 LTS

Categories

(Firefox Build System :: General, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: kats, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [solution in comment 10])

Attachments

(1 file)

Full output attached. Basically, updated to latest m-c. The configure step fails because it picks up my py3.5 installation instead of my py2.7 installation. It says to run bootstrap to fix this, so I do. bootstrap fails to do anything about Python and then craps out trying to download toolchains.

Install a Python > 3.6 to get the build to succeed. (The error message says 2.7 should work, I know; this is untrue, you need Python 3 to build.)

Another issue is that bootstrap isn't installing Python 3.6 for you, I think because it thinks your Python 2 is up to date (but that doesn't matter because you need Python 3). That should also be fixed, I'll work on that.

Severity: -- → S3
Priority: -- → P3

Oh, wait, I missed the bit about Ubuntu 16.04. Yeah, as of bug 1622963, you are going to need Python 3.6 going forward (and as you can imagine we can't install Python 3.6 for you if your system package manager doesn't allow you to).

I built python 3.6.3 from source into a local user dir (didn't run make install yet) and tried to convince ./mach build to use that by setting the PYTHON and PYTHON3 env vars both from command line and .mozconfig. None of that worked, I get the same error as before. Also tried setting MOZ_CONFIGURE_TRACE=1 in my env, hoping to activate some of the log.debug lines in build/moz.configure/init.configure but that didn't produce any new output. For now I'm just going to locally revert bug 1622963 but I'm happy to try other things.

(In reply to Ricky Stewart from comment #3)

we can't install Python 3.5 for you if your system package manager doesn't allow you to.

Any chance you can build from source into ~/.mozbuild and do the magic that makes mach use it?

Building, bundling, and distributing Python isn't something that's in the cards for the build team right now.

If you do PYTHON3=$PATH_TO_YOUR_PYTHON3 ./mach configure followed by a mach build, it should work fine.

You can also set this from your mozconfig with ac_add_options PYTHON3=$PATH_TO_YOUR_PYTHON3.

(In reply to Ricky Stewart from comment #6)

Building, bundling, and distributing Python isn't something that's in the cards for the build team right now.

If you do PYTHON3=$PATH_TO_YOUR_PYTHON3 ./mach configure followed by a mach build, it should work fine.

This didn't work. I ended up doing sudo make install on the python 3.6.3 build, which installed it to the system properly AFAICT. (Running python3 -V says 3.6.3). However, when I run ./mach build or ./mach configure now I get:

$ ./mach configure
Traceback (most recent call last):
  File "./mach", line 226, in <module>
    main(sys.argv[1:])
  File "./mach", line 218, in main
    mach = get_mach()
  File "./mach", line 208, in get_mach
    mach = check_and_get_mach(dir_path)
  File "./mach", line 164, in check_and_get_mach
    return load_mach(dir_path, mach_path)
  File "./mach", line 152, in load_mach
    return mach_bootstrap.bootstrap(dir_path)
  File "/home/kats/zspace/gecko-tests/build/mach_bootstrap.py", line 443, in bootstrap
    driver.load_commands_from_file(os.path.join(mozilla_dir, path))
  File "/home/kats/zspace/gecko-tests/python/mach/mach/main.py", line 267, in load_commands_from_file
    imp.load_source(module_name, path)
  File "/usr/local/lib/python3.6/imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 684, in _load
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/kats/zspace/gecko-tests/remote/mach_commands.py", line 36, in <module>
    import mozprofile
  File "/home/kats/zspace/gecko-tests/build/mach_bootstrap.py", line 475, in __call__
    module = self._original_import(name, globals, locals, fromlist, level)
  File "/home/kats/zspace/gecko-tests/testing/mozbase/mozprofile/mozprofile/__init__.py", line 17, in <module>
    from mozprofile.cli import *
  File "/home/kats/zspace/gecko-tests/build/mach_bootstrap.py", line 475, in __call__
    module = self._original_import(name, globals, locals, fromlist, level)
  File "/home/kats/zspace/gecko-tests/testing/mozbase/mozprofile/mozprofile/cli.py", line 18, in <module>
    from .profile import FirefoxProfile
  File "/home/kats/zspace/gecko-tests/build/mach_bootstrap.py", line 475, in __call__
    module = self._original_import(name, globals, locals, fromlist, level)
  File "/home/kats/zspace/gecko-tests/testing/mozbase/mozprofile/mozprofile/profile.py", line 20, in <module>
    from .permissions import Permissions
  File "/home/kats/zspace/gecko-tests/build/mach_bootstrap.py", line 475, in __call__
    module = self._original_import(name, globals, locals, fromlist, level)
  File "/home/kats/zspace/gecko-tests/testing/mozbase/mozprofile/mozprofile/permissions.py", line 14, in <module>
    import sqlite3
  File "/home/kats/zspace/gecko-tests/build/mach_bootstrap.py", line 475, in __call__
    module = self._original_import(name, globals, locals, fromlist, level)
  File "/usr/local/lib/python3.6/sqlite3/__init__.py", line 23, in <module>
    from sqlite3.dbapi2 import *
  File "/home/kats/zspace/gecko-tests/build/mach_bootstrap.py", line 475, in __call__
    module = self._original_import(name, globals, locals, fromlist, level)
  File "/usr/local/lib/python3.6/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
  File "/home/kats/zspace/gecko-tests/build/mach_bootstrap.py", line 475, in __call__
    module = self._original_import(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named '_sqlite3'

This didn't work.

When you say "this didn't work", what does that mean? Need much more information than that if we're supposed to fix things :)

The stacktrace you posted just looks like one of the typical problems that will come from building/installing Python from source, which is that Python is actually an awfully complicated piece of software and building a working version at the same feature parity as versions that are distributed with OS's is very difficult. In this case it looks like you haven't built the sqlite package correctly. (As you can imagine, I can't help you get a working local build of Python 3.)

Is there a reason you can't just update your OS to one that allows you to install a modern version of Python?

(In reply to Ricky Stewart from comment #8)

This didn't work.

When you say "this didn't work", what does that mean? Need much more information than that if we're supposed to fix things :)

Same problem as initially reported. It seemed like it's just ignoring all my attempts to get it to use a custom Python. Debugging this would be a lot easier if there was a way to get debug logs from the configure modules, like with --verbose or something. Every time I run into python problems in the build system I have to resort to adding garbage in the scripts to debug by backtrace/exception.

The stacktrace you posted just looks like one of the typical problems that will come from building/installing Python from source, which is that Python is actually an awfully complicated piece of software and building a working version at the same feature parity as versions that are distributed with OS's is very difficult. In this case it looks like you haven't built the sqlite package correctly. (As you can imagine, I can't help you get a working local build of Python 3.)

Ok, I can at least iterate on this by configuring Python.

Is there a reason you can't just update your OS to one that allows you to install a modern version of Python?

In general doing that loses me at least a week so I'd like to avoid it.

So there's been a bunch of issues identified in this bug so far (e.g. mach incorrectly reporting py2.7 is sufficient for building) but I'm going to downscope this bug to be more specific, and here's what I did to get it working (writing these steps retroactively, so hopefully there's no typos):

sudo apt install libsqlite3-dev
mkdir ~/tmp/python-bld && pushd ~/tmp/python-bld
wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
tar xzf Python-3.6.3.tgz
cd Python-3.6.3
./configure && make
sudo make install
python3 -V # verify it reports 3.6.3

Then do a clobber build

Regressed by: 1622963
Summary: Python version checks are inconsistent, can't detect useful python → Unable to build with python 2.7/3.5 on Ubuntu 16.04 LTS
Whiteboard: [solution in comment 10]

(I'm removing the "Regression" bug here because this isn't a regression. Not building with Python 3.5 is an expected consequence of bug 1622963, and none of the issues identified here exist because of that bug, but instead have been around for a while and only became apparent due to that bug.)

No longer regressed by: 1622963

Try pyenv (https://github.com/pyenv/pyenv) instead of building python yourself.

Thanks, I'll try that if I run into more problems. Closing bug as WONTFIX since there's no changes to be made to in-tree scripts, at least for this particular issue.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WONTFIX
See Also: → 1644887
See Also: → 1644892

(In reply to Ricky Stewart from comment #6)

You can also set this from your mozconfig with ac_add_options PYTHON3=$PATH_TO_YOUR_PYTHON3.

This results in mozbuild.configure.options.InvalidOptionError: Unknown option: PYTHON3

Things seem to progress more with this in my .mozconfig:

mk_add_options "export PYTHON3=/usr/bin/python3.6"

But after getting the artifacts…

 0:04.61 /usr/bin/python3.6: Error while finding module specification for 'mozbuild.action.preprocessor' (ModuleNotFoundError: No module named 'mozbuild')
 0:04.61 /media/firefox-dev/bffc283f-5722-4980-9c7d-3eb5053bcb86/mozilla-central/config/rules.mk:1161: recipe for target '.cargo/config' failed
 0:04.61 make[2]: *** [.cargo/config] Error 1
 0:04.61 make[2]: *** Waiting for unfinished jobs....
 0:04.63 /usr/bin/python3.6: Error while finding module specification for 'mozbuild.action.process_install_manifest' (ModuleNotFoundError: No module named 'mozbuild')
 0:04.63 Makefile:104: recipe for target 'install-dist/include' failed
 0:04.64 make[3]: *** [install-dist/include] Error 1
 0:04.64 make[3]: *** Waiting for unfinished jobs....

It sounds like your tree is relatively old. Try with current mozilla-central.

I'm on latest https://hg.mozilla.org/mozilla-central/

firefox-dev@firefox-dev:~/dev/mozilla-central$ hg id
d25dfe67b69e tip

firefox-dev@firefox-dev:~/dev/mozilla-central$ hg log -l 1
changeset:   537520:d25dfe67b69e
tag:         tip
user:        David Major
date:        Thu Jun 25 19:30:52 2020 +0000
summary:     Bug 1648541 - Rename details namespace in SPSCQueue r=froydnj

firefox-dev@firefox-dev:~/dev/mozilla-central$ ./mach build --verbose
…
 0:05.21 /usr/bin/make recurse_pre-export
 0:05.25 make[3]: Entering directory '/media/firefox-dev/bffc283f-5722-4980-9c7d-3eb5053bcb86/mozilla-central/obj-x86_64-pc-linux-gnu'
 0:05.25 /usr/bin/python3.6 -m mozbuild.action.process_install_manifest --track install_dist_include.track dist/include _build_manifests/install/dist_include
 0:05.25 /usr/bin/python3.6 -m mozbuild.action.process_install_manifest --track install_dist_private.track dist/private _build_manifests/install/dist_private
 0:05.25 /usr/bin/python3.6 -m mozbuild.action.process_install_manifest --track install_dist_public.track dist/public _build_manifests/install/dist_public
 0:05.26 /usr/bin/python3.6 -m mozbuild.action.process_install_manifest --track install_dist_xpi-stage.track dist/xpi-stage _build_manifests/install/dist_xpi-stage
 0:05.28 /usr/bin/python3.6: Error while finding module specification for 'mozbuild.action.process_install_manifest' (ModuleNotFoundError: No module named 'mozbuild')
 0:05.28 /usr/bin/python3.6: Error while finding module specification for 'mozbuild.action.process_install_manifest' (ModuleNotFoundError: No module named 'mozbuild')
 0:05.28 Makefile:104: recipe for target 'install-dist/include' failed
 0:05.28 make[3]: *** [install-dist/include] Error 1
 0:05.28 make[3]: *** Waiting for unfinished jobs....
 0:05.28 Makefile:104: recipe for target 'install-dist/private' failed
 0:05.28 make[3]: *** [install-dist/private] Error 1
 0:05.28 /usr/bin/python3.6: Error while finding module specification for 'mozbuild.action.process_install_manifest' (ModuleNotFoundError: No module named 'mozbuild')
 0:05.28 Makefile:104: recipe for target 'install-dist/public' failed
 0:05.28 make[3]: *** [install-dist/public] Error 1
 0:05.29 /usr/bin/python3.6: Error while finding module specification for 'mozbuild.action.process_install_manifest' (ModuleNotFoundError: No module named 'mozbuild')
 0:05.30 Makefile:104: recipe for target 'install-dist/xpi-stage' failed
 0:05.30 make[3]: *** [install-dist/xpi-stage] Error 1
 0:05.30 make[3]: Leaving directory '/media/firefox-dev/bffc283f-5722-4980-9c7d-3eb5053bcb86/mozilla-central/obj-x86_64-pc-linux-gnu'
 0:05.30 /media/firefox-dev/bffc283f-5722-4980-9c7d-3eb5053bcb86/mozilla-central/config/recurse.mk:32: recipe for target 'pre-export' failed
 0:05.30 make[2]: *** [pre-export] Error 2
 0:05.30 make[2]: Leaving directory '/media/firefox-dev/bffc283f-5722-4980-9c7d-3eb5053bcb86/mozilla-central/obj-x86_64-pc-linux-gnu'
 0:05.30 /media/firefox-dev/bffc283f-5722-4980-9c7d-3eb5053bcb86/mozilla-central/config/rules.mk:390: recipe for target 'default' failed
 0:05.30 make[1]: *** [default] Error 2
 0:05.30 make[1]: Leaving directory '/media/firefox-dev/bffc283f-5722-4980-9c7d-3eb5053bcb86/mozilla-central/obj-x86_64-pc-linux-gnu'
 0:05.30 client.mk:125: recipe for target 'build' failed
 0:05.30 make: *** [build] Error 2

I eventually got things working with an export PYTHONPATH not as mk_add_options

firefox-dev@firefox-dev:~/dev/mozilla-central$ export PYTHONPATH=~/dev/mozilla-central/python/mozbuild:~/dev/mozilla-central/third_party/python/six:~/dev/mozilla-central/third_party/python/jsmin:~/dev/mozilla-central/build:~/dev/mozilla-central/python/mach:~/dev/mozilla-central/testing/mozbase/mozprocess:~/dev/mozilla-central/python/mozboot:~/dev/mozilla-central/testing/mozbase/mozfile:~/dev/mozilla-central/python/mozversioncontrol:~/dev/mozilla-central/config

firefox-dev@firefox-dev:~/dev/mozilla-central$ ./mach build
…
 0:06.80 Your build was successful!

You're shooting yourself in the foot with:

mk_add_options "export PYTHON3=/usr/bin/python3.6"

Use

export PYTHON3=...

or

ac_add_options PYTHON3=...

Needless to say, you shouldn't set PYTHONPATH.

mk_add_options "export PYTHON3=/usr/bin/python3.6" was to get ./mach configure working as otherwise:

 0:00.43 ERROR: One of the following Python versions are required:
 0:00.43 ERROR: * Python 2.7.3 or greater
 0:00.43 ERROR: * Python 3.6.0 or greater
 0:00.43 ERROR: You are running Python 3.5.2.

But indeed, getting rid of the mk_add_options avoids needing to set PYTHONPATH.

However, ac_add_options PYTHON3=/usr/bin/python3.6 results in mozbuild.configure.options.InvalidOptionError: Unknown option: PYTHON3

So to summarize:

  • don't modify .mozconfig
  • run PYTHON3=/usr/bin/python3.6 ./mach configure then plain ./mach build

export PYTHON3=... in .mozconfig should work.

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

Attachment

General

Created:
Updated:
Size: