Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
43
tools/python/data_files/__init__.py
Normal file
43
tools/python/data_files/__init__.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import os
|
||||
import site
|
||||
import sys
|
||||
|
||||
|
||||
def find_data_files_in_user_installations(directory):
|
||||
possible_paths = [os.path.join(site.USER_BASE, directory),] + [
|
||||
os.path.normpath(os.path.join(p, "../../..", directory))
|
||||
for p in site.getusersitepackages()
|
||||
]
|
||||
|
||||
for p in possible_paths:
|
||||
if os.path.isdir(p):
|
||||
return p
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def find_data_files_in_sys_installations(directory):
|
||||
possible_paths = [os.path.join(sys.prefix, directory),] + [
|
||||
os.path.normpath(os.path.join(p, "../../..", directory))
|
||||
for p in site.getsitepackages()
|
||||
]
|
||||
for p in possible_paths:
|
||||
if os.path.isdir(p):
|
||||
return p
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def find_data_files(directory, user_inst_first=True):
|
||||
functions = [
|
||||
(int(user_inst_first), find_data_files_in_user_installations),
|
||||
(int(not user_inst_first), find_data_files_in_sys_installations),
|
||||
]
|
||||
|
||||
functions.sort(key=lambda k: k[0])
|
||||
for prior, func in functions:
|
||||
res = func(directory)
|
||||
if res is not None:
|
||||
return res
|
||||
|
||||
return None
|
||||
30
tools/python/data_files/setup.py
Normal file
30
tools/python/data_files/setup.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
|
||||
import setuptools
|
||||
|
||||
module_dir = os.path.abspath(os.path.dirname(__file__))
|
||||
sys.path.insert(0, os.path.join(module_dir, "..", "..", ".."))
|
||||
|
||||
from pyhelpers.setup import chdir
|
||||
from pyhelpers.setup import get_version
|
||||
|
||||
|
||||
with chdir(os.path.abspath(os.path.dirname(__file__))):
|
||||
supported_pythons = ("2", "2.7", "3", "3.5", "3.6", "3.7")
|
||||
setuptools.setup(
|
||||
name="omim-data-files",
|
||||
version=str(get_version()),
|
||||
author="CoMaps",
|
||||
author_email="info@comaps.app",
|
||||
description="This package is a library for dealing with data files.",
|
||||
url="https://codeberg.org/comaps",
|
||||
package_dir={"data_files": ""},
|
||||
packages=["data_files",],
|
||||
classifiers=["License :: OSI Approved :: Apache Software License",]
|
||||
+ [
|
||||
"Programming Language :: Python :: {}".format(supported_python)
|
||||
for supported_python in supported_pythons
|
||||
],
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue