chore: Update .gitignore to exclude __pycache__ directory

This commit is contained in:
2024-08-11 08:28:14 -04:00
parent ca0ca5b275
commit be202215e5
3 changed files with 7 additions and 8 deletions
+1
View File
@@ -3,3 +3,4 @@ build
dist
uvenv_cli.egg-info
.vscode
__pycache__
+1 -6
View File
@@ -11,17 +11,15 @@ Options:
--version Show version.
"""
import os
import sys
import logging
import shlex
import shellingham
from docopt import docopt
from .project import Project
from .__version__ import __version__
logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
)
@@ -32,8 +30,6 @@ def main():
args = docopt(__doc__, version=f"uvenv {__version__}")
project = Project.from_cwd()
try:
# Ensure the project has a virtual environment.
project.ensure_requirements_txt()
@@ -48,7 +44,6 @@ def main():
# Update the lockfile.
project.lock()
except Exception as e:
logger.error(f"An error occurred: {str(e)}")
sys.exit(1)
+5 -2
View File
@@ -11,12 +11,15 @@ def system_run(*command):
exit_code = os.system(shlex.join(command))
return exit_code >> 8
class Project:
def __init__(self, path):
self.path = Path(path).resolve()
@classmethod
def from_cwd(cls, *, search_depth=3, search_fnames=[REQUIREMENTS_TXT, REQUIREMENTS_IN]):
def from_cwd(
cls, *, search_depth=3, search_fnames=[REQUIREMENTS_TXT, REQUIREMENTS_IN]
):
"""Find the project root by searching up the directory tree for a file named `requirements.txt`."""
current_path = Path.cwd()
@@ -32,7 +35,7 @@ class Project:
"""Ensure the project has a virtual environment."""
if not self.path_to_venv.exists():
system_run("uv", "venv", str(self.path_to_venv))
system_run("uv", "venv", str(self.path_to_venv))
def ensure_requirements_txt(self):
"""Ensure the project has a `requirements.txt` file."""