wide-midnight-78598
10/15/2022, 5:08 PMmypy
uses the shim script as the python executable, but I'm wondering if we can just get the absolute venv location out of this data structure?
requirements_venv_pex = await Get(
VenvPex,
PexRequest(
output_filename="requirements_venv.pex",
internal_only=True,
pex_path=[requirements_pex],
interpreter_constraints=InterpreterConstraints(["==3.9.15"]),
),
)
requirements_venv_pex.venv_rel_dir
wide-midnight-78598
10/15/2022, 5:24 PMbitter-ability-32190
10/15/2022, 6:42 PMhappy-kitchen-89482
10/16/2022, 4:57 AMVenvPexProcess
not do what you want?bitter-ability-32190
10/16/2022, 11:19 AMwide-midnight-78598
10/16/2022, 12:40 PMwide-midnight-78598
10/16/2022, 12:42 PMvenvPath
and venv
are what I need to populate, For testing, I copied this from mypy
# See `requirements_venv_pex` for how this will get wrapped in a `VenvPex`.
requirements_pex = await Get(
Pex,
RequirementsPexRequest(
(fs.address for fs in request.field_sets),
# hardcoded_interpreter_constraints=partition.interpreter_constraints,
),
)
requirements_venv_pex = await Get(
VenvPex,
PexRequest(
output_filename="requirements_venv.pex",
internal_only=True,
pex_path=[requirements_pex],
interpreter_constraints=InterpreterConstraints(["==3.9.15"]),
),
)
wide-midnight-78598
10/16/2022, 12:46 PMNamedCachesDirOption
)?, but I didn't know if it was the correct approachbitter-ability-32190
10/16/2022, 12:50 PMwide-midnight-78598
10/16/2022, 12:50 PMwide-midnight-78598
10/16/2022, 12:50 PMbitter-ability-32190
10/16/2022, 12:50 PMwide-midnight-78598
10/16/2022, 12:51 PMdummy_config_digest = await Get(Digest, CreateDigest([FileContent("pyrightconfig.json", f'{{ "venv": "{requirements_venv_pex.venv_rel_dir}" }}'.encode())]))
NpxProcess(
npm_package=pyright.default_version,
args=(
f"--venv-path={named_cache_dir.val}/pex_root/",
*pyright.args, # User-added arguments
*source_files.snapshot.files,
),
wide-midnight-78598
10/16/2022, 12:51 PMwide-midnight-78598
10/16/2022, 12:52 PMasync def pyright_typecheck(request: PyrightRequest, pyright: Pyright, named_cache_dir: NamedCachesDirOption) -> CheckResults:
wide-midnight-78598
10/16/2022, 12:57 PMpex_roots
- I'm assuming (hoping) this venv path is stable thoughbitter-ability-32190
10/16/2022, 1:33 PMbitter-ability-32190
10/16/2022, 1:33 PMwide-midnight-78598
10/16/2022, 5:52 PMwide-midnight-78598
10/16/2022, 5:55 PM@dataclass(frozen=True)
class CompletePexEnvironment:
_pex_environment: PexEnvironment
pex_root: PurePath
_working_directory: PurePath | None
append_only_caches: FrozenDict[str, str]
_PEX_ROOT_DIRNAME = "pex_root"
But this looks interesting:
def in_sandbox(self, *, working_directory: str | None) -> CompletePexEnvironment:
pex_root = PurePath(".cache") / self._PEX_ROOT_DIRNAME
return CompletePexEnvironment(
_pex_environment=self,
pex_root=pex_root,
_working_directory=PurePath(working_directory) if working_directory else None,
append_only_caches=FrozenDict({self._PEX_ROOT_DIRNAME: str(pex_root)}),
)
and
@rule
async def setup_pex_process(request: PexProcess, pex_environment: PexEnvironment) -> Process:
pex = request.pex
complete_pex_env = pex_environment.in_sandbox(working_directory=request.working_directory)
bitter-ability-32190
10/16/2022, 10:00 PMwide-midnight-78598
10/17/2022, 12:31 AMwide-midnight-78598
10/17/2022, 12:32 AMbitter-ability-32190
10/17/2022, 12:34 AMwide-midnight-78598
10/17/2022, 12:34 AMbitter-ability-32190
10/17/2022, 12:39 AMwide-midnight-78598
10/17/2022, 12:40 AMhappy-kitchen-89482
10/17/2022, 3:23 AMhappy-kitchen-89482
10/17/2022, 3:24 AMwide-midnight-78598
10/17/2022, 3:40 AMin_sandbox(working_directory=None)
and it didnt work