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

fix: "extras" and "all-extras" not applied for environments created by stew #62

Merged
merged 3 commits into from
Oct 17, 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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ quick = {}
- **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.
- **extras**: A list of extras to install during `stew build` and `stew ci`.
- **all-extras**: If true, all extras will be installed during `stew build` and `stew ci`. Overrides the `extras` list.
- **quick**: *(v3.0.30)* Controls which checks are skipped when calling `stew ci --quick`.
- The format is a dictionary with either the `check` or `skip` key, followed by a list of runners.
- The behavior is identical to the `--check` and `--skip` options.
Expand Down
28 changes: 18 additions & 10 deletions coveo_stew/stew.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,18 @@ def _create_default_poetry_install(
) -> PythonEnvironment:
"""To be used only when no environments exist. Creates a default one by calling "poetry install"."""
if install is EnvironmentCreationBehavior.Full:
self.poetry_run("install")
command = self._generate_poetry_install_command()
elif install is EnvironmentCreationBehavior.NoDev:
self.poetry_run("install", "--no-dev")
command = self._generate_poetry_install_command()
command.append("--no-dev")
else:
assert install is EnvironmentCreationBehavior.Empty
try:
self.poetry_run("env", "use", "python3")
command = ["env", "use", "python3"]
except CalledProcessError:
self.poetry_run("env", "use", "python")
command = ["env", "use", "python"]

self.poetry_run(*command)

del self._virtual_environments_cache # force cache refresh
activated_environment = self.activated_environment()
Expand Down Expand Up @@ -333,20 +336,25 @@ def install(
# return unless we are cleaning a non-cleaned environment
return

command = self._generate_poetry_install_command(target_environment if sync else None, quiet)
self.poetry_run(*command, environment=target_environment)
target_environment.installed = True
target_environment.cleaned |= sync

def _generate_poetry_install_command(
self, sync_target_environment: Optional[PythonEnvironment] = None, quiet: bool = False
) -> List[str]:
command: List[str] = ["install"]
if sync:
command.append(get_verb("--sync", target_environment))
if sync_target_environment:
command.append(get_verb("--sync", 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
target_environment.cleaned |= sync
return command

def remove_egg_info(self) -> bool:
"""Removes the egg-info (editable project hook) from the folder. Returns True if we removed it."""
Expand Down
Loading