Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion alibuild_helpers/analytics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python3
import os, subprocess, sys
import os
import subprocess
import sys
from os.path import exists, expanduser
from os import unlink

Expand Down
10 changes: 4 additions & 6 deletions alibuild_helpers/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from alibuild_helpers.utilities import getPackageList, asList
from alibuild_helpers.utilities import validateDefaults
from alibuild_helpers.utilities import Hasher
from alibuild_helpers.utilities import yamlDump
from alibuild_helpers.utilities import resolve_tag, resolve_version, short_commit_hash
from alibuild_helpers.git import Git, git
from alibuild_helpers.sl import Sapling
Expand All @@ -31,7 +30,6 @@
import os
import re
import shutil
import sys
import time


Expand Down Expand Up @@ -476,7 +474,7 @@ def doBuild(args, parser):
checkedOutCommitName = scm.checkedOutCommitName(directory=args.configDir)
except SCMError:
dieOnError(True, "Cannot find SCM directory in %s." % args.configDir)
os.environ["ALIBUILD_ALIDIST_HASH"] = checkedOutCommitName # type: ignore
os.environ["ALIBUILD_ALIDIST_HASH"] = checkedOutCommitName

debug("Building for architecture %s", args.architecture)
debug("Number of parallel builds: %d", args.jobs)
Expand Down Expand Up @@ -512,9 +510,9 @@ def doBuild(args, parser):
("\n- ".join(sorted(failed)), args.defaults, " ".join(args.pkgname)))

for x in specs.values():
x["requires"] = [r for r in x["requires"] if not r in args.disable]
x["build_requires"] = [r for r in x["build_requires"] if not r in args.disable]
x["runtime_requires"] = [r for r in x["runtime_requires"] if not r in args.disable]
x["requires"] = [r for r in x["requires"] if r not in args.disable]
x["build_requires"] = [r for r in x["build_requires"] if r not in args.disable]
x["runtime_requires"] = [r for r in x["runtime_requires"] if r not in args.disable]

if systemPackages:
banner("aliBuild can take the following packages from the system and will not build them:\n %s",
Expand Down
4 changes: 2 additions & 2 deletions alibuild_helpers/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ def decideClean(workDir, architecture, aggressiveCleanup):
"%s/SOURCES" % (workDir)]
allBuildStuff = glob.glob("%s/BUILD/*" % workDir)
toDelete += [x for x in allBuildStuff
if not path.islink(x) and not basename(x) in symlinksBuild]
if not path.islink(x) and basename(x) not in symlinksBuild]
installGlob ="%s/%s/*/" % (workDir, architecture)
installedPackages = set([dirname(x) for x in glob.glob(installGlob)])
symlinksInstall = []
for x in installedPackages:
symlinksInstall += [path.realpath(y) for y in glob.glob(x + "/latest*")]
toDelete += [x for x in glob.glob(installGlob+ "*")
if not path.islink(x) and not path.realpath(x) in symlinksInstall]
if not path.islink(x) and path.realpath(x) not in symlinksInstall]
toDelete = [x for x in toDelete if path.exists(x)]
return toDelete

Expand Down
8 changes: 4 additions & 4 deletions alibuild_helpers/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ def doDeps(args, parser):

for s in specs.values():
# Remove disabled packages
s["requires"] = [r for r in s["requires"] if not r in args.disable and r != "defaults-release"]
s["build_requires"] = [r for r in s["build_requires"] if not r in args.disable and r != "defaults-release"]
s["runtime_requires"] = [r for r in s["runtime_requires"] if not r in args.disable and r != "defaults-release"]
s["requires"] = [r for r in s["requires"] if r not in args.disable and r != "defaults-release"]
s["build_requires"] = [r for r in s["build_requires"] if r not in args.disable and r != "defaults-release"]
s["runtime_requires"] = [r for r in s["runtime_requires"] if r not in args.disable and r != "defaults-release"]

# Determine which pacakages are only build/runtime dependencies
all_build = set()
Expand Down Expand Up @@ -97,7 +97,7 @@ def doDeps(args, parser):
# Check if we have dot in PATH
try:
execute(["dot", "-V"])
except Exception as e:
except Exception:
dieOnError(True, "Could not find dot in PATH. Please install graphviz and add it to PATH.")
try:
if args.neat:
Expand Down
6 changes: 4 additions & 2 deletions alibuild_helpers/doctor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python3
import os, re, sys
import os
import re
import sys
from os.path import exists, abspath, expanduser
import logging
from alibuild_helpers.log import debug, error, banner, info, success, warning
Expand All @@ -9,7 +11,7 @@

