Some more refactoring.
This commit is contained in:
parent
dd14deb00d
commit
7c61fa0e43
6 changed files with 39 additions and 28 deletions
|
@ -23,7 +23,7 @@ from .buildsystem import NoBuildToolsFound, detect_buildsystems
|
||||||
from .resolver import (
|
from .resolver import (
|
||||||
auto_resolver,
|
auto_resolver,
|
||||||
native_resolvers,
|
native_resolvers,
|
||||||
MissingDependencies,
|
UnsatisfiedRequirements,
|
||||||
)
|
)
|
||||||
from .resolver.apt import AptResolver
|
from .resolver.apt import AptResolver
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,6 @@ class SetupPy(BuildSystem):
|
||||||
return "%s(%r)" % (type(self).__name__, self.path)
|
return "%s(%r)" % (type(self).__name__, self.path)
|
||||||
|
|
||||||
def setup(self, resolver):
|
def setup(self, resolver):
|
||||||
resolver.install([PythonPackageRequirement('pip')])
|
|
||||||
with open(self.path, "r") as f:
|
with open(self.path, "r") as f:
|
||||||
setup_py_contents = f.read()
|
setup_py_contents = f.read()
|
||||||
try:
|
try:
|
||||||
|
@ -222,10 +221,9 @@ class PyProject(BuildSystem):
|
||||||
resolver.install(
|
resolver.install(
|
||||||
[
|
[
|
||||||
PythonPackageRequirement("venv"),
|
PythonPackageRequirement("venv"),
|
||||||
PythonPackageRequirement("pip"),
|
PythonPackageRequirement("poetry"),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
session.check_call(["pip3", "install", "poetry"], user="root")
|
|
||||||
session.check_call(["poetry", "build", "-f", "sdist"])
|
session.check_call(["poetry", "build", "-f", "sdist"])
|
||||||
return
|
return
|
||||||
raise AssertionError("no supported section in pyproject.toml")
|
raise AssertionError("no supported section in pyproject.toml")
|
||||||
|
@ -242,7 +240,6 @@ class SetupCfg(BuildSystem):
|
||||||
resolver.install(
|
resolver.install(
|
||||||
[
|
[
|
||||||
PythonPackageRequirement("pep517"),
|
PythonPackageRequirement("pep517"),
|
||||||
PythonPackageRequirement("pip"),
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -125,6 +125,7 @@ def create_dist_schroot(
|
||||||
) -> str:
|
) -> str:
|
||||||
from .buildsystem import detect_buildsystems
|
from .buildsystem import detect_buildsystems
|
||||||
from .resolver.apt import AptResolver
|
from .resolver.apt import AptResolver
|
||||||
|
from .buildlog import UpstreamRequirementFixer
|
||||||
|
|
||||||
if subdir is None:
|
if subdir is None:
|
||||||
subdir = "package"
|
subdir = "package"
|
||||||
|
@ -150,13 +151,14 @@ def create_dist_schroot(
|
||||||
|
|
||||||
buildsystems = list(detect_buildsystems(export_directory))
|
buildsystems = list(detect_buildsystems(export_directory))
|
||||||
resolver = AptResolver.from_session(session)
|
resolver = AptResolver.from_session(session)
|
||||||
|
fixers = [UpstreamRequirementFixer(resolver)]
|
||||||
|
|
||||||
with DistCatcher(export_directory) as dc:
|
with DistCatcher(export_directory) as dc:
|
||||||
oldcwd = os.getcwd()
|
oldcwd = os.getcwd()
|
||||||
os.chdir(export_directory)
|
os.chdir(export_directory)
|
||||||
try:
|
try:
|
||||||
session.chdir(os.path.join(reldir, subdir))
|
session.chdir(os.path.join(reldir, subdir))
|
||||||
run_dist(session, buildsystems, resolver)
|
run_dist(session, buildsystems, resolver, fixers)
|
||||||
finally:
|
finally:
|
||||||
os.chdir(oldcwd)
|
os.chdir(oldcwd)
|
||||||
|
|
||||||
|
@ -194,9 +196,17 @@ if __name__ == "__main__":
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--target-directory", type=str, default="..", help="Target directory"
|
"--target-directory", type=str, default="..", help="Target directory"
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--verbose",
|
||||||
|
action="store_true",
|
||||||
|
help="Be verbose")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
if args.verbose:
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
else:
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
tree = WorkingTree.open(args.directory)
|
tree = WorkingTree.open(args.directory)
|
||||||
if args.packaging_directory:
|
if args.packaging_directory:
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
|
||||||
class MissingDependencies(Exception):
|
class UnsatisfiedRequirements(Exception):
|
||||||
|
|
||||||
def __init__(self, reqs):
|
def __init__(self, reqs):
|
||||||
self.requirements = reqs
|
self.requirements = reqs
|
||||||
|
@ -55,7 +55,7 @@ class CPANResolver(Resolver):
|
||||||
user="root", env={"PERL_MM_USE_DEFAULT": "1"}
|
user="root", env={"PERL_MM_USE_DEFAULT": "1"}
|
||||||
)
|
)
|
||||||
if missing:
|
if missing:
|
||||||
raise MissingDependencies(missing)
|
raise UnsatisfiedRequirements(missing)
|
||||||
|
|
||||||
def explain(self, requirements):
|
def explain(self, requirements):
|
||||||
raise NotImplementedError(self.explain)
|
raise NotImplementedError(self.explain)
|
||||||
|
@ -83,7 +83,7 @@ class CargoResolver(Resolver):
|
||||||
["cargo", "install", requirement.crate],
|
["cargo", "install", requirement.crate],
|
||||||
user="root")
|
user="root")
|
||||||
if missing:
|
if missing:
|
||||||
raise MissingDependencies(missing)
|
raise UnsatisfiedRequirements(missing)
|
||||||
|
|
||||||
def explain(self, requirements):
|
def explain(self, requirements):
|
||||||
raise NotImplementedError(self.explain)
|
raise NotImplementedError(self.explain)
|
||||||
|
@ -109,7 +109,7 @@ class PypiResolver(Resolver):
|
||||||
continue
|
continue
|
||||||
self.session.check_call(["pip", "install", requirement.package])
|
self.session.check_call(["pip", "install", requirement.package])
|
||||||
if missing:
|
if missing:
|
||||||
raise MissingDependencies(missing)
|
raise UnsatisfiedRequirements(missing)
|
||||||
|
|
||||||
def explain(self, requirements):
|
def explain(self, requirements):
|
||||||
raise NotImplementedError(self.explain)
|
raise NotImplementedError(self.explain)
|
||||||
|
@ -145,7 +145,7 @@ class NpmResolver(Resolver):
|
||||||
continue
|
continue
|
||||||
self.session.check_call(["npm", "-g", "install", package])
|
self.session.check_call(["npm", "-g", "install", package])
|
||||||
if missing:
|
if missing:
|
||||||
raise MissingDependencies(missing)
|
raise UnsatisfiedRequirements(missing)
|
||||||
|
|
||||||
def explain(self, requirements):
|
def explain(self, requirements):
|
||||||
raise NotImplementedError(self.explain)
|
raise NotImplementedError(self.explain)
|
||||||
|
@ -165,7 +165,7 @@ class StackedResolver(Resolver):
|
||||||
for sub in self.subs:
|
for sub in self.subs:
|
||||||
try:
|
try:
|
||||||
sub.install(requirements)
|
sub.install(requirements)
|
||||||
except MissingDependencies as e:
|
except UnsatisfiedRequirements as e:
|
||||||
requirements = e.requirements
|
requirements = e.requirements
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
@ -188,7 +188,7 @@ class ExplainResolver(Resolver):
|
||||||
return cls(session)
|
return cls(session)
|
||||||
|
|
||||||
def install(self, requirements):
|
def install(self, requirements):
|
||||||
raise MissingDependencies(requirements)
|
raise UnsatisfiedRequirements(requirements)
|
||||||
|
|
||||||
|
|
||||||
def auto_resolver(session):
|
def auto_resolver(session):
|
||||||
|
|
|
@ -21,7 +21,7 @@ import posixpath
|
||||||
|
|
||||||
from ..debian.apt import AptManager
|
from ..debian.apt import AptManager
|
||||||
|
|
||||||
from . import Resolver, MissingDependencies
|
from . import Resolver, UnsatisfiedRequirements
|
||||||
from ..requirements import (
|
from ..requirements import (
|
||||||
BinaryRequirement,
|
BinaryRequirement,
|
||||||
CHeaderRequirement,
|
CHeaderRequirement,
|
||||||
|
@ -520,19 +520,20 @@ class AptResolver(Resolver):
|
||||||
missing.append(req)
|
missing.append(req)
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
missing.append(req)
|
missing.append(req)
|
||||||
if missing:
|
if not missing:
|
||||||
still_missing = []
|
return
|
||||||
apt_requirements = []
|
still_missing = []
|
||||||
for m in missing:
|
apt_requirements = []
|
||||||
apt_req = self.resolve(m)
|
for m in missing:
|
||||||
if apt_req is None:
|
apt_req = self.resolve(m)
|
||||||
still_missing.append(m)
|
if apt_req is None:
|
||||||
else:
|
still_missing.append(m)
|
||||||
apt_requirements.append(m)
|
else:
|
||||||
self.apt.install(
|
apt_requirements.append(m)
|
||||||
[req.package for req in apt_requirements])
|
self.apt.install(
|
||||||
if still_missing:
|
[req.package for req in apt_requirements])
|
||||||
raise MissingDependencies(still_missing)
|
if still_missing:
|
||||||
|
raise UnsatisfiedRequirements(still_missing)
|
||||||
|
|
||||||
def explain(self, requirements):
|
def explain(self, requirements):
|
||||||
raise NotImplementedError(self.explain)
|
raise NotImplementedError(self.explain)
|
||||||
|
|
|
@ -61,6 +61,9 @@ class SchrootSession(Session):
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
# TODO(jelmer): Capture stderr and forward in SessionSetupFailure
|
# TODO(jelmer): Capture stderr and forward in SessionSetupFailure
|
||||||
raise SessionSetupFailure()
|
raise SessionSetupFailure()
|
||||||
|
logging.info(
|
||||||
|
'Opened schroot session %s (from %s)', self.session_id,
|
||||||
|
self.chroot)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue