From 8639df65cbd0a30ac4ed5df426a64fa428b0f5ad Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone <exarkun@twistedmatrix.com> Date: Fri, 18 Nov 2022 10:00:04 -0500 Subject: [PATCH] some notes and syntax error "fixes" --- flake.nix | 189 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 150 insertions(+), 39 deletions(-) diff --git a/flake.nix b/flake.nix index 034fc6d..32c0376 100644 --- a/flake.nix +++ b/flake.nix @@ -211,43 +211,154 @@ nativeBuildInputs = with pkgs; getBuildInputs (drv: drv.nativeBuildInputs) [ openssl libffi python39 ]; }; - } // { - packages.aarch64-android.host-python310 = (pkgs.pkgsCross.aarch64-android.python310.override { - # Turn off all the things. Each one might be broken for - # cross-compilation and even if not we don't need them for this build - # Python. We just need it to report the right platform info. - mimetypesSupport = false; - x11Support = false; - bluezSupport = false; - sqlite = null; - openssl = null; - tzdata = null; - readline = null; - }).overrideAttrs (old: { - # Turn off even more things which aren't parameters to the Python - # expression. - - # These drag in an aarch64-android bash which fails to build. - preFixup = null; - postPatch = null; - - # This drags in a -lcrypt dependency which isn't satisfied by Google - # Android Bionic. - LIBS = null; - }); - - # packages.aarch64-android.zfec = self.packages.aarch64-android.host-python310.buildPythonPackage; - # let - # build-python = pkgs.pkgsCross.${system}.python310; - # host-python = pkgs.pkgsCross.aarch64-android.python310; - - # build-pyenv = build-python.withPackages (ps: [ (ps.callPackage ./crossenv.nix) ]); - # in - # pkgs.mkDerivation { - # name = "python3.10-zfec"; - # version = "2.3.4"; # XXX - - # src = fetchPypi - # }; - }); + }) // { + + # Python cross-compilation notes. + # + # You can get a lot of cross-compiled stuff out of nixpkgs beneath + # `pkgsCross`. For example, + # + # pkgsCross.aarch64-android.python3Minimal + # + # is just what the name says. This builds fine with only one small + # change against current nixpkgs. However, its extension modules have a + # harder time. For example, + # + # pkgsCross.aarch64-android.python3Minimal.pkgs.zfec + # + # fails to build because: + # + # running bdist_wheel + # Traceback (most recent call last): + # File "/build/wheel-0.37.1-source/nix_run_setup", line 8, in <module> + # exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec')) + # File "setup.py", line 4, in <module> + # setup(maintainer=u'Alex Grönholm') + # File "/nix/store/azdg3l16q2d03g8drgr94bg1069mfzpq-python3.10-bootstrapped-pip-22.2.2/lib/python3.10/site-packages/setuptools/__init__.py", line 87, in setup + # return distutils.core.setup(**attrs) + # File "/nix/store/azdg3l16q2d03g8drgr94bg1069mfzpq-python3.10-bootstrapped-pip-22.2.2/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup + # return run_commands(dist) + # File "/nix/store/azdg3l16q2d03g8drgr94bg1069mfzpq-python3.10-bootstrapped-pip-22.2.2/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands + # dist.run_commands() + # File "/nix/store/azdg3l16q2d03g8drgr94bg1069mfzpq-python3.10-bootstrapped-pip-22.2.2/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 973, in run_commands + # self.run_command(cmd) + # File "/nix/store/azdg3l16q2d03g8drgr94bg1069mfzpq-python3.10-bootstrapped-pip-22.2.2/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command + # super().run_command(command) + # File "/nix/store/azdg3l16q2d03g8drgr94bg1069mfzpq-python3.10-bootstrapped-pip-22.2.2/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 992, in run_command + # cmd_obj.run() + # File "/nix/store/azdg3l16q2d03g8drgr94bg1069mfzpq-python3.10-bootstrapped-pip-22.2.2/lib/python3.10/site-packages/wheel/bdist_wheel.py", line 295, in run + # build_ext = self.reinitialize_command('build_ext') + # File "/nix/store/azdg3l16q2d03g8drgr94bg1069mfzpq-python3.10-bootstrapped-pip-22.2.2/lib/python3.10/site-packages/setuptools/__init__.py", line 200, in reinitialize_command + # cmd = _Command.reinitialize_command(self, command, reinit_subcommands) + # File "/nix/store/azdg3l16q2d03g8drgr94bg1069mfzpq-python3.10-bootstrapped-pip-22.2.2/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 312, in reinitialize_command + # return self.distribution.reinitialize_command(command, reinit_subcommands) + # File "/nix/store/azdg3l16q2d03g8drgr94bg1069mfzpq-python3.10-bootstrapped-pip-22.2.2/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 945, in reinitialize_command + # command = self.get_command_obj(command_name) + # File "/nix/store/azdg3l16q2d03g8drgr94bg1069mfzpq-python3.10-bootstrapped-pip-22.2.2/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 864, in get_command_obj + # klass = self.get_command_class(command) + # File "/nix/store/azdg3l16q2d03g8drgr94bg1069mfzpq-python3.10-bootstrapped-pip-22.2.2/lib/python3.10/site-packages/setuptools/dist.py", line 954, in get_command_class + # self.cmdclass[command] = cmdclass = ep.load() + # File "/nix/store/537cvh8mqdaglc0an8ndmzszllh1lwac-python3-minimal-3.10.8/lib/python3.10/importlib/metadata/__init__.py", line 171, in load + # module = import_module(match.group('module')) + # File "/nix/store/537cvh8mqdaglc0an8ndmzszllh1lwac-python3-minimal-3.10.8/lib/python3.10/importlib/__init__.py", line 126, in import_module + # return _bootstrap._gcd_import(name[level:], package, level) + # File "<frozen importlib._bootstrap>", line 1050, in _gcd_import + # File "<frozen importlib._bootstrap>", line 1027, in _find_and_load + # File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked + # File "<frozen importlib._bootstrap>", line 688, in _load_unlocked + # File "<frozen importlib._bootstrap_external>", line 883, in exec_module + # File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed + # File "/nix/store/azdg3l16q2d03g8drgr94bg1069mfzpq-python3.10-bootstrapped-pip-22.2.2/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 26, in <module> + # get_config_var("LDSHARED") + # File "/nix/store/azdg3l16q2d03g8drgr94bg1069mfzpq-python3.10-bootstrapped-pip-22.2.2/lib/python3.10/site-packages/setuptools/_distutils/sysconfig.py", line 574, in get_config_var + # return get_config_vars().get(name) + # File "/nix/store/azdg3l16q2d03g8drgr94bg1069mfzpq-python3.10-bootstrapped-pip-22.2.2/lib/python3.10/site-packages/setuptools/_distutils/sysconfig.py", line 553, in get_config_vars + # _config_vars = sysconfig.get_config_vars().copy() + # File "/nix/store/537cvh8mqdaglc0an8ndmzszllh1lwac-python3-minimal-3.10.8/lib/python3.10/sysconfig.py", line 615, in get_config_vars + # _init_posix(_CONFIG_VARS) + # File "/nix/store/537cvh8mqdaglc0an8ndmzszllh1lwac-python3-minimal-3.10.8/lib/python3.10/sysconfig.py", line 477, in _init_posix + # _temp = __import__(name, globals(), locals(), ['build_time_vars'], 0) + # ModuleNotFoundError: No module named '_sysconfigdata__linux_aarch64-linux-android' + # + # Notice that the *build* Python + # (537cvh8mqdaglc0an8ndmzszllh1lwac-python3-minimal-3.10.8) is trying to + # load sysconfigdata for the *host* Python - presumably so it can + # compile the extension correctly. However, the host Python + # sysconfigdata module appears to be unavailable to the build Python. + # + # Why? The nixpkgs CPython expression writes the sysconfigdata module + # for both Pythons (build and host). It has ``sysconfigdataHook`` that + # goes to a lot of trouble to compute the right parameters for the host + # Python and write the data to a properly named source file. + # + # However, the build Python and host Pythons each only get one of these + # modules. For the build Python it is: + # + # _sysconfigdata__linux_x86_64-linux-gnu.py + # + # and the host Python gets: + # + # _sysconfigdata__linux_.py + # + # Each of these contains information which is apparently correct for + # their respective runtime systems. Then, the nixpkgs CPython + # expression for building the extension module uses "bootstrap pip" + # which will respect PYTHONPATH for module search. + # + # (Q) Does something put the host Python's _sysconfigdata__linux_.py on + # the build Python's PYTHONPATH? What? How? + # + # (Q) + + # + # And now for something completely different. + # + # https://crossenv.readthedocs.io/en/latest/ is a tool specifically for + # this. It assumes you can cross-compile CPython on your own, though, + # and then helps you use it to cross-compile extension modules. Maybe + # our nixpkgs-cross-compiled CPython would be a good complement? + # + + + # packages.host-python = pkgsCross.aarch64-android.python3Minimal.withPackages (ps: [ + # # The nixpkgs zfec has some extra dependencies that we might not + # # really care about. This one is leaner. Mostly only relevant + # # because we have to cross-compile anything here. + # (ps.callPackage ./zfec.nix {}) + # ]); + + # packages.aarch64-android.host-python310 = + # let + # pkgs = import nixpkgs { + # system = "x86_64-linux"; + # config = { + # allowUnfree = true; + # android_sdk.accept_license = true; + # }; + # }; + # in + # (pkgs.pkgsCross.aarch64-android.python310.override { + # # Turn off all the things. Each one might be broken for + # # cross-compilation and even if not we don't need them for this build + # # Python. We just need it to report the right platform info. + # mimetypesSupport = false; + # x11Support = false; + # bluezSupport = false; + # sqlite = null; + # openssl = null; + # tzdata = null; + # readline = null; + # }).overrideAttrs (old: { + # # Turn off even more things which aren't parameters to the Python + # # expressionThey . + + # # These drag in an aarch64-android bash which fails to build. + # preFixup = null; + # postPatch = null; + + # # This drags in a -lcrypt dependency which isn't satisfied by Google + # # Android Bionic. + # LIBS = null; + # }); + }; } -- GitLab