mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 05:13:58 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
63
tools/python/data/borders/setup.py
Executable file
63
tools/python/data/borders/setup.py
Executable file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import tarfile
|
||||
from distutils import log
|
||||
from distutils.command.build import build
|
||||
from distutils.command.clean import clean
|
||||
|
||||
from six import BytesIO
|
||||
|
||||
try:
|
||||
import lzma
|
||||
except ImportError:
|
||||
from backports import lzma
|
||||
|
||||
|
||||
module_dir = os.path.abspath(os.path.dirname(__file__))
|
||||
sys.path.insert(0, os.path.join(module_dir, "..", ".."))
|
||||
|
||||
from data.base import DATA_PATH
|
||||
from data.base import chdir
|
||||
from data.base import get_version
|
||||
from data.base import setup
|
||||
|
||||
|
||||
TAR_LZMA_PATH = os.path.join(DATA_PATH, "borders.tar.xz")
|
||||
|
||||
|
||||
class BuildCmd(build, object):
|
||||
def run(self):
|
||||
log.info("Creating {}".format(TAR_LZMA_PATH))
|
||||
tar_stream = BytesIO()
|
||||
borders_path = os.path.join(DATA_PATH, "borders")
|
||||
with chdir(borders_path):
|
||||
with tarfile.open(fileobj=tar_stream, mode="w") as tar:
|
||||
for f in os.listdir(borders_path):
|
||||
tar.add(f)
|
||||
|
||||
tar_stream.seek(0)
|
||||
with lzma.open(TAR_LZMA_PATH, mode="w") as f:
|
||||
f.write(tar_stream.read())
|
||||
|
||||
super(BuildCmd, self).run()
|
||||
|
||||
|
||||
class CleanCmd(clean, object):
|
||||
def run(self):
|
||||
if os.path.exists(TAR_LZMA_PATH):
|
||||
log.info("Removing {}".format(TAR_LZMA_PATH))
|
||||
os.remove(TAR_LZMA_PATH)
|
||||
|
||||
super(CleanCmd, self).run()
|
||||
|
||||
|
||||
setup(
|
||||
__file__,
|
||||
"borders",
|
||||
["borders.tar.xz", "packed_polygons.bin"],
|
||||
package_dir={"borders": ""},
|
||||
packages=["borders"],
|
||||
cmdclass={"build": BuildCmd, "clean": CleanCmd},
|
||||
install_requires=["omim-data-files=={}".format(get_version())]
|
||||
)
|
||||
Reference in New Issue
Block a user