def matching_spec_from_env(spec): """ Returns a concrete spec, matching what is available in the environment. If no matching spec is found in the environment (or if no environment is active), this will return the given spec but concretized. """ env = ev.active_environment() if env: return env.matching_spec(spec) or spec.concretized() else: return spec.concretized()
def test_legacy_yaml(tmpdir, install_mockery, mock_packages): """Tests a simple legacy YAML with a dependency and ensures spec survives concretization.""" yaml = """ spec: - a: version: '2.0' arch: platform: linux platform_os: rhel7 target: x86_64 compiler: name: gcc version: 8.3.0 namespace: builtin.mock parameters: bvv: true foo: - bar foobar: bar cflags: [] cppflags: [] cxxflags: [] fflags: [] ldflags: [] ldlibs: [] dependencies: b: hash: iaapywazxgetn6gfv2cfba353qzzqvhn type: - build - link hash: obokmcsn3hljztrmctbscmqjs3xclazz full_hash: avrk2tqsnzxeabmxa6r776uq7qbpeufv build_hash: obokmcsn3hljztrmctbscmqjs3xclazy - b: version: '1.0' arch: platform: linux platform_os: rhel7 target: x86_64 compiler: name: gcc version: 8.3.0 namespace: builtin.mock parameters: cflags: [] cppflags: [] cxxflags: [] fflags: [] ldflags: [] ldlibs: [] hash: iaapywazxgetn6gfv2cfba353qzzqvhn full_hash: qvsxvlmjaothtpjluqijv7qfnni3kyyg build_hash: iaapywazxgetn6gfv2cfba353qzzqvhy """ spec = Spec.from_yaml(yaml) concrete_spec = spec.concretized() assert concrete_spec.eq_dag(spec)
def install(self, user_spec, concrete_spec=None, **install_args): """Install a single spec into an environment. This will automatically concretize the single spec, but it won't affect other as-yet unconcretized specs. """ spec = Spec(user_spec) if self.add(spec): concrete = concrete_spec if concrete_spec else spec.concretized() self._add_concrete_spec(spec, concrete) else: # spec might be in the user_specs, but not installed. spec = next(s for s in self.user_specs if s.name == spec.name) concrete = self.specs_by_hash.get(spec.dag_hash()) if not concrete: concrete = spec.concretized() self._add_concrete_spec(spec, concrete) concrete.package.do_install(**install_args)
def install(self, user_spec, concrete_spec=None, **install_args): """Install a single spec into an environment. This will automatically concretize the single spec, but it won't affect other as-yet unconcretized specs. """ spec = Spec(user_spec) if self.add(spec): concrete = concrete_spec if concrete_spec else spec.concretized() self._add_concrete_spec(spec, concrete) else: # spec might be in the user_specs, but not installed. # TODO: Redo name-based comparison for old style envs spec = next(s for s in self.user_specs if s.satisfies(user_spec)) concrete = self.specs_by_hash.get(spec.build_hash()) if not concrete: concrete = spec.concretized() self._add_concrete_spec(spec, concrete) self._install(concrete, **install_args)