from typing import Iterator, Sequence

REL_GT: int
REL_EQ: int
REL_LT: int
REL_AND: int
REL_OR: int
REL_WITH: int
REL_NAMESPACE: int
REL_ARCH: int
REL_FILECONFLICT: int
REL_COND: int
REL_COMPAT: int
REL_KIND: int
REL_MULTIARCH: int
REL_ELSE: int
REL_ERROR: int
REL_WITHOUT: int
REL_UNLESS: int
REL_CONDA: int


def xfopen(path: str, mode: str = ...) -> XFile: ...
def xfopen_fd(path: str, fd: int) -> XFile: ...


class XFile:
	def close(self) -> None: ...


class Dep:
	...


class Pool:
	DISTTYPE_RPM: int
	DISTTYPE_DEB: int
	DISTTYPE_ARCH: int
	DISTTYPE_HAIKU: int
	DISTTYPE_CONDA: int
	DISTTYPE_APK: int

	installed: Repo | None
	repos: list[Repo]

	def setdisttype(self, disttype: int) -> None: ...
	def setarch(self, arch: str) -> None: ...
	def add_repo(self, name: str) -> Repo: ...
	def createwhatprovides(self) -> None: ...
	def str2id(self, s: str, create: bool = ...) -> int: ...
	def rel2id(self, name: int, evr: int, flags: int, create: bool = ...) -> int: ...
	def dep2str(self, dep: int) -> str: ...
	def id2str(self, id: int) -> str: ...
	def select(self, name: str, flags: int) -> Selection: ...
	def Solver(self) -> Solver: ...
	def Selection(self) -> Selection: ...
	def Selection_all(self) -> Selection: ...
	def Job(self, how: int, what: int) -> Job: ...
	def Dep(self, s: str, create: bool = ...) -> Dep: ...
	def isknownarch(self, id: int) -> bool: ...
	def set_debuglevel(self, level: int) -> None: ...
	def set_flag(self, flag: int, value: int) -> int: ...
	def get_flag(self, flag: int) -> int: ...
	def set_rootdir(self, rootdir: str) -> None: ...
	def get_rootdir(self) -> str: ...
	def repos_iter(self) -> Iterator[Repo]: ...
	def solvables_iter(self) -> Iterator[Solvable]: ...
	def id2repo(self, id: int) -> Repo | None: ...
	def id2solvable(self, id: int) -> Solvable: ...


class Repo:
	REPO_EXTEND_SOLVABLES: int
	REPO_LOCALPOOL: int
	REPO_NO_INTERNALIZE: int
	REPO_NO_LOCATION: int
	REPO_REUSE_REPODATA: int
	REPO_USE_LOADING: int
	REPO_USE_ROOTDIR: int
	SOLV_ADD_NO_STUBS: int

	name: str
	nsolvables: int
	id: int
	pool: Pool

	def add_solvable(self) -> Solvable: ...
	def add_solv(self, f: XFile, flags: int = ...) -> bool: ...
	def add_rpmmd(self, f: XFile, language: str | None, flags: int = ...) -> bool: ...
	def add_repomdxml(self, f: XFile, flags: int = ...) -> bool: ...
	def write(self, f: XFile) -> bool: ...
	def write_first_repodata(self, f: XFile) -> bool: ...
	def internalize(self) -> None: ...
	def isempty(self) -> bool: ...
	def empty(self) -> None: ...
	def free(self, reuseids: bool = ...) -> None: ...
	def solvables_iter(self) -> Iterator[Solvable]: ...
	def Selection(self, flags: int = ...) -> Selection: ...


class Solvable:
	name: str
	evr: str
	arch: str
	nameid: int
	evrid: int
	archid: int
	id: int
	repo: Repo
	pool: Pool
	vendor: str
	vendorid: int

	def add_provides(self, dep: int) -> None: ...
	def add_requires(self, dep: int) -> None: ...
	def add_conflicts(self, dep: int) -> None: ...
	def add_obsoletes(self, dep: int) -> None: ...
	def add_recommends(self, dep: int) -> None: ...
	def add_suggests(self, dep: int) -> None: ...
	def add_supplements(self, dep: int) -> None: ...
	def add_enhances(self, dep: int) -> None: ...
	def add_deparray(self, keyname: int, dep: int, marker: int = ...) -> None: ...
	def installable(self) -> bool: ...
	def isinstalled(self) -> bool: ...
	def identical(self, other: Solvable) -> bool: ...
	def evrcmp(self, other: Solvable) -> int: ...
	def matchesdep(self, keyname: int, dep: int, marker: int = ...) -> bool: ...
	def lookup_str(self, keyname: int) -> str | None: ...
	def lookup_num(self, keyname: int, notfound: int = ...) -> int: ...
	def lookup_id(self, keyname: int) -> int: ...
	def lookup_idarray(self, keyname: int, marker: int = ...) -> list[int]: ...
	def lookup_deparray(self, keyname: int, marker: int = ...) -> list[Dep]: ...
	def lookup_checksum(self, keyname: int) -> Chksum | None: ...
	def lookup_location(self) -> tuple[str | None, int]: ...
	def lookup_sourcepkg(self) -> str | None: ...
	def lookup_void(self, keyname: int) -> bool: ...
	def Selection(self, flags: int = ...) -> Selection: ...
	def unset(self, keyname: int) -> None: ...
	def __str__(self) -> str: ...


