This repository has been archived by the owner on Oct 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
setup.py
97 lines (83 loc) · 3.01 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
"""
Copyright (c) Meta Platforms, Inc. and affiliates.
All rights reserved.
This source code is licensed under the license found in the
LICENSE file in the root directory of this source tree.
"""
#!/usr/bin/env python3
import glob
import os
import shutil
from os import path
from typing import List
from setuptools import find_packages, setup
cwd = os.path.dirname(os.path.abspath(__file__))
version = "0.0.1"
try:
if not os.getenv("RELEASE"):
from datetime import date
today = date.today()
day = today.strftime("b%Y%m%d")
version += day
except Exception:
pass
requirements = [
"importlib",
"numpy",
"Pillow",
"mock",
"torch",
"pytorch-lightning @ git+https://github.com/PyTorchLightning/pytorch-lightning@9b011606f",
"opencv-python",
"parameterized",
# Downgrade the protobuf package to 3.20.x or lower, related:
# https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
# https://github.com/protocolbuffers/protobuf/issues/10051
"protobuf<=3.20.1",
]
def d2go_gather_files(dst_module, file_path, extension="*") -> List[str]:
"""
Return a list of files to include in sylph submodule. Copy over the corresponding files.
"""
# Use absolute paths while symlinking.
source_configs_dir = path.join(
path.dirname(path.realpath(__file__)), file_path)
destination = path.join(path.dirname(
path.realpath(__file__)), "sylph", dst_module)
# Symlink the config directory inside package to have a cleaner pip install.
# Remove stale symlink/directory from a previous build.
if path.exists(source_configs_dir):
if path.islink(destination):
os.unlink(destination)
elif path.isdir(destination):
shutil.rmtree(destination)
if not path.exists(destination):
try:
os.symlink(source_configs_dir, destination)
except OSError:
# Fall back to copying if symlink fails: ex. on Windows.
shutil.copytree(source_configs_dir, destination)
config_paths = glob.glob(os.path.join(
file_path + extension), recursive=True)
return config_paths
if __name__ == "__main__":
setup(
name="sylph-few-shot",
version=version,
author="Li Yin",
url="https://github.com/facebookresearch/sylph-few-shot-detection",
description="Sylph hypernetwork framework for object detection",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
license="Apache-2.0",
install_requires=requirements,
packages=find_packages(exclude=["tools", "tests"]),
package_data={
"sylph-few-shot": [
"LICENSE",
],
"sylph-few-shot.configs": d2go_gather_files("configs", "configs", "**/*.yaml"),
"sylph-few-shot.tools": d2go_gather_files("tools", "tools", "**/*.py"),
"sylph-few-shot.tests": d2go_gather_files("tests", "tests", "**/*helper.py"),
},
)