-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Adapt Tools CLI to uv #1455
Merged
Adapt Tools CLI to uv #1455
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Python-generated files | ||
__pycache__/ | ||
*.py[oc] | ||
build/ | ||
dist/ | ||
wheels/ | ||
*.egg-info | ||
|
||
# Virtual environments | ||
.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
[tool.poetry] | ||
[project] | ||
name = "{{folder_name}}" | ||
version = "0.1.0" | ||
description = "Power up your crews with {{folder_name}}" | ||
authors = ["Your Name <[email protected]>"] | ||
readme = "README.md" | ||
requires-python = ">=3.10,<=3.13" | ||
dependencies = [ | ||
"crewai[tools]>=0.70.1" | ||
] | ||
|
||
[tool.poetry.dependencies] | ||
python = ">=3.10,<=3.13" | ||
crewai = { extras = ["tools"], version = ">=0.70.1,<1.0.0" } | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
import subprocess | ||
import tempfile | ||
from pathlib import Path | ||
from netrc import netrc | ||
import stat | ||
|
||
import click | ||
from rich.console import Console | ||
|
@@ -147,7 +149,7 @@ def login(self): | |
|
||
if login_response.status_code != 200: | ||
console.print( | ||
"Failed to authenticate to the tool repository. Make sure you have the access to tools.", | ||
"Authentication failed. Verify access to the tool repository, or try `crewai login`. ", | ||
style="bold red", | ||
) | ||
raise SystemExit | ||
|
@@ -159,23 +161,19 @@ def login(self): | |
"Successfully authenticated to the tool repository.", style="bold green" | ||
) | ||
|
||
def _set_netrc_credentials(self, credentials): | ||
# Create .netrc or _netrc file | ||
netrc_filename = "_netrc" if platform.system() == "Windows" else ".netrc" | ||
netrc_path = Path.home() / netrc_filename | ||
def _set_netrc_credentials(self, credentials, netrc_path=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I refactored it to use Python's builtin |
||
if not netrc_path: | ||
netrc_filename = "_netrc" if platform.system() == "Windows" else ".netrc" | ||
netrc_path = Path.home() / netrc_filename | ||
netrc_path.touch(mode=stat.S_IRUSR | stat.S_IWUSR, exist_ok=True) | ||
|
||
netrc_content = f"""machine app.crewai.com | ||
login {credentials['username']} | ||
password {credentials['password']} | ||
""" | ||
netrc_instance = netrc(file=netrc_path) | ||
netrc_instance.hosts["app.crewai.com"] = (credentials["username"], "", credentials["password"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the line we need to change after we migrate to |
||
|
||
with open(netrc_path, "a") as netrc_file: | ||
netrc_file.write(netrc_content) | ||
with open(netrc_path, 'w') as file: | ||
file.write(str(netrc_instance)) | ||
|
||
# Set appropriate permissions for Unix-like systems | ||
if platform.system() != "Windows": | ||
os.chmod(netrc_path, 0o600) | ||
console.print(f"Added credentials to {netrc_filename}", style="bold green") | ||
console.print(f"Added credentials to {netrc_path}", style="bold green") | ||
|
||
def _add_package(self, tool_details): | ||
tool_handle = tool_details["handle"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trust_env = False
tellsrequests
to bypass the system's authentication or proxy settings, relying only on the authentication defined in the request itself.The reason for this change is that when a
.netrc
file is present,requests
automatically replaces theAuthorization
header with the credentials from.netrc
, overwriting Auth0 credentials.While
trust_env = False
fixes the issue, alongside I'm proposing moving our custom PyPI index endpoints fromapp.crewai.com
totools.crewai.com
. This ensures.netrc
is only applied to that specific subdomain system-wide.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your suggestion makes total sense.