Skip to content

Commit

Permalink
Merge pull request #6 from ChillerDragon/pr_polyfill_copy_tree
Browse files Browse the repository at this point in the history
Polyfill distutils.copy_tree because it was removed
  • Loading branch information
Bamcane authored Feb 29, 2024
2 parents 65507c1 + f35345a commit e951456
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/download.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import shutil, os, re, sys, zipfile
from distutils.dir_util import copy_tree
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])) + "/..")
import twlib
from twlib import copy_tree

def unzip(filename, where):
try:
Expand Down
2 changes: 1 addition & 1 deletion scripts/make_release.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import shutil, optparse, os, re, sys, zipfile
from distutils.dir_util import copy_tree
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])) + "/..")
import twlib
from twlib import copy_tree

arguments = optparse.OptionParser(usage="usage: %prog VERSION PLATFORM [options]\n\nVERSION - Version number\nPLATFORM - Target platform (f.e. linux_x86, linux_x86_64, macos, src, win32, win64)")
arguments.add_option("-l", "--url-languages", default = "http://github.com/teeworlds/teeworlds-translation/archive/master.zip", help = "URL from which the teeworlds language files will be downloaded")
Expand Down
9 changes: 9 additions & 0 deletions scripts/twlib.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import shutil
import sys
if sys.version_info[0] == 2:
import urllib
Expand All @@ -6,6 +7,14 @@
import urllib.request
url_lib = urllib.request

try:
from distutils.dir_util import copy_tree
except ModuleNotFoundError:
# distutils was removed in python 3.12
# https://peps.python.org/pep-0632/
def copy_tree(src, dst):
shutil.copytree(src, dst, dirs_exist_ok=True)

def fetch_file(url):
print("trying %s" % url)
try:
Expand Down

0 comments on commit e951456

Please sign in to comment.