Пример #1
0
    def reduce_python(self):
        logger.info("Reduce python")
        logger.info("Remove files unlikely to be used")
        with cd(join(self.ctx.dist_dir, "root", "python3")):
            sh.rm("-rf", "bin", "share")
        # platform binaries and configuration
        with cd(
                join(self.ctx.dist_dir, "root", "python3", "lib", "python3.8",
                     "config-3.8-darwin")):
            sh.rm(
                "libpython3.8.a",
                "python.o",
                "config.c.in",
                "makesetup",
                "install-sh",
            )

        # cleanup pkgconfig and compiled lib
        with cd(join(self.ctx.dist_dir, "root", "python3", "lib")):
            sh.rm("-rf", "pkgconfig", "libpython3.8.a")

        # cleanup python libraries
        with cd(join(self.ctx.dist_dir, "root", "python3", "lib",
                     "python3.8")):
            sh.rm("-rf", "wsgiref", "curses", "idlelib", "lib2to3",
                  "ensurepip", "turtledemo", "lib-dynload", "venv",
                  "pydoc_data")
            sh.find(".", "-path", "*/test*/*", "-delete")
            sh.find(".", "-name", "*.exe", "-type", "f", "-delete")
            sh.find(".", "-name", "test*", "-type", "d", "-delete")
            sh.find(".", "-iname", "*.pyc", "-delete")
            sh.find(".", "-path", "*/__pycache__/*", "-delete")
            sh.find(".", "-name", "__pycache__", "-type", "d", "-delete")

            # now precompile to Python bytecode
            hostpython = sh.Command(self.ctx.hostpython)
            shprint(hostpython, "-m", "compileall", "-f", "-b")
            # sh.find(".", "-iname", "*.py", "-delete")

            # some pycache are recreated after compileall
            sh.find(".", "-path", "*/__pycache__/*", "-delete")
            sh.find(".", "-name", "__pycache__", "-type", "d", "-delete")

            # create the lib zip
            logger.info("Create a python3.8.zip")
            sh.mv("config-3.8-darwin", "..")
            sh.mv("site-packages", "..")
            sh.zip("-r", "../python38.zip", sh.glob("*"))
            sh.rm("-rf", sh.glob("*"))
            sh.mv("../config-3.8-darwin", ".")
            sh.mv("../site-packages", ".")
Пример #2
0
 def install(self):
     arch = list(self.filtered_archs)[0]
     build_dir = self.get_build_dir(arch.arch)
     hostpython = sh.Command(self.ctx.hostpython)
     build_env = arch.get_env()
     dest_dir = join(self.ctx.dist_dir, "root", "python3")
     build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python3.8', 'site-packages')
     with cd(build_dir):
         shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env)
Пример #3
0
 def install(self):
     arch = list(self.filtered_archs)[0]
     build_dir = self.get_build_dir(arch.arch)
     hostpython = sh.Command(self.ctx.hostpython)
     build_env = arch.get_env()
     dest_dir = join(self.ctx.dist_dir, "root", "python")
     build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python3.7', 'site-packages')
     cmd = sh.Command("sed")
     with cd(build_dir):
         shprint(cmd, "-i", "", "s/setuptools/distutils.core/g", "./setup.py", _env=build_env)
         shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env)
Пример #4
0
 def install(self):
     arch = list(self.filtered_archs)[0]
     build_dir = self.get_build_dir(arch.arch)
     build_env = self.get_netifaces_env(arch)
     hostpython = sh.Command(self.ctx.hostpython)
     with cd(build_dir):
         shprint(
             hostpython,
             "setup.py",
             "install",
             "--prefix",
             self.dest_dir(),
             _env=build_env,
         )
Пример #5
0
 def build_x86_64(self):
     build_env = self.get_build_env()
     configure = sh.Command(join(self.build_dir, "configure"))
     arch = self.filtered_archs[0]
     build_subdir = self.get_build_subdir(arch.arch)
     os.makedirs(build_subdir, exist_ok=True)
     with cd(build_subdir):
         shprint(configure,
                 "--prefix={}".format(join(self.ctx.dist_dir,
                                           "hostpython3")),
                 "--with-openssl={}".format(
                     join(self.ctx.dist_dir, 'hostopenssl')),
                 _env=build_env)
     shprint(sh.make,
             "-C",
             build_subdir,
             self.ctx.concurrent_make,
             _env=build_env)
Пример #6
0
 def install(self):
     arch = self.filtered_archs[0]
     build_dir = self.get_build_dir(arch.arch)
     hostpython = sh.Command(self.ctx.hostpython)
     with cd(build_dir):
         shprint(hostpython, "setup.py", "install")