def prunePaths(workDir) -> None:
for x in ["PATH", "LD_LIBRARY_PATH", "DYLD_LIBRARY_PATH"]:
if not x in os.environ:
if x not in os.environ:
continue
workDirEscaped = re.escape("%s" % workDir) + "[^:]*:?"
os.environ[x] = re.sub(workDirEscaped, "", os.environ[x])
Expand Down
2 changes: 1 addition & 1 deletion alibuild_helpers/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def git(args, directory=".", check=True, prompt=True):
directory=quote(directory),
args=" ".join(map(quote, args)),
# GIT_TERMINAL_PROMPT is only supported in git 2.3+.
prompt_var=f"GIT_TERMINAL_PROMPT=0" if not prompt else "",
prompt_var="GIT_TERMINAL_PROMPT=0" if not prompt else "",
directory_safe_var=f"GIT_CONFIG_COUNT={lastGitOverride+2} GIT_CONFIG_KEY_{lastGitOverride}=safe.directory GIT_CONFIG_VALUE_{lastGitOverride}=$PWD GIT_CONFIG_KEY_{lastGitOverride+1}=gc.auto GIT_CONFIG_VALUE_{lastGitOverride+1}=0" if directory else "",
), timeout=GIT_CMD_TIMEOUTS.get(args[0] if len(args) else "*", GIT_COMMAND_TIMEOUT_SEC))
if check and err != 0:
Expand Down
5 changes: 3 additions & 2 deletions alibuild_helpers/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
from alibuild_helpers.utilities import getPackageList, parseDefaults, readDefaults, validateDefaults
from alibuild_helpers.log import debug, error, warning, banner, info
from alibuild_helpers.log import dieOnError
from alibuild_helpers.workarea import cleanup_git_log, updateReferenceRepoSpec
from alibuild_helpers.workarea import updateReferenceRepoSpec

from os.path import join
import os.path as path
import os, sys
import os
import sys

