mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-03 05:35:58 +00:00
scripts: make.py clean implementation
This commit is contained in:
parent
4d424de69e
commit
8eba627b29
3 changed files with 44 additions and 31 deletions
2
Vagrantfile
vendored
2
Vagrantfile
vendored
|
@ -200,7 +200,7 @@ def install_borg(fuse)
|
||||||
pip install -U wheel # upgrade wheel, might be too old
|
pip install -U wheel # upgrade wheel, might be too old
|
||||||
cd borg
|
cd borg
|
||||||
pip install -r requirements.d/development.lock.txt
|
pip install -r requirements.d/development.lock.txt
|
||||||
python setup.py clean clean2
|
python3 scripts/make.py clean
|
||||||
pip install -e .[#{fuse}]
|
pip install -e .[#{fuse}]
|
||||||
EOF
|
EOF
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# Support code for building docs (build_usage, build_man)
|
# Support code for building docs (build_usage, build_man)
|
||||||
|
|
||||||
|
import glob
|
||||||
import os
|
import os
|
||||||
import io
|
import io
|
||||||
import re
|
import re
|
||||||
|
@ -530,11 +531,48 @@ def is_positional_group(group):
|
||||||
write(option.ljust(padding), desc)
|
write(option.ljust(padding), desc)
|
||||||
|
|
||||||
|
|
||||||
|
cython_sources = """
|
||||||
|
src/borg/compress.pyx
|
||||||
|
src/borg/crypto/low_level.pyx
|
||||||
|
src/borg/chunker.pyx
|
||||||
|
src/borg/hashindex.pyx
|
||||||
|
src/borg/item.pyx
|
||||||
|
src/borg/checksums.pyx
|
||||||
|
src/borg/platform/posix.pyx
|
||||||
|
src/borg/platform/linux.pyx
|
||||||
|
src/borg/platform/syncfilerange.pyx
|
||||||
|
src/borg/platform/darwin.pyx
|
||||||
|
src/borg/platform/freebsd.pyx
|
||||||
|
src/borg/platform/windows.pyx
|
||||||
|
""".strip().splitlines()
|
||||||
|
|
||||||
|
|
||||||
|
def rm(file):
|
||||||
|
try:
|
||||||
|
os.unlink(file)
|
||||||
|
except FileNotFoundError:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
class Clean:
|
||||||
|
def run(self):
|
||||||
|
for source in cython_sources:
|
||||||
|
genc = source.replace(".pyx", ".c")
|
||||||
|
rm(genc)
|
||||||
|
compiled_glob = source.replace(".pyx", ".cpython*")
|
||||||
|
for compiled in sorted(glob.glob(compiled_glob)):
|
||||||
|
rm(compiled)
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
print(
|
print(
|
||||||
textwrap.dedent(
|
textwrap.dedent(
|
||||||
"""
|
"""
|
||||||
Usage:
|
Usage:
|
||||||
|
python scripts/make.py clean # clean workdir (remove generated files)
|
||||||
python scripts/make.py build_usage # build usage documentation
|
python scripts/make.py build_usage # build usage documentation
|
||||||
python scripts/make.py build_man # build man pages
|
python scripts/make.py build_man # build man pages
|
||||||
"""
|
"""
|
||||||
|
@ -547,6 +585,8 @@ def main(argv):
|
||||||
usage()
|
usage()
|
||||||
return 0
|
return 0
|
||||||
command = argv[1]
|
command = argv[1]
|
||||||
|
if command == "clean":
|
||||||
|
return Clean().run()
|
||||||
if command == "build_usage":
|
if command == "build_usage":
|
||||||
return BuildUsage().run()
|
return BuildUsage().run()
|
||||||
if command == "build_man":
|
if command == "build_man":
|
||||||
|
|
33
setup.py
33
setup.py
|
@ -4,7 +4,6 @@
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from glob import glob
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
@ -12,7 +11,7 @@
|
||||||
multiprocessing = None
|
multiprocessing = None
|
||||||
|
|
||||||
from setuptools.command.build_ext import build_ext
|
from setuptools.command.build_ext import build_ext
|
||||||
from setuptools import setup, Extension, Command
|
from setuptools import setup, Extension
|
||||||
from setuptools.command.sdist import sdist
|
from setuptools.command.sdist import sdist
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -84,33 +83,7 @@ def __init__(self, *args, **kwargs):
|
||||||
raise ImportError("The GIT version of Borg needs Cython. Install Cython or use a released version.")
|
raise ImportError("The GIT version of Borg needs Cython. Install Cython or use a released version.")
|
||||||
|
|
||||||
|
|
||||||
def rm(file):
|
cmdclass = {"build_ext": build_ext, "sdist": Sdist}
|
||||||
try:
|
|
||||||
os.unlink(file)
|
|
||||||
print("rm", file)
|
|
||||||
except FileNotFoundError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class Clean(Command):
|
|
||||||
user_options = []
|
|
||||||
|
|
||||||
def initialize_options(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def finalize_options(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
for source in cython_sources:
|
|
||||||
genc = source.replace(".pyx", ".c")
|
|
||||||
rm(genc)
|
|
||||||
compiled_glob = source.replace(".pyx", ".cpython*")
|
|
||||||
for compiled in sorted(glob(compiled_glob)):
|
|
||||||
rm(compiled)
|
|
||||||
|
|
||||||
|
|
||||||
cmdclass = {"build_ext": build_ext, "sdist": Sdist, "clean2": Clean}
|
|
||||||
|
|
||||||
|
|
||||||
ext_modules = []
|
ext_modules = []
|
||||||
|
@ -228,7 +201,7 @@ def lib_ext_kwargs(pc, prefix_env_var, lib_name, lib_pkg_name, pc_version, lib_s
|
||||||
# this breaks chained commands like 'clean sdist'
|
# this breaks chained commands like 'clean sdist'
|
||||||
cythonizing = (
|
cythonizing = (
|
||||||
len(sys.argv) > 1
|
len(sys.argv) > 1
|
||||||
and sys.argv[1] not in (("clean", "clean2", "egg_info", "--help-commands", "--version"))
|
and sys.argv[1] not in (("clean", "egg_info", "--help-commands", "--version"))
|
||||||
and "--help" not in sys.argv[1:]
|
and "--help" not in sys.argv[1:]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue