a
This commit is contained in:
parent
c599ed4560
commit
be660c91e8
9 changed files with 160 additions and 46 deletions
32
app/abk.py
Normal file
32
app/abk.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import subprocess
|
||||
import os
|
||||
|
||||
from pipfile import Pipfile
|
||||
|
||||
|
||||
def globally_installed_py_packages():
|
||||
output = subprocess.check_output("pip list --format freeze".split(), env={})
|
||||
output = output.decode("utf-8")
|
||||
output = output.strip()
|
||||
global_packages = output.split("\n")
|
||||
return global_packages
|
||||
|
||||
|
||||
global_packages = globally_installed_py_packages()
|
||||
|
||||
p = Pipfile.load(filename="meowPip")
|
||||
content = ""
|
||||
with open("meowPip", "r") as f:
|
||||
content = f.read()
|
||||
|
||||
for pip_package in p.data["default"]:
|
||||
version = p.data["default"][pip_package]
|
||||
if version == "*":
|
||||
for package in global_packages:
|
||||
package = package.lower()
|
||||
if package.startswith(pip_package.lower()):
|
||||
substr = f'{pip_package} = "*"'
|
||||
content = content.replace(substr, package)
|
||||
|
||||
with open("meowPippy", "w") as f:
|
||||
f.write(content)
|
||||
Loading…
Add table
Add a link
Reference in a new issue