def parsePackagesDefinition(pkgname):
return [ dict(zip(["name","ver"], y.split("@")[0:2]))
Expand Down
1 change: 0 additions & 1 deletion alibuild_helpers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ def fetch_symlinks(self, spec) -> None:
done
""".format(
workDir=self.workdir,
b=self.remoteStore,
architecture=self.architecture,
cvmfs_architecture=cvmfs_architecture,
package=spec["package"],
Expand Down
16 changes: 8 additions & 8 deletions alibuild_helpers/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def normalise_multiple_options(option, sep=","):

def prunePaths(workDir):
for x in ["PATH", "LD_LIBRARY_PATH", "DYLD_LIBRARY_PATH"]:
if not x in os.environ:
if x not in os.environ:
continue
workDirEscaped = re.escape("%s" % workDir) + "[^:]*:?"
os.environ[x] = re.sub(workDirEscaped, "", os.environ[x])
Expand All @@ -163,12 +163,12 @@ def validateSpec(spec):
raise SpecError("Empty recipe.")
if type(spec) != OrderedDict:
raise SpecError("Not a YAML key / value.")
if not "package" in spec:
if "package" not in spec:
raise SpecError("Missing package field in header.")

# Use this to check if a given spec is compatible with the given default
def validateDefaults(finalPkgSpec, defaults):
if not "valid_defaults" in finalPkgSpec:
if "valid_defaults" not in finalPkgSpec:
return (True, "", [])
validDefaults = asList(finalPkgSpec["valid_defaults"])
nonStringDefaults = [x for x in validDefaults if not type(x) == str]
Expand Down Expand Up @@ -378,7 +378,7 @@ def parseRecipe(reader):
err = "Unable to parse %s\n%s" % (reader.url, str(e))
except yaml.parser.ParserError as e:
err = "Unable to parse %s\n%s" % (reader.url, str(e))
except ValueError as e:
except ValueError:
err = "Unable to parse %s. Header missing." % reader.url
return err, spec, recipe

Expand Down Expand Up @@ -496,7 +496,7 @@ def getPackageList(packages, specs, configDir, preferSystem, noSystem,
systemRE = spec.get("prefer_system", "(?!.*)")
try:
systemREMatches = re.match(systemRE, architecture)
except TypeError as e:
except TypeError:
dieOnError(True, "Malformed entry prefer_system: %s in %s" % (systemRE, spec["package"]))
if not noSystem and (preferSystem or systemREMatches):
requested_version = resolve_version(spec, defaults, "unavailable", "unavailable")
Expand Down Expand Up @@ -553,7 +553,7 @@ def getPackageList(packages, specs, configDir, preferSystem, noSystem,
"System requirements %s cannot have a recipe" % spec["package"])
if re.match(spec.get("system_requirement", "(?!.*)"), architecture):
cmd = spec.get("system_requirement_check", "false")
if not spec["package"] in requirementsCache:
if spec["package"] not in requirementsCache:
requirementsCache[spec["package"]] = performRequirementCheck(spec, cmd.strip())

err, output = requirementsCache[spec["package"]]
Expand All @@ -580,8 +580,8 @@ def getPackageList(packages, specs, configDir, preferSystem, noSystem,
spec["disabled"] += [x for x in fn("requires")]
spec["disabled"] += [x for x in fn("build_requires")]
fn = lambda what: filterByArchitectureDefaults(architecture, defaults, spec.get(what, []))
spec["requires"] = [x for x in fn("requires") if not x in disable]
spec["build_requires"] = [x for x in fn("build_requires") if not x in disable]
spec["requires"] = [x for x in fn("requires") if x not in disable]
spec["build_requires"] = [x for x in fn("build_requires") if x not in disable]
if spec["package"] != "defaults-release":
spec["build_requires"].append("defaults-release")
spec["runtime_requires"] = spec["requires"]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_args.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import print_function
# Assuming you are using the mock library to ... mock things
from unittest import mock
from unittest.mock import patch, call
from unittest.mock import patch

import alibuild_helpers.args
from alibuild_helpers.args import doParseArgs, matchValidArch, finaliseArgs, DEFAULT_WORK_DIR, DEFAULT_CHDIR, ARCHITECTURE_TABLE
from alibuild_helpers.args import doParseArgs, matchValidArch
import sys
import os
import os.path
Expand Down
4 changes: 1 addition & 3 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ class BuildTestCase(unittest.TestCase):
@patch("alibuild_helpers.git.git")
@patch("alibuild_helpers.build.exists", new=MagicMock(side_effect=dummy_exists))
@patch("os.path.exists", new=MagicMock(side_effect=dummy_exists))
@patch("alibuild_helpers.build.sys")
@patch("alibuild_helpers.build.dieOnError", new=MagicMock())
@patch("alibuild_helpers.utilities.dieOnError", new=MagicMock())
@patch("alibuild_helpers.utilities.warning")
Expand Down Expand Up @@ -240,7 +239,7 @@ class BuildTestCase(unittest.TestCase):
@patch("alibuild_helpers.workarea.is_writeable", new=MagicMock(return_value=True))
@patch("alibuild_helpers.build.basename", new=MagicMock(return_value="aliBuild"))
@patch("alibuild_helpers.build.install_wrapper_script", new=MagicMock())
def test_coverDoBuild(self, mock_debug, mock_listdir, mock_warning, mock_sys, mock_git_git) -> None:
def test_coverDoBuild(self, mock_debug, mock_listdir, mock_warning, mock_git_git) -> None:
mock_git_git.side_effect = dummy_git
mock_debug.side_effect = lambda *args: None
mock_warning.side_effect = lambda *args: None
Expand Down Expand Up @@ -281,7 +280,6 @@ def test_coverDoBuild(self, mock_debug, mock_listdir, mock_warning, mock_sys, mo
forceTracked=False,
plugin="legacy"
)
mock_sys.version_info = sys.version_info

def mkcall(args):
cmd, directory, check = args
Expand Down
1 change: 0 additions & 1 deletion tests/test_clean.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from __future__ import print_function
from textwrap import dedent
# Assuming you are using the mock library to ... mock things
from unittest.mock import patch, call

Expand Down
4 changes: 2 additions & 2 deletions tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,15 @@ def test_prunePaths(self) -> None:
}
with patch.object(os, "environ", fake_env):
prunePaths("/sw")
self.assertTrue(not "ROOT_VERSION" in fake_env)
self.assertTrue("ROOT_VERSION" not in fake_env)
self.assertTrue(fake_env["PATH"] == "/usr/local/bin")
self.assertTrue(fake_env["LD_LIBRARY_PATH"] == "")
self.assertTrue(fake_env["DYLD_LIBRARY_PATH"] == "")
self.assertTrue(fake_env["ALIBUILD_VERSION"] == "v1.0.0")

with patch.object(os, "environ", fake_env_copy):
prunePaths("/foo")
self.assertTrue(not "ROOT_VERSION" in fake_env_copy)
self.assertTrue("ROOT_VERSION" not in fake_env_copy)
self.assertTrue(fake_env_copy["PATH"] == "/sw/bin:/usr/local/bin")
self.assertTrue(fake_env_copy["LD_LIBRARY_PATH"] == "/sw/lib")
self.assertTrue(fake_env_copy["DYLD_LIBRARY_PATH"] == "/sw/lib")
Expand Down
Loading