[Datumaro] Pip installation (#881)
* Add version file * Remove unnecessary dependencies * Add lxml use motivation * Add pip setup script * Reduce opencv dependency * Fix cli command * Codacymain
parent
693e32e867
commit
59df0dfabc
@ -0,0 +1 @@
|
||||
VERSION = '0.1.0'
|
||||
@ -0,0 +1,66 @@
|
||||
|
||||
# Copyright (C) 2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
import os.path as osp
|
||||
import re
|
||||
import setuptools
|
||||
|
||||
|
||||
def find_version(file_path=None):
|
||||
if not file_path:
|
||||
file_path = osp.join(osp.dirname(osp.abspath(__file__)),
|
||||
'datumaro', 'version.py')
|
||||
|
||||
with open(file_path, 'r') as version_file:
|
||||
version_text = version_file.read()
|
||||
|
||||
# PEP440:
|
||||
# https://www.python.org/dev/peps/pep-0440/#appendix-b-parsing-version-strings-with-regular-expressions
|
||||
pep_regex = r'([1-9]\d*!)?(0|[1-9]\d*)(\.(0|[1-9]\d*))*((a|b|rc)(0|[1-9]\d*))?(\.post(0|[1-9]\d*))?(\.dev(0|[1-9]\d*))?'
|
||||
version_regex = r'VERSION\s*=\s*.(' + pep_regex + ').'
|
||||
match = re.match(version_regex, version_text)
|
||||
if not match:
|
||||
raise RuntimeError("Failed to find version string in '%s'" % file_path)
|
||||
|
||||
version = version_text[match.start(1) : match.end(1)]
|
||||
return version
|
||||
|
||||
|
||||
with open('README.md', 'r') as fh:
|
||||
long_description = fh.read()
|
||||
|
||||
setuptools.setup(
|
||||
name="datumaro",
|
||||
version=find_version(),
|
||||
author="Intel",
|
||||
author_email="maxim.zhiltsov@intel.com",
|
||||
description="Dataset Framework",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
url="https://github.com/opencv/cvat/datumaro",
|
||||
packages=setuptools.find_packages(exclude=['tests*']),
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
],
|
||||
python_requires='>=3.5',
|
||||
install_requires=[
|
||||
'GitPython',
|
||||
'lxml',
|
||||
'matplotlib',
|
||||
'numpy',
|
||||
'opencv-python',
|
||||
'Pillow',
|
||||
'PyYAML',
|
||||
'pycocotools',
|
||||
'tensorboardX',
|
||||
],
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'datum=datumaro:main',
|
||||
],
|
||||
},
|
||||
)
|
||||
@ -0,0 +1,39 @@
|
||||
from itertools import product
|
||||
import numpy as np
|
||||
import os.path as osp
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
import datumaro.util.image as image_module
|
||||
from datumaro.util.test_utils import TestDir
|
||||
|
||||
|
||||
class ImageTest(TestCase):
|
||||
def setUp(self):
|
||||
self.default_backend = image_module._IMAGE_BACKEND
|
||||
|
||||
def tearDown(self):
|
||||
image_module._IMAGE_BACKEND = self.default_backend
|
||||
|
||||
def _test_can_save_and_load(self, src_image, path,
|
||||
save_backend=None, load_backend=None):
|
||||
if save_backend:
|
||||
image_module._IMAGE_BACKEND = save_backend
|
||||
image_module.save_image(path, src_image)
|
||||
|
||||
if load_backend:
|
||||
image_module._IMAGE_BACKEND = load_backend
|
||||
dst_image = image_module.load_image(path)
|
||||
|
||||
self.assertTrue(np.all(src_image == dst_image), 'save: %s, load: %s' % \
|
||||
(save_backend, load_backend))
|
||||
|
||||
def test_save_and_load_backends(self):
|
||||
backends = image_module._IMAGE_BACKENDS
|
||||
for save_backend, load_backend in product(backends, backends):
|
||||
with TestDir() as test_dir:
|
||||
src_image = np.random.random_integers(0, 255, (2, 4, 3))
|
||||
image_path = osp.join(test_dir.path, 'img.png')
|
||||
|
||||
self._test_can_save_and_load(src_image, image_path,
|
||||
save_backend, load_backend)
|
||||
Loading…
Reference in New Issue