-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathsetup.py
More file actions
110 lines (90 loc) · 3.41 KB
/
Copy pathsetup.py
File metadata and controls
110 lines (90 loc) · 3.41 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env python
"""Configure the package for distribution."""
import os
from setuptools import find_packages, setup
def read(file_name):
"""Read the provided file."""
this_dir = os.path.dirname(__file__)
file_path = os.path.join(this_dir, file_name)
with open(file_path, encoding="utf-8") as f:
return f.read()
def version_scheme(version):
"""
Version scheme hack for setuptools_scm.
Appears to be necessary to due to the bug documented here: https://github.com/pypa/setuptools_scm/issues/342
If that issue is resolved, this method can be removed.
"""
import time
from setuptools_scm.version import guess_next_version
if version.exact:
return version.format_with("{tag}")
else:
_super_value = version.format_next_version(guess_next_version)
now = int(time.time())
return _super_value + str(now)
def local_version(version):
"""
Local version scheme hack for setuptools_scm.
Appears to be necessary due to the bug documented here: https://github.com/pypa/setuptools_scm/issues/342
If that issue is resolved, this method can be removed.
"""
return ""
def parse_requirements(filename):
"""Load requirements from a pip requirements file."""
with open(filename) as file:
lines = file.readlines()
requirements = []
for line in lines:
# Skip comments, empty lines, and pip options
if line.startswith("#") or line.strip() == "" or line.startswith("-"):
continue
# Remove inline comments
line = line.split("#", 1)[0].strip()
requirements.append(line)
return requirements
def get_version():
"""Get the version using setuptools_scm or fallback to a default version."""
try:
from setuptools_scm import get_version as scm_get_version
return scm_get_version(
version_scheme=version_scheme, local_scheme=local_version
)
except (ImportError, LookupError):
return "0.1.0"
setup(
name="clean-scraper",
version=get_version(),
description="Command-line interface for downloading police agency reports and bodycam footage for the CLEAN project",
long_description=read("README.md"),
long_description_content_type="text/markdown",
author="Big Local News",
url="https://github.com/biglocalnews/clean-scraper",
packages=find_packages(exclude=["tests"]),
include_package_data=True,
entry_points="""
[console_scripts]
clean-scraper=clean.cli:cli
""",
install_requires=parse_requirements("requirements.txt"),
license="Apache 2.0 license",
zip_safe=False,
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Natural Language :: English",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
],
setup_requires=["pytest-runner", "setuptools_scm"],
project_urls={
"Maintainer": "https://github.com/biglocalnews",
"Source": "https://github.com/biglocalnews/clean-scraper",
"Tracker": "https://github.com/biglocalnews/clean-scraper/issues",
},
)