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

support extras #50

Merged
merged 1 commit into from
Apr 15, 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
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,27 @@ $ stew locate coveo-stew

# Configuration

## stew

Configuration is done through the `pyproject.toml` file; default values are shown:

```
[tool.stew]
build-without-hashes = false
pydev = false
build-dependencies = {}
extras = []
all-extras = false
```

- **build-without-hashes**: Disables hashes when calling `pip` to download dependencies during `stew build`.
- **pydev**: See the [multiple-libraries](README_MULTIPLE_LIBRARIES.md) guide.
- **build-dependencies**: You can specify additional dependencies to be installed during `stew build`.
- The format is the same as poetry dependencies: `name = "version"` or `name = { version = "version", ... }`
- **extras**: A list of extras to install during `stew build`.
- **all-extras**: If true, all extras will be installed during `stew build`. Overrides the `extras` list.

## stew ci
Configuration is done through each `pyproject.toml` file; default values are shown:

```
Expand Down
21 changes: 16 additions & 5 deletions coveo_stew/metadata/stew_api.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
from typing import Any, Mapping
from typing import Any, List, Mapping, Optional

from coveo_styles.styles import echo

from coveo_stew.metadata.poetry_api import dependencies_factory


class StewPackage:
"""Represents the coveo-specific sections of a pyproject.toml file."""
"""Represents the stew-specific sections of a pyproject.toml file."""

def __init__(
self,
*,
build: bool = False,
build: bool = False, # deprecated
build_without_hashes: bool = False,
pydev: bool = False,
build_dependencies: Mapping[str, Any] = None,
build_dependencies: Optional[Mapping[str, Any]] = None,
extras: Optional[List[str]] = None,
all_extras: bool = False,
) -> None:
self.build = build # we won't build a project unless this is specified.
# poetry sometimes fail at getting hashes, in which case the export cannot work because pip will complain
# that some files have a hash and some don't. This fixes it.
self.build_without_hashes = build_without_hashes
self.pydev = pydev # is this a one-ring-to-bind-them-all dev environment?
# additional build-time dependencies
self.build_dependencies = dependencies_factory(build_dependencies)
self.extras = extras
self.all_extras = all_extras

if extras and all_extras:
echo.suggest(
"Both 'extras' and 'all_extras' are specified. 'extras' will be ignored; "
"consider removing it from your pyproject.toml."
)
7 changes: 6 additions & 1 deletion coveo_stew/stew.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,16 @@ def install(
# return unless we are cleaning a non-cleaned environment
return

command = ["install"]
command: List[str] = ["install"]
if sync:
command.append(get_verb("--sync", target_environment))
if quiet and not self.verbose:
command.append("--quiet")
if self.options.all_extras:
command.append("--all-extras")
elif self.options.extras:
for extra in self.options.extras:
command.extend(["--extras", extra])

self.poetry_run(*command, environment=target_environment)
target_environment.installed = True
Expand Down