Skip to content

Commit

Permalink
support extras
Browse files Browse the repository at this point in the history
  • Loading branch information
jonapich committed Apr 12, 2024
1 parent d0f4a7c commit 7de26c0
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
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
20 changes: 15 additions & 5 deletions coveo_stew/metadata/stew_api.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
from typing import Any, Mapping
from typing import Any, Mapping, Optional, List

from coveo_stew.metadata.poetry_api import dependencies_factory
from coveo_styles.styles import echo


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."
)
4 changes: 4 additions & 0 deletions coveo_stew/stew.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ def install(
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:
command.extend(["--extras", extra] for extra in self.options.extras)

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

0 comments on commit 7de26c0

Please sign in to comment.