mirror of
https://github.com/enpaul/tox-poetry-installer.git
synced 2024-10-29 19:47:00 +00:00
Update transient dep resolution to always exclude root package name
Fixes #37
This commit is contained in:
parent
6e535f0f42
commit
366c50ac87
@ -112,7 +112,9 @@ def tox_testenv_install_deps(venv: ToxVirtualEnv, action: ToxAction) -> Optional
|
|||||||
|
|
||||||
env_deps: List[PoetryPackage] = []
|
env_deps: List[PoetryPackage] = []
|
||||||
for dep in venv.envconfig.locked_deps:
|
for dep in venv.envconfig.locked_deps:
|
||||||
env_deps += utilities.find_transients(package_map, dep.lower())
|
env_deps += utilities.find_transients(
|
||||||
|
package_map, dep.lower(), allow_missing=[poetry.package.name]
|
||||||
|
)
|
||||||
reporter.verbosity1(
|
reporter.verbosity1(
|
||||||
f"{constants.REPORTER_PREFIX} Identified {len(env_deps)} environment dependencies to install to env"
|
f"{constants.REPORTER_PREFIX} Identified {len(env_deps)} environment dependencies to install to env"
|
||||||
)
|
)
|
||||||
|
@ -48,13 +48,17 @@ def install_to_venv(
|
|||||||
installer.install(dependency)
|
installer.install(dependency)
|
||||||
|
|
||||||
|
|
||||||
def find_transients(packages: PackageMap, dependency_name: str) -> Set[PoetryPackage]:
|
def find_transients(
|
||||||
|
packages: PackageMap, dependency_name: str, allow_missing: Sequence[str] = ()
|
||||||
|
) -> Set[PoetryPackage]:
|
||||||
"""Using a poetry object identify all dependencies of a specific dependency
|
"""Using a poetry object identify all dependencies of a specific dependency
|
||||||
|
|
||||||
:param poetry: Populated poetry object which can be used to build a populated locked
|
:param packages: All packages from the lockfile to use for identifying dependency relationships.
|
||||||
repository object.
|
|
||||||
:param dependency_name: Bare name (without version) of the dependency to fetch the transient
|
:param dependency_name: Bare name (without version) of the dependency to fetch the transient
|
||||||
dependencies of.
|
dependencies of.
|
||||||
|
:param allow_missing: Sequence of package names to allow to be missing from the lockfile. Any
|
||||||
|
packages that are not found in the lockfile but their name appears in this
|
||||||
|
list will be silently skipped from installation.
|
||||||
:returns: List of packages that need to be installed for the requested dependency.
|
:returns: List of packages that need to be installed for the requested dependency.
|
||||||
|
|
||||||
.. note:: The package corresponding to the dependency named by ``dependency_name`` is included
|
.. note:: The package corresponding to the dependency named by ``dependency_name`` is included
|
||||||
@ -75,7 +79,15 @@ def find_transients(packages: PackageMap, dependency_name: str) -> Set[PoetryPac
|
|||||||
return dict()
|
return dict()
|
||||||
|
|
||||||
transients: PackageMap = {}
|
transients: PackageMap = {}
|
||||||
package = packages[name]
|
try:
|
||||||
|
package = packages[name]
|
||||||
|
except KeyError as err:
|
||||||
|
if name in allow_missing:
|
||||||
|
reporter.verbosity2(
|
||||||
|
f"{constants.REPORTER_PREFIX} Skip {name}: package is not in lockfile but designated as allowed to be missing"
|
||||||
|
)
|
||||||
|
return dict()
|
||||||
|
raise err
|
||||||
|
|
||||||
if not package.python_constraint.allows(constants.PLATFORM_VERSION):
|
if not package.python_constraint.allows(constants.PLATFORM_VERSION):
|
||||||
reporter.verbosity2(
|
reporter.verbosity2(
|
||||||
@ -190,6 +202,8 @@ def find_project_dependencies(
|
|||||||
|
|
||||||
dependencies: List[PoetryPackage] = []
|
dependencies: List[PoetryPackage] = []
|
||||||
for dep in base_dependencies + extra_dependencies:
|
for dep in base_dependencies + extra_dependencies:
|
||||||
dependencies += find_transients(packages, dep.name.lower())
|
dependencies += find_transients(
|
||||||
|
packages, dep.name.lower(), allow_missing=[poetry.package.name]
|
||||||
|
)
|
||||||
|
|
||||||
return dependencies
|
return dependencies
|
||||||
|
Loading…
Reference in New Issue
Block a user