def test_serialization_and_deserialization_leads_to_identity( dependency_graph: DependencyGraph, ): assert DependencyGraph.deserialize( dependency_graph.serialize()) == dependency_graph
def _read_dependency_graph(self) -> DependencyGraph: with open(self._dependency_graph_output_path()) as f: return DependencyGraph.deserialize(f.read())
def main( version: str, verbose: int, quiet: int, nix_shell: Optional[str], nix_path: List[str], basename: str, extra_build_inputs: List[str], emit_extra_build_inputs: bool, extra_env: str, enable_tests: bool, python_version_argument: str, requirements: List[str], editable: List[str], setup_requires: List[str], overrides: List[NetworkFile], default_overrides: bool, wheels_cache: List[str], build_directory: Optional[str], dependency_graph_output: Optional[str], dependency_graph_input: Optional[NetworkFile], ) -> None: overrides_list: List[Overrides] = [] if version: click.echo(pypi2nix_version) exit(0) verbosity = verbosity_from_int(verbose - quiet + DEFAULT_VERBOSITY) nix_executable_directory: Optional[str] if nix_shell is None: nix_executable_directory = None else: if not os.path.isfile(nix_shell): raise click.exceptions.UsageError( f"Specified `nix-shell` executable `{nix_shell}` does not exist." ) else: nix_executable_directory = os.path.dirname( os.path.abspath(nix_shell)) overrides_list += [ OverridesNetworkFile(network_file) for network_file in overrides ] if default_overrides: overrides_list += tuple([ OverridesGithub( owner="nix-community", repo="pypi2nix-overrides", path="overrides.nix", ) ]) python_version = getattr(PythonVersion, python_version_argument, None) if python_version is None: raise click.exceptions.UsageError( f"Python version `{python_version_argument}` not available") project_directory_context: ProjectDirectory = ( TemporaryProjectDirectory() if build_directory is None else PersistentProjectDirectory(path=build_directory)) if dependency_graph_input: dependency_graph = DependencyGraph.deserialize( dependency_graph_input.fetch()) else: dependency_graph = DependencyGraph() with project_directory_context as _project_directory: configuration = ApplicationConfiguration( emit_extra_build_inputs=emit_extra_build_inputs, enable_tests=enable_tests, extra_build_inputs=args_as_list(extra_build_inputs), extra_environment=extra_env, nix_executable_directory=nix_executable_directory, nix_path=nix_path, output_basename=basename, overrides=overrides_list, python_version=python_version, requirement_files=requirements, requirements=editable, setup_requirements=setup_requires, verbosity=verbosity, wheels_caches=wheels_cache, project_directory=_project_directory, target_directory=os.getcwd(), dependency_graph_output_location=Path(dependency_graph_output) if dependency_graph_output else None, dependency_graph_input=dependency_graph, ) Pypi2nix(configuration).run()