class Solver:
	SOLVER_FLAG_ALLOW_DOWNGRADE: int
	SOLVER_FLAG_ALLOW_ARCHCHANGE: int
	SOLVER_FLAG_ALLOW_VENDORCHANGE: int
	SOLVER_FLAG_ALLOW_UNINSTALL: int
	SOLVER_FLAG_ALLOW_NAMECHANGE: int
	SOLVER_FLAG_SPLITPROVIDES: int
	SOLVER_FLAG_IGNORE_RECOMMENDED: int
	SOLVER_FLAG_ADD_ALREADY_RECOMMENDED: int
	SOLVER_FLAG_NO_INFARCHCHECK: int
	SOLVER_FLAG_BEST_OBEY_POLICY: int
	SOLVER_FLAG_NO_AUTOTARGET: int
	SOLVER_FLAG_FOCUS_INSTALLED: int
	SOLVER_FLAG_FOCUS_BEST: int
	SOLVER_FLAG_INSTALL_ALSO_UPDATES: int
	SOLVER_FLAG_STRICT_REPO_PRIORITY: int

	def solve(self, jobs: Sequence[Job]) -> list[Problem]: ...
	def transaction(self) -> Transaction: ...
	def write_testcase(self, path: str) -> bool: ...


class Problem:
	def __str__(self) -> str: ...


class Selection:
	SELECTION_NAME: int
	SELECTION_PROVIDES: int
	SELECTION_FILELIST: int
	SELECTION_CANON: int
	SELECTION_DOTARCH: int
	SELECTION_REL: int
	SELECTION_INSTALLED_ONLY: int
	SELECTION_GLOB: int
	SELECTION_FLAT: int
	SELECTION_NOCASE: int
	SELECTION_SOURCE_ONLY: int
	SELECTION_WITH_SOURCE: int
	SELECTION_SKIP_KIND: int
	SELECTION_MATCH_DEPSTR: int
	SELECTION_WITH_DISABLED: int
	SELECTION_WITH_BADARCH: int
	SELECTION_WITH_ALL: int
	SELECTION_ADD: int
	SELECTION_SUBTRACT: int
	SELECTION_FILTER: int
	SELECTION_FILTER_KEEP_IFEMPTY: int
	SELECTION_FILTER_SWAPPED: int

	def isempty(self) -> bool: ...
	def jobs(self, action: int) -> list[Job]: ...
	def solvables(self) -> list[Solvable]: ...
	def select(self, name: str, flags: int) -> None: ...
	def add_raw(self, how: int, what: int) -> None: ...


class Job:
	SOLVER_INSTALL: int
	SOLVER_ERASE: int
	SOLVER_UPDATE: int
	SOLVER_WEAKENDEPS: int
	SOLVER_MULTIVERSION: int
	SOLVER_LOCK: int
	SOLVER_DISTUPGRADE: int
	SOLVER_VERIFY: int
	SOLVER_DROP_ORPHANED: int
	SOLVER_USERINSTALLED: int
	SOLVER_ALLOWUNINSTALL: int
	SOLVER_FAVOR: int
	SOLVER_DISFAVOR: int
	SOLVER_EXCLUDEFROMWEAK: int
	SOLVER_SOLVABLE: int
	SOLVER_SOLVABLE_NAME: int
	SOLVER_SOLVABLE_PROVIDES: int
	SOLVER_SOLVABLE_ONE_OF: int
	SOLVER_SOLVABLE_REPO: int
	SOLVER_SOLVABLE_ALL: int
	SOLVER_SELECTMASK: int
	SOLVER_JOBMASK: int
	SOLVER_NOOP: int
	SOLVER_WEAK: int
	SOLVER_ESSENTIAL: int
	SOLVER_CLEANDEPS: int
	SOLVER_FORCEBEST: int
	SOLVER_TARGETED: int
	SOLVER_NOTBYUSER: int
	SOLVER_SETEV: int
	SOLVER_SETEVR: int
	SOLVER_SETARCH: int
	SOLVER_SETVENDOR: int
	SOLVER_SETREPO: int
	SOLVER_SETNAME: int
	SOLVER_NOAUTOSET: int
	SOLVER_SETMASK: int

	def isemptyupdate(self) -> bool: ...


class Transaction:
	pool: Pool

	def isempty(self) -> bool: ...
	def newsolvables(self) -> list[Solvable]: ...
	def keptsolvables(self) -> list[Solvable]: ...
	def newpackages(self) -> list[Solvable]: ...
	def keptpackages(self) -> list[Solvable]: ...
	def steps(self) -> list[Solvable]: ...
	def steptype(self, solvable: Solvable, mode: int) -> int: ...
	def othersolvable(self, solvable: Solvable) -> Solvable | None: ...
	def allothersolvables(self, solvable: Solvable) -> list[Solvable]: ...
	def calc_installsizechange(self) -> int: ...
	def order(self, flags: int = ...) -> None: ...
	def classify(self, mode: int = ...) -> list[TransactionClass]: ...


class TransactionClass:
	...


class Chksum:
	...
