-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from CasualEngineerZombie/dev
🪲 [2] fix: Fixes bug with Windows path
- Loading branch information
Showing
6 changed files
with
104 additions
and
45 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
nh3==0.2.18 | ||
watchdog==4.0.2 | ||
requests==2.32.3 | ||
readme_renderer==44.0 | ||
sqlparse==0.5.1 | ||
urllib3==2.2.2 | ||
Pygments==2.18.0 | ||
zipp==3.19.2 | ||
rfc3986==2.0.0 | ||
asgiref==3.8.1 | ||
mdurl==0.1.2 | ||
pkginfo==1.10.0 | ||
certifi==2024.7.4 | ||
keyring==25.3.0 | ||
twine==5.1.1 | ||
charset-normalizer==3.3.2 | ||
idna==3.7 | ||
rich==13.7.1 | ||
tzdata==2024.1 | ||
setuptools==72.1.0 | ||
-e git+https://github.com/CasualEngineerZombie/venvwatch.git@ce9773a53e4a8fdfe62a6d8ff6fef2f403817028#egg=venvwatch | ||
requests-toolbelt==1.0.0 | ||
jaraco.functools==4.0.2 | ||
importlib_metadata==8.2.0 | ||
pywin32-ctypes==0.2.2 | ||
jaraco.classes==3.4.0 | ||
more-itertools==10.4.0 | ||
docutils==0.21.2 | ||
markdown-it-py==3.0.0 | ||
wheel==0.44.0 | ||
jaraco.context==5.3.0 |
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,16 @@ | ||
import argparse | ||
from .core import VenvWatch | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description="VenvWatch: Automatically update requirements.txt") | ||
parser.add_argument('--venv', help="Path to the virtual environment") | ||
parser.add_argument('--interval', type=int, default=5, help="Interval between checks (in seconds)") | ||
parser.add_argument('--no-remove', action='store_true', help="Don't remove packages from requirements.txt") | ||
|
||
args = parser.parse_args() | ||
|
||
watcher = VenvWatch(venv_path=args.venv, interval=args.interval, no_remove=args.no_remove) | ||
watcher.watch() | ||
|
||
if __name__ == "__main__": | ||
main() |
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,54 @@ | ||
import os | ||
import subprocess | ||
import time | ||
import sys | ||
from pathlib import Path | ||
|
||
class VenvWatch: | ||
def __init__(self, venv_path=None, interval=5, no_remove=False): | ||
self.venv_path = venv_path or os.environ.get('VIRTUAL_ENV') | ||
self.interval = interval | ||
self.no_remove = no_remove | ||
self.requirements_file = 'requirements.txt' | ||
self.last_packages = set() | ||
|
||
def get_pip_path(self): | ||
if sys.platform == "win32": | ||
return str(Path(self.venv_path) / "Scripts" / "pip.exe") | ||
return str(Path(self.venv_path) / "bin" / "pip") | ||
|
||
def get_installed_packages(self): | ||
pip_path = self.get_pip_path() | ||
result = subprocess.run([pip_path, "freeze"], capture_output=True, text=True) | ||
return set(result.stdout.splitlines()) | ||
|
||
def update_requirements(self): | ||
current_packages = self.get_installed_packages() | ||
|
||
if current_packages != self.last_packages: | ||
added = current_packages - self.last_packages | ||
removed = self.last_packages - current_packages | ||
|
||
with open(self.requirements_file, 'w') as f: | ||
for package in current_packages: | ||
f.write(f"{package}\n") | ||
|
||
update_message = f"Updated {self.requirements_file}" | ||
if added: | ||
for package in added: | ||
update_message += f"\n - Installed: {package}" | ||
if removed and not self.no_remove: | ||
for package in removed: | ||
update_message += f"\n - Uninstalled: {package}" | ||
|
||
print(update_message) | ||
|
||
self.last_packages = current_packages | ||
|
||
def watch(self): | ||
print(f"Watching virtual environment: {self.venv_path}") | ||
print(f"Updating {self.requirements_file} every {self.interval} seconds") | ||
|
||
while True: | ||
self.update_requirements() | ||
time.sleep(self.interval) |
This file was deleted.
Oops, something went wrong.
Empty file.