avoid using pkg_resources
This is deprecated in python 3.12. Also, improve file handling
This commit is contained in:
parent
c144b68306
commit
3d66b318ec
@ -3,33 +3,27 @@
|
||||
# Copyright (C) 2022 Thomas Basler and others
|
||||
#
|
||||
import os
|
||||
import pkg_resources
|
||||
|
||||
Import("env")
|
||||
|
||||
required_pkgs = {'dulwich'}
|
||||
installed_pkgs = {pkg.key for pkg in pkg_resources.working_set}
|
||||
missing_pkgs = required_pkgs - installed_pkgs
|
||||
|
||||
if missing_pkgs:
|
||||
try:
|
||||
from dulwich import porcelain
|
||||
except ModuleNotFoundError:
|
||||
env.Execute('"$PYTHONEXE" -m pip install dulwich')
|
||||
|
||||
from dulwich import porcelain
|
||||
from dulwich import porcelain
|
||||
|
||||
|
||||
def updateFileIfChanged(filename, content):
|
||||
mustUpdate = True
|
||||
try:
|
||||
fp = open(filename, "rb")
|
||||
if fp.read() == content:
|
||||
mustUpdate = False
|
||||
fp.close()
|
||||
with open(filename, "rb") as fp:
|
||||
if fp.read() == content:
|
||||
mustUpdate = False
|
||||
except:
|
||||
pass
|
||||
if mustUpdate:
|
||||
fp = open(filename, "wb")
|
||||
fp.write(content)
|
||||
fp.close()
|
||||
with open(filename, "wb") as fp:
|
||||
fp.write(content)
|
||||
return mustUpdate
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user