Skip to content

Commit fac7e06

Browse files
Merge pull request #1127 from adamtheturtle/setup-cfg-version
Use setup.py setup which allows comments
2 parents 7ea4fcd + b22e2b5 commit fac7e06

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

dev-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# We use dev-requirements.txt instead of just declaring the requirements here
2+
# because Read The Docs needs a requirements file.
13
PyYAML==5.2
24
Pygments==2.5.2
35
Sphinx-Substitution-Extensions==2019.6.15.0

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF = true
123123

124124
[metadata]
125125
name = VWS Python
126+
version = attr: vws.__version__
126127
description = Interact with the Vuforia Web Services (VWS) API.
127128
long_description = file: README.rst
128129
keywords = vuforia client

setup.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
11
"""Setup script for VWS Python, a wrapper for Vuforia's Web Services APIs."""
22

3+
from pathlib import Path
34
from setuptools import setup
5+
from typing import List
46

57
import versioneer
68

7-
# We use requirements.txt instead of just declaring the requirements here
8-
# because this helps with Docker package caching.
9-
with open('requirements.txt') as requirements:
10-
INSTALL_REQUIRES = requirements.readlines()
119

12-
# We use dev-requirements.txt instead of just declaring the requirements here
13-
# because Read The Docs needs a requirements file.
14-
with open('dev-requirements.txt') as dev_requirements:
15-
DEV_REQUIRES = dev_requirements.readlines()
10+
def _get_dependencies(requirements_file: Path) -> List[str]:
11+
"""
12+
Return requirements from a requirements file.
13+
14+
This expects a requirements file with no ``--find-links`` lines.
15+
"""
16+
lines = requirements_file.read_text().strip().split('\n')
17+
return [line for line in lines if not line.startswith('#')]
18+
19+
20+
_DIRECT_REQUIRES = _get_dependencies(
21+
requirements_file=Path('requirements.txt'),
22+
)
23+
24+
INSTALL_REQUIRES = _DIRECT_REQUIRES
25+
DEV_REQUIRES = _get_dependencies(
26+
requirements_file=Path('dev-requirements.txt'),
27+
)
28+
PACKAGING_REQUIRES = _get_dependencies(
29+
requirements_file=Path('packaging-requirements.txt'),
30+
)
1631

1732
setup(
18-
version=versioneer.get_version(), # type: ignore
1933
cmdclass=versioneer.get_cmdclass(), # type: ignore
2034
install_requires=INSTALL_REQUIRES,
2135
extras_require={'dev': DEV_REQUIRES},

0 commit comments

Comments
 (0)