* [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, pym/portage/util/
@ 2012-08-23 16:55 Zac Medico
0 siblings, 0 replies; 4+ messages in thread
From: Zac Medico @ 2012-08-23 16:55 UTC (permalink / raw
To: gentoo-commits
commit: c0ac477af61fa107aaececeda2ca888292719e17
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 23 16:55:19 2012 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Aug 23 16:55:19 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c0ac477a
read_corresponding_eapi_file: cache results
---
pym/portage/package/ebuild/config.py | 3 ++-
pym/portage/util/__init__.py | 7 +++++++
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
index 2fa799f..81e0501 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -42,7 +42,7 @@ from portage.repository.config import load_repository_config
from portage.util import ensure_dirs, getconfig, grabdict, \
grabdict_package, grabfile, grabfile_package, LazyItemsDict, \
normalize_path, shlex_split, stack_dictlist, stack_dicts, stack_lists, \
- writemsg, writemsg_level
+ writemsg, writemsg_level, _eapi_cache
from portage.versions import catpkgsplit, catsplit, cpv_getkey, _pkg_str
from portage.package.ebuild._config import special_env_vars
@@ -811,6 +811,7 @@ class config(object):
# and subsequent calls to the _init() functions have no effect.
portage.output._init(config_root=self['PORTAGE_CONFIGROOT'])
portage.data._init(self)
+ _eapi_cache.clear()
if mycpv:
self.setcpv(mycpv)
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index 4645be5..951a158 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -379,6 +379,8 @@ def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1):
newdict[k] = " ".join(v)
return newdict
+_eapi_cache = {}
+
def read_corresponding_eapi_file(filename):
"""
Read the 'eapi' file from the directory 'filename' is in.
@@ -387,6 +389,10 @@ def read_corresponding_eapi_file(filename):
default = "0"
eapi_file = os.path.join(os.path.dirname(filename), "eapi")
try:
+ return _eapi_cache[eapi_file]
+ except KeyError:
+ pass
+ try:
f = io.open(_unicode_encode(eapi_file,
encoding=_encodings['fs'], errors='strict'),
mode='r', encoding=_encodings['repo.content'], errors='replace')
@@ -401,6 +407,7 @@ def read_corresponding_eapi_file(filename):
except IOError:
eapi = default
+ _eapi_cache[eapi_file] = eapi
return eapi
def grabdict_package(myfilename, juststrings=0, recursive=0, allow_wildcard=False, allow_repo=False,
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, pym/portage/util/
@ 2013-03-26 20:09 Zac Medico
0 siblings, 0 replies; 4+ messages in thread
From: Zac Medico @ 2013-03-26 20:09 UTC (permalink / raw
To: gentoo-commits
commit: 86e75790954e766beba75443d967b2c25055c5b0
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 26 19:14:50 2013 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Mar 26 20:05:45 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=86e75790
make.conf: recurse directories, bug #463266
---
pym/portage/package/ebuild/config.py | 4 +-
pym/portage/util/__init__.py | 49 ++++++++++++++++++++++++++++++++-
2 files changed, 49 insertions(+), 4 deletions(-)
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
index 5f3e1c6..1d2e4a6 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -339,7 +339,7 @@ class config(object):
for x in make_conf_paths:
mygcfg = getconfig(x,
tolerant=tolerant, allow_sourcing=True,
- expand=make_conf)
+ expand=make_conf, recursive=True)
if mygcfg is not None:
make_conf.update(mygcfg)
make_conf_count += 1
@@ -538,7 +538,7 @@ class config(object):
for x in make_conf_paths:
mygcfg.update(getconfig(x,
tolerant=tolerant, allow_sourcing=True,
- expand=expand_map) or {})
+ expand=expand_map, recursive=True) or {})
# Don't allow the user to override certain variables in make.conf
profile_only_variables = self.configdict["defaults"].get(
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index dafc3e3..59d4fa4 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -483,6 +483,9 @@ def grabfile_package(myfilename, compatlevel=0, recursive=0, allow_wildcard=Fals
atoms.append(pkg_orig)
return atoms
+def _recursive_basename_filter(f):
+ return not f.startswith(".") and not f.endswith("~")
+
def grablines(myfilename, recursive=0, remember_source_file=False):
mylines=[]
if recursive and os.path.isdir(myfilename):
@@ -499,7 +502,7 @@ def grablines(myfilename, recursive=0, remember_source_file=False):
raise
dirlist.sort()
for f in dirlist:
- if not f.startswith(".") and not f.endswith("~"):
+ if _recursive_basename_filter(f):
mylines.extend(grablines(
os.path.join(myfilename, f), recursive, remember_source_file))
else:
@@ -558,7 +561,9 @@ class _tolerant_shlex(shlex.shlex):
_invalid_var_name_re = re.compile(r'^\d|\W')
-def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True):
+def getconfig(mycfg, tolerant=False, allow_sourcing=False, expand=True,
+ recursive=False):
+
if isinstance(expand, dict):
# Some existing variable definitions have been
# passed in, for use in substitutions.
@@ -567,6 +572,46 @@ def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True):
else:
expand_map = {}
mykeys = {}
+
+ if recursive and os.path.isdir(mycfg):
+ # Use source commands so that syntax error messages
+ # can display real file names and line numbers.
+ recursive_files = []
+ for parent, dirs, files in os.walk(mycfg):
+ try:
+ parent = _unicode_decode(parent,
+ encoding=_encodings['fs'], errors='strict')
+ except UnicodeDecodeError:
+ continue
+ for fname_enc in dirs[:]:
+ try:
+ fname = _unicode_decode(fname_enc,
+ encoding=_encodings['fs'], errors='strict')
+ except UnicodeDecodeError:
+ dirs.remove(fname_enc)
+ continue
+ if fname in VCS_DIRS or not _recursive_basename_filter(fname):
+ dirs.remove(fname_enc)
+ for fname in files:
+ try:
+ fname = _unicode_decode(fname,
+ encoding=_encodings['fs'], errors='strict')
+ except UnicodeDecodeError:
+ pass
+ else:
+ if _recursive_basename_filter(fname):
+ fname = os.path.join(parent, fname)
+ if os.path.isfile(fname):
+ recursive_files.append(fname)
+ recursive_files.sort()
+ if not expand:
+ expand_map = False
+ for fname in recursive_files:
+ mykeys.update(getconfig(fname, tolerant=tolerant,
+ allow_sourcing=allow_sourcing, expand=expand_map,
+ recursive=False) or {})
+ return mykeys
+
f = None
try:
# NOTE: shlex doesn't support unicode objects with Python 2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, pym/portage/util/
@ 2015-01-18 18:04 Michał Górny
0 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2015-01-18 18:04 UTC (permalink / raw
To: gentoo-commits
commit: 5a1e6c9710becab384b684ad6ba55e025d63a60e
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 17 10:36:18 2015 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jan 18 18:04:24 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5a1e6c97
Default MAKEOPTS to -j(ncpus+1) when unset
Default MAKEOPTS job number to (number of CPUs + 1) when it is not
provided in the ebuild environment.
Suggested-By: Daniel Robbins <drobbins <AT> funtoo.org>
---
pym/portage/package/ebuild/doebuild.py | 8 +++++++-
pym/portage/util/cpuinfo.py | 18 ++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
index bf97660..f43dddc 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2013 Gentoo Foundation
+# Copyright 2010-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from __future__ import unicode_literals
@@ -66,6 +66,7 @@ from portage.package.ebuild.prepare_build_dirs import prepare_build_dirs
from portage.util import apply_recursive_permissions, \
apply_secpass_permissions, noiselimit, normalize_path, \
writemsg, writemsg_stdout, write_atomic
+from portage.util.cpuinfo import get_cpu_count
from portage.util.lafilefixer import rewrite_lafile
from portage.versions import _pkgsplit
from _emerge.BinpkgEnvExtractor import BinpkgEnvExtractor
@@ -463,6 +464,11 @@ def doebuild_environment(myebuild, mydo, myroot=None, settings=None,
mysettings["PATH"] = os.path.join(os.sep, eprefix_lstrip,
"usr", libdir, "ccache", "bin") + ":" + mysettings["PATH"]
+ if 'MAKEOPTS' not in mysettings:
+ nproc = get_cpu_count()
+ if nproc:
+ mysettings['MAKEOPTS'] = '-j%d' % (nproc + 1)
+
if not eapi_exports_KV(eapi):
# Discard KV for EAPIs that don't support it. Cached KV is restored
# from the backupenv whenever config.reset() is called.
diff --git a/pym/portage/util/cpuinfo.py b/pym/portage/util/cpuinfo.py
new file mode 100644
index 0000000..669e707
--- /dev/null
+++ b/pym/portage/util/cpuinfo.py
@@ -0,0 +1,18 @@
+# Copyright 2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+__all__ = ['get_cpu_count']
+
+
+def get_cpu_count():
+ """
+ Try to obtain the number of CPUs available.
+
+ @return: Number of CPUs or None if unable to obtain.
+ """
+
+ try:
+ import multiprocessing
+ return multiprocessing.cpu_count()
+ except (ImportError, NotImplementedError):
+ return None
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, pym/portage/util/
@ 2015-11-15 22:54 Michał Górny
0 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2015-11-15 22:54 UTC (permalink / raw
To: gentoo-commits
commit: e5ba8d096e56495a9b516cea818d48e104d62bca
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 15 21:03:42 2015 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Nov 15 21:18:48 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=e5ba8d09
EAPI 6: Enforce posixish LC_CTYPE
pym/portage/package/ebuild/config.py | 13 ++++++++++++-
pym/portage/util/locale.py | 23 ++++++++++++++++++++---
2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
index 095de37..1827043 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -24,7 +24,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
'portage.dep.soname.SonameAtom:SonameAtom',
'portage.dbapi.vartree:vartree',
'portage.package.ebuild.doebuild:_phase_func_map',
- 'portage.util.locale:split_LC_ALL',
+ 'portage.util.locale:check_locale,split_LC_ALL',
)
from portage import bsd_chflags, \
load_mod, os, selinux, _unicode_decode
@@ -2773,6 +2773,17 @@ class config(object):
if eapi_attrs.posixish_locale:
split_LC_ALL(mydict)
mydict["LC_COLLATE"] = "C"
+ if not check_locale(silent=True, env=mydict):
+ # try another locale
+ for l in ("C.UTF-8", "en_US.UTF-8", "en_GB.UTF-8", "C"):
+ mydict["LC_CTYPE"] = l
+ if check_locale(silent=True, env=mydict):
+ # TODO: output the following only once
+# writemsg(_("!!! LC_CTYPE unsupported, using %s instead\n")
+# % mydict["LC_CTYPE"])
+ break
+ else:
+ raise AssertionError("C locale did not pass the test!")
return mydict
diff --git a/pym/portage/util/locale.py b/pym/portage/util/locale.py
index d902db8..27a2806 100644
--- a/pym/portage/util/locale.py
+++ b/pym/portage/util/locale.py
@@ -8,6 +8,7 @@ locale.
"""
from __future__ import unicode_literals
+import locale
import logging
import os
import textwrap
@@ -26,7 +27,7 @@ locale_categories = (
)
-def _check_locale():
+def _check_locale(silent):
"""
The inner locale check function.
"""
@@ -44,6 +45,9 @@ def _check_locale():
ruc = [libc.toupper(c) for c in lc]
if lc != rlc or uc != ruc:
+ if silent:
+ return False
+
msg = ("WARNING: The LC_CTYPE variable is set to a locale " +
"that specifies transformation between lowercase " +
"and uppercase ASCII characters that is different than " +
@@ -71,7 +75,7 @@ def _check_locale():
return True
-def check_locale():
+def check_locale(silent=False, env=None):
"""
Check whether the locale is sane. Returns True if it is, prints
warning and returns False if it is not. Returns None if the check
@@ -81,7 +85,20 @@ def check_locale():
pid = os.fork()
if pid == 0:
try:
- ret = _check_locale()
+ if env is not None:
+ for v in ("LC_ALL", "LC_CTYPE", "LANG"):
+ if v in env:
+ mylocale = env[v]
+ break
+ else:
+ mylocale = "C"
+
+ try:
+ locale.setlocale(locale.LC_CTYPE, mylocale)
+ except locale.Error:
+ os._exit(2)
+
+ ret = _check_locale(silent)
if ret is None:
os._exit(2)
else:
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-11-15 22:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-15 22:54 [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, pym/portage/util/ Michał Górny
-- strict thread matches above, loose matches on Subject: below --
2015-01-18 18:04 Michał Górny
2013-03-26 20:09 Zac Medico
2012-08-23 16:55 Zac Medico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox