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: use optional-dependencies as preferred variant to custom dev-dependencies #1590

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
11 changes: 9 additions & 2 deletions bench/utils/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,15 @@ def install_python_dev_dependencies(bench_path=".", apps=None, verbose=False):
dev_requirements_path = os.path.join(app_path, "dev-requirements.txt")

if os.path.exists(pyproject_path):
pyproject_deps = _generate_dev_deps_pattern(pyproject_path)
if pyproject_deps:
try:
from tomli import loads
except ImportError:
from tomllib import loads

pyroject_config = loads(open(pyproject_path).read())
for key, deps in pyroject_config["project"]["optional-dependencies"].items():
bench.run(f"{bench.python} -m pip install {quiet_flag} --upgrade {' '.join(deps)}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this could just be moved into the function that installs the apps instead

bench.run(f"{bench.python} -m pip install {quiet_flag} --upgrade -e './apps/{app}[{', '.join(pyroject_config["project"]["optional-dependencies"])}]'

Let pip worry about the entire env management

Given we are using the standard to define optional dependencies, I wonder if we could just retire bench.dev-dependencies in favour of the standard.

Copy link
Contributor Author

@blaggacao blaggacao Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this could just be moved into the function that installs the apps instead

If "install app" can be equated to "install optional deps, as well", then yes, indeed.

retire tools.bench.dev-dependencies

Yes that makes sense, absolutely!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For development setups, installing optional dependencies should be ok, although if I go through the effort of making separate groups, I would expect more control.

So, I'm not sure automatically installing the different "optional-dependencies" groups would be the best course of action. Passing --install-optional-dependencies=dev,test sounds like a saner path to take, also adding a warning/info if developer_mode is enabled on bench and optional-dependencies are present in app pyproject.toml.

if pyproject_deps := _generate_dev_deps_pattern(pyproject_path):
bench.run(f"{bench.python} -m pip install {quiet_flag} --upgrade {pyproject_deps}")

if not pyproject_deps and os.path.exists(dev_requirements_path):
Expand Down
Loading