diff --git a/script/update-requirements b/script/update-requirements index b9107ef..c750a18 100755 --- a/script/update-requirements +++ b/script/update-requirements @@ -3,30 +3,6 @@ from os.path import join from subprocess import check_call, check_output from tempfile import TemporaryDirectory -import re - - -def parse_setup(lines, which): - match = re.search(fr'{which}\w*=\w*[\(\[](?P[^\)\]]*)', 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): @@ -35,24 +11,31 @@ def print_packages(packages, heading): 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: 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 = 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_requires]) + # dev additions + check_call([join(tmpdir, 'bin', 'pip'), 'install', '.[dev]']) 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) -dev_frozen = sorted(dev_frozen) +# pip installs the module itself along with deps so we need to get that out of +# 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(dev_frozen, 'dev_frozen') diff --git a/setup.py b/setup.py index ffacd43..407be02 100644 --- a/setup.py +++ b/setup.py @@ -55,6 +55,11 @@ def long_description(): return buf.getvalue() +tests_require = ( + 'pytest>=6.2.5', + 'pytest-network>=0.0.1', +) + setup( author='Ross McFarland', author_email='rwmcfa1@gmail.com', @@ -62,6 +67,15 @@ setup( entry_points={ '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=( 'PyYaml>=4.2b1', 'dnspython>=1.15.0', @@ -77,10 +91,7 @@ setup( name='octodns', packages=find_packages(), python_requires='>=3.6', + tests_require=tests_require, url='https://github.com/octodns/octodns', version=octodns.__VERSION__, - tests_require=( - 'pytest>=6.2.5', - 'pytest-network>=0.0.1', - ), )