mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Rework update-requirements and setup.py to use pip's setup.py support
This commit is contained in:
@ -3,30 +3,6 @@
|
|||||||
from os.path import join
|
from os.path import join
|
||||||
from subprocess import check_call, check_output
|
from subprocess import check_call, check_output
|
||||||
from tempfile import TemporaryDirectory
|
from tempfile import TemporaryDirectory
|
||||||
import re
|
|
||||||
|
|
||||||
|
|
||||||
def parse_setup(lines, which):
|
|
||||||
match = re.search(fr'{which}\w*=\w*[\(\[](?P<list>[^\)\]]*)', lines,
|
|
||||||
flags=re.DOTALL)
|
|
||||||
packages = match.groups('list')[0]
|
|
||||||
packages = re.sub(r"[\"'\s]+", '', packages, flags=re.MULTILINE)
|
|
||||||
packages = [p for p in packages.split(',') if p]
|
|
||||||
return packages
|
|
||||||
|
|
||||||
|
|
||||||
with open('setup.py') as fh:
|
|
||||||
lines = fh.read()
|
|
||||||
|
|
||||||
install_requires = parse_setup(lines, 'install_requires')
|
|
||||||
tests_require = parse_setup(lines, 'tests_require')
|
|
||||||
dev_requires = [
|
|
||||||
'build>=0.7.0',
|
|
||||||
'pycodestyle>=2.6.0',
|
|
||||||
'pyflakes>=2.2.0',
|
|
||||||
'readme_renderer[md]>=26.0',
|
|
||||||
'twine>=3.4.2',
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def print_packages(packages, heading):
|
def print_packages(packages, heading):
|
||||||
@ -35,24 +11,31 @@ def print_packages(packages, heading):
|
|||||||
print('\n '.join(packages))
|
print('\n '.join(packages))
|
||||||
|
|
||||||
|
|
||||||
print_packages(install_requires, 'install_requires')
|
|
||||||
print_packages(tests_require, 'tests_require')
|
|
||||||
print_packages(dev_requires, 'dev_requires')
|
|
||||||
|
|
||||||
with TemporaryDirectory() as tmpdir:
|
with TemporaryDirectory() as tmpdir:
|
||||||
check_call(['python3', '-m', 'venv', tmpdir])
|
check_call(['python3', '-m', 'venv', tmpdir])
|
||||||
|
|
||||||
check_call([join(tmpdir, 'bin', 'pip'), 'install', *install_requires])
|
# base needs
|
||||||
|
check_call([join(tmpdir, 'bin', 'pip'), 'install', '.'])
|
||||||
frozen = check_output([join(tmpdir, 'bin', 'pip'), 'freeze'])
|
frozen = check_output([join(tmpdir, 'bin', 'pip'), 'freeze'])
|
||||||
frozen = set(frozen.decode('utf-8').split())
|
frozen = set(frozen.decode('utf-8').strip().split('\n'))
|
||||||
|
|
||||||
check_call([join(tmpdir, 'bin', 'pip'), 'install', *tests_require,
|
# dev additions
|
||||||
*dev_requires])
|
check_call([join(tmpdir, 'bin', 'pip'), 'install', '.[dev]'])
|
||||||
dev_frozen = check_output([join(tmpdir, 'bin', 'pip'), 'freeze'])
|
dev_frozen = check_output([join(tmpdir, 'bin', 'pip'), 'freeze'])
|
||||||
dev_frozen = set(dev_frozen.decode('utf-8').split()) - frozen
|
dev_frozen = set(dev_frozen.decode('utf-8').strip().split('\n')) - frozen
|
||||||
|
|
||||||
frozen = sorted(frozen)
|
# pip installs the module itself along with deps so we need to get that out of
|
||||||
dev_frozen = sorted(dev_frozen)
|
# our list by finding the thing that was file installed during dev
|
||||||
|
dev_frozen_sorted = sorted(dev_frozen)
|
||||||
|
dev_frozen = []
|
||||||
|
for package in dev_frozen_sorted:
|
||||||
|
if 'file://' in package:
|
||||||
|
ours = package.split(' @ ')[0]
|
||||||
|
else:
|
||||||
|
dev_frozen.append(package)
|
||||||
|
# now we can build the list of base requiements w/o ourself
|
||||||
|
frozen = sorted([p for p in frozen if not p.startswith(ours)])
|
||||||
|
# we also sorted things while we were at it above
|
||||||
|
|
||||||
print_packages(frozen, 'frozen')
|
print_packages(frozen, 'frozen')
|
||||||
print_packages(dev_frozen, 'dev_frozen')
|
print_packages(dev_frozen, 'dev_frozen')
|
||||||
|
19
setup.py
19
setup.py
@ -55,6 +55,11 @@ def long_description():
|
|||||||
return buf.getvalue()
|
return buf.getvalue()
|
||||||
|
|
||||||
|
|
||||||
|
tests_require = (
|
||||||
|
'pytest>=6.2.5',
|
||||||
|
'pytest-network>=0.0.1',
|
||||||
|
)
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
author='Ross McFarland',
|
author='Ross McFarland',
|
||||||
author_email='rwmcfa1@gmail.com',
|
author_email='rwmcfa1@gmail.com',
|
||||||
@ -62,6 +67,15 @@ setup(
|
|||||||
entry_points={
|
entry_points={
|
||||||
'console_scripts': console_scripts,
|
'console_scripts': console_scripts,
|
||||||
},
|
},
|
||||||
|
extras_require={
|
||||||
|
'dev': tests_require + (
|
||||||
|
'build>=0.7.0',
|
||||||
|
'pycodestyle>=2.6.0',
|
||||||
|
'pyflakes>=2.2.0',
|
||||||
|
'readme_renderer[md]>=26.0',
|
||||||
|
'twine>=3.4.2',
|
||||||
|
),
|
||||||
|
},
|
||||||
install_requires=(
|
install_requires=(
|
||||||
'PyYaml>=4.2b1',
|
'PyYaml>=4.2b1',
|
||||||
'dnspython>=1.15.0',
|
'dnspython>=1.15.0',
|
||||||
@ -77,10 +91,7 @@ setup(
|
|||||||
name='octodns',
|
name='octodns',
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
python_requires='>=3.6',
|
python_requires='>=3.6',
|
||||||
|
tests_require=tests_require,
|
||||||
url='https://github.com/octodns/octodns',
|
url='https://github.com/octodns/octodns',
|
||||||
version=octodns.__VERSION__,
|
version=octodns.__VERSION__,
|
||||||
tests_require=(
|
|
||||||
'pytest>=6.2.5',
|
|
||||||
'pytest-network>=0.0.1',
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user