Fix/host setuptools3 (#533)
* status * ♻️ Extract context managers * 🎨 Fix typo * ✨ Use python_prefix * ✨ Remove unused import * 📦 Trigger pipeline Co-authored-by: richard <richard@dotmodus>
This commit is contained in:
parent
4567cad31f
commit
7cb14fc7da
9 changed files with 69 additions and 24 deletions
|
@ -98,7 +98,7 @@ You can build recipes at the same time by adding them as parameters:
|
||||||
Recipe builds can be removed via the clean command e.g.:
|
Recipe builds can be removed via the clean command e.g.:
|
||||||
|
|
||||||
$ toolchain clean openssl
|
$ toolchain clean openssl
|
||||||
|
|
||||||
You can install package that don't require compilation with pip::
|
You can install package that don't require compilation with pip::
|
||||||
|
|
||||||
$ toolchain pip install plyer
|
$ toolchain pip install plyer
|
||||||
|
@ -324,3 +324,4 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
|
||||||
<a href="https://opencollective.com/kivy/sponsor/7/website" target="_blank"><img src="https://opencollective.com/kivy/sponsor/7/avatar.svg"></a>
|
<a href="https://opencollective.com/kivy/sponsor/7/website" target="_blank"><img src="https://opencollective.com/kivy/sponsor/7/avatar.svg"></a>
|
||||||
<a href="https://opencollective.com/kivy/sponsor/8/website" target="_blank"><img src="https://opencollective.com/kivy/sponsor/8/avatar.svg"></a>
|
<a href="https://opencollective.com/kivy/sponsor/8/website" target="_blank"><img src="https://opencollective.com/kivy/sponsor/8/avatar.svg"></a>
|
||||||
<a href="https://opencollective.com/kivy/sponsor/9/website" target="_blank"><img src="https://opencollective.com/kivy/sponsor/9/avatar.svg"></a>
|
<a href="https://opencollective.com/kivy/sponsor/9/website" target="_blank"><img src="https://opencollective.com/kivy/sponsor/9/avatar.svg"></a>
|
||||||
|
|
||||||
|
|
46
kivy_ios/context_managers.py
Normal file
46
kivy_ios/context_managers.py
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
"""
|
||||||
|
This module houses context managers to assist in the managing of state during
|
||||||
|
kivy-ios builds.
|
||||||
|
"""
|
||||||
|
from logging import getLogger
|
||||||
|
from contextlib import contextmanager
|
||||||
|
from os import getcwd, chdir, environ
|
||||||
|
from os.path import expanduser
|
||||||
|
|
||||||
|
|
||||||
|
logger = getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def cd(newdir):
|
||||||
|
"""
|
||||||
|
Set the current working directory to `newdir` for the duration of the
|
||||||
|
context.
|
||||||
|
"""
|
||||||
|
prevdir = getcwd()
|
||||||
|
logger.info("cd {}".format(newdir))
|
||||||
|
chdir(expanduser(newdir))
|
||||||
|
try:
|
||||||
|
yield
|
||||||
|
finally:
|
||||||
|
logger.info("cd {}".format(prevdir))
|
||||||
|
chdir(prevdir)
|
||||||
|
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def python_path(newdir):
|
||||||
|
"""
|
||||||
|
Set the PYTHONPATH environmnet variable to `newdir` for the duraiton of the
|
||||||
|
context.
|
||||||
|
"""
|
||||||
|
prevdir = environ.get("PYTHONPATH")
|
||||||
|
logger.debug("Setting PYTHONPATH to {}".format(newdir))
|
||||||
|
environ["PYTHONPATH"] = newdir
|
||||||
|
try:
|
||||||
|
yield
|
||||||
|
finally:
|
||||||
|
logger.debug("Setting PYTHONPATH to {}".format(prevdir))
|
||||||
|
if prevdir is None:
|
||||||
|
environ.pop("PYTHONPATH")
|
||||||
|
else:
|
||||||
|
environ["PYTHONPATH"] = prevdir
|
|
@ -1,9 +1,10 @@
|
||||||
from kivy_ios.toolchain import Recipe, shprint, cd, cache_execution
|
from kivy_ios.toolchain import Recipe, shprint, cache_execution
|
||||||
|
from kivy_ios.context_managers import cd, python_path
|
||||||
import sh
|
import sh
|
||||||
|
|
||||||
|
|
||||||
class HostSetuptools3(Recipe):
|
class HostSetuptools3(Recipe):
|
||||||
depends = ["openssl", "hostpython3"]
|
depends = ["openssl", "hostpython3", "python3"]
|
||||||
archs = ["x86_64"]
|
archs = ["x86_64"]
|
||||||
version = '40.9.0'
|
version = '40.9.0'
|
||||||
url = 'https://pypi.python.org/packages/source/s/setuptools/setuptools-{version}.zip'
|
url = 'https://pypi.python.org/packages/source/s/setuptools/setuptools-{version}.zip'
|
||||||
|
@ -13,8 +14,11 @@ class HostSetuptools3(Recipe):
|
||||||
arch = self.filtered_archs[0]
|
arch = self.filtered_archs[0]
|
||||||
build_dir = self.get_build_dir(arch.arch)
|
build_dir = self.get_build_dir(arch.arch)
|
||||||
hostpython = sh.Command(self.ctx.hostpython)
|
hostpython = sh.Command(self.ctx.hostpython)
|
||||||
with cd(build_dir):
|
|
||||||
shprint(hostpython, "setup.py", "install")
|
with python_path(self.ctx.site_packages_dir):
|
||||||
|
with cd(build_dir):
|
||||||
|
shprint(hostpython, "setup.py", "install",
|
||||||
|
f"--prefix={self.ctx.python_prefix}")
|
||||||
|
|
||||||
|
|
||||||
recipe = HostSetuptools3()
|
recipe = HostSetuptools3()
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
from kivy_ios.toolchain import Recipe, cd, shprint
|
from kivy_ios.toolchain import Recipe, shprint
|
||||||
from os.path import join
|
from os.path import join
|
||||||
import os
|
import os
|
||||||
import sh
|
import sh
|
||||||
import shutil
|
import shutil
|
||||||
import logging
|
import logging
|
||||||
|
from kivy_ios.context_managers import cd
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# pure-python package, this can be removed when we'll support any python package
|
# pure-python package, this can be removed when we'll support any python package
|
||||||
from kivy_ios.toolchain import PythonRecipe, shprint, cd
|
from kivy_ios.toolchain import PythonRecipe, shprint
|
||||||
|
from kivy_ios.context_managers import cd
|
||||||
from os.path import join
|
from os.path import join
|
||||||
import sh
|
import sh
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@ import sh
|
||||||
|
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
|
||||||
from kivy_ios.toolchain import CythonRecipe, cd, shprint
|
from kivy_ios.toolchain import CythonRecipe, shprint
|
||||||
|
from kivy_ios.context_managers import cd
|
||||||
|
|
||||||
|
|
||||||
class NetifacesRecipe(CythonRecipe):
|
class NetifacesRecipe(CythonRecipe):
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
'''Recipe for pycrypto on ios
|
'''Recipe for pycrypto on ios
|
||||||
'''
|
'''
|
||||||
from kivy_ios.toolchain import CythonRecipe, shprint, cd
|
from kivy_ios.toolchain import CythonRecipe, shprint
|
||||||
|
from kivy_ios.context_managers import cd
|
||||||
from os.path import join
|
from os.path import join
|
||||||
import sh
|
import sh
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from kivy_ios.toolchain import Recipe, shprint, cd
|
from kivy_ios.toolchain import Recipe, shprint
|
||||||
|
from kivy_ios.context_managers import cd
|
||||||
from os.path import join
|
from os.path import join
|
||||||
import sh
|
import sh
|
||||||
import shutil
|
import shutil
|
||||||
|
|
|
@ -9,7 +9,7 @@ This tool intend to replace all the previous tools/ in shell script.
|
||||||
import argparse
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
from sys import stdout
|
from sys import stdout
|
||||||
from os.path import join, dirname, realpath, exists, isdir, basename, expanduser
|
from os.path import join, dirname, realpath, exists, isdir, basename
|
||||||
from os import listdir, unlink, makedirs, environ, chdir, getcwd, walk
|
from os import listdir, unlink, makedirs, environ, chdir, getcwd, walk
|
||||||
import sh
|
import sh
|
||||||
import zipfile
|
import zipfile
|
||||||
|
@ -21,7 +21,7 @@ import shutil
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
from contextlib import contextmanager, suppress
|
from contextlib import suppress
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
import logging
|
import logging
|
||||||
|
@ -46,18 +46,6 @@ sh_logging.setLevel(logging.WARNING)
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
|
||||||
def cd(newdir):
|
|
||||||
prevdir = getcwd()
|
|
||||||
logger.info("cd {}".format(newdir))
|
|
||||||
chdir(expanduser(newdir))
|
|
||||||
try:
|
|
||||||
yield
|
|
||||||
finally:
|
|
||||||
logger.info("cd {}".format(prevdir))
|
|
||||||
chdir(prevdir)
|
|
||||||
|
|
||||||
|
|
||||||
def shprint(command, *args, **kwargs):
|
def shprint(command, *args, **kwargs):
|
||||||
kwargs["_iter"] = True
|
kwargs["_iter"] = True
|
||||||
kwargs["_out_bufsize"] = 1
|
kwargs["_out_bufsize"] = 1
|
||||||
|
|
Loading…
Reference in a new issue