Newer
Older
from setuptools import find_packages, setup
MODULE = "worker_generic_training_dataset"
COMMAND = "worker-generic-training-dataset"
SUBMODULE_PATTERN = re.compile("-e ((?:(?!#egg=).)*)(?:#egg=)?(.*)")
def parse_requirements_line(line: str) -> str:
# Special case for git requirements
if line.startswith("git+http"):
assert "@" in line, "Branch should be specified with suffix (ex: @master)"
assert (
"#egg=" in line
), "Package name should be specified with suffix (ex: #egg=kraken)"
package_name: str = line.split("#egg=")[-1]
# Special case for submodule requirements
elif line.startswith("-e"):
package_path, package_name = SUBMODULE_PATTERN.match(line).groups()
package_path: Path = Path(package_path).resolve()
# Package name is optional: use folder name by default
return f"{package_name or package_path.name} @ file://{package_path}"
def parse_requirements() -> List[str]:
path = Path(__file__).parent.resolve() / "requirements.txt"
assert path.exists(), f"Missing requirements: {path}"
return list(
map(parse_requirements_line, map(str.strip, path.read_text().splitlines()))
)
setup(
name=MODULE,
version=open("VERSION").read(),
description="Fill base-worker cache with information about dataset and extract images",
author="Teklia",
author_email="contact@teklia.com",
install_requires=parse_requirements(),
entry_points={
"console_scripts": [
f"{COMMAND}={MODULE}.worker:main",
f"{COMMAND}-api={MODULE}.worker:main",
]
},