Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: remove unused functions and overrides #310

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,31 +333,6 @@ def get_build_sdist_dependencies(ctx, req, sdist_root_dir):
)
```

### get_install_dependencies

The `get_install_dependencies()` function should return the PEP 517
installation and runtime dependencies for a package.

The arguments are the `WorkContext`, the `Requirement` being
evaluated, and the `Path` to the root of the source tree.

The return value is an iterable of requirement specification strings
for runtime and installation dependencies for the package. The caller
is responsible for evaluating the requirements with the current build
environment settings to determine if they are actually needed.

```python
# pyarrow.py
def get_install_dependencies(ctx, req, sdist_root_dir):
# The _actual_ directory with our requirements is different than
# the source root directory detected for the build because the
# source tree doesn't just include the python package.
return dependencies.default_get_install_dependencies(
ctx, req,
sdist_root_dir / 'python',
)
```

### build_sdist

The `build_sdist()` function is responsible for creating a new source
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ fromager_test = "fromager.example_override"
get_build_system_dependencies = "fromager.dependencies:default_get_build_system_dependencies"
get_build_backend_dependencies = "fromager.dependencies:default_get_build_backend_dependencies"
get_build_sdist_dependencies = "fromager.dependencies:default_get_build_sdist_dependencies"
get_install_dependencies = "fromager.dependencies:default_get_install_dependencies"
resolver_provider = "fromager.sources:default_resolver_provider"
download_source = "fromager.sources:default_download_source"
build_sdist = "fromager.sources:default_build_sdist"
Expand Down
28 changes: 0 additions & 28 deletions src/fromager/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
import logging
import os
import pathlib
import shutil
import typing

import pkginfo
import pyproject_hooks
import tomlkit
from packaging import metadata
from packaging.requirements import Requirement

from . import context, external_commands, overrides, requirements_file
Expand Down Expand Up @@ -178,32 +176,6 @@ def get_install_dependencies_of_wheel(
return deps


def default_get_install_dependencies(
ctx: context.WorkContext,
req: Requirement,
sdist_root_dir: pathlib.Path,
) -> set[Requirement]:
pyproject_toml = get_pyproject_contents(sdist_root_dir)
requires = set()
extra_environ = overrides.extra_environ_for_pkg(ctx.envs_dir, req.name, ctx.variant)
hook_caller = get_build_backend_hook_caller(
sdist_root_dir, pyproject_toml, override_environ=extra_environ
)

# Clean up any existing dist-info so we don't get an error regenerating it.
for info_dir in sdist_root_dir.glob("*.dist-info"):
logger.debug(f"{req.name}: removing existing dist-info dir {info_dir}")
shutil.rmtree(info_dir)

metadata_path = hook_caller.prepare_metadata_for_build_wheel(str(sdist_root_dir))
with open(os.path.join(sdist_root_dir, metadata_path, "METADATA"), "r") as f:
parsed = metadata.Metadata.from_email(f.read(), validate=False)
for r in parsed.requires_dist or []:
if requirements_file.evaluate_marker(req, r, req.extras):
requires.add(r)
return requires


def get_pyproject_contents(sdist_root_dir: pathlib.Path) -> dict[str, typing.Any]:
pyproject_toml_filename = sdist_root_dir / "pyproject.toml"
if not os.path.exists(pyproject_toml_filename):
Expand Down
Loading