From 3ba9f6985313041eebf40608250963adf31c20ca Mon Sep 17 00:00:00 2001 From: Austin Raney Date: Wed, 9 Jun 2021 14:43:26 -0400 Subject: [PATCH 1/4] add dev requirements to subpackage setup.py. Now install development reqs with pip install hydrotools.[develop] --- python/events/setup.py | 4 ++++ python/gcp_client/setup.py | 4 ++++ python/metrics/setup.py | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/python/events/setup.py b/python/events/setup.py index 9fb86246..eb049caf 100644 --- a/python/events/setup.py +++ b/python/events/setup.py @@ -32,6 +32,9 @@ "pandas", ] +# Development requirements +DEVELOPMENT_REQUIREMENTS = ["pytest"] + setup( name=SUBPACKAGE_SLUG, version=VERSION, @@ -53,4 +56,5 @@ namespace_packages=[NAMESPACE_PACKAGE_NAME], packages=find_namespace_packages(include=[f"{NAMESPACE_PACKAGE_NAME}.*"]), install_requires=REQUIREMENTS, + extras_require={"develop": DEVELOPMENT_REQUIREMENTS}, ) diff --git a/python/gcp_client/setup.py b/python/gcp_client/setup.py index 2d17901a..3a4c9bd6 100644 --- a/python/gcp_client/setup.py +++ b/python/gcp_client/setup.py @@ -37,6 +37,9 @@ "numpy>=1.20.0" ] +# Development requirements +DEVELOPMENT_REQUIREMENTS = ["pytest"] + setup( name=SUBPACKAGE_SLUG, version=VERSION, @@ -66,4 +69,5 @@ ] }, install_requires=REQUIREMENTS, + extras_require={"develop": DEVELOPMENT_REQUIREMENTS}, ) diff --git a/python/metrics/setup.py b/python/metrics/setup.py index 0a52c093..93a4865d 100644 --- a/python/metrics/setup.py +++ b/python/metrics/setup.py @@ -33,6 +33,9 @@ "numpy>=1.20.0" ] +# Development requirements +DEVELOPMENT_REQUIREMENTS = ["pytest"] + setup( name=SUBPACKAGE_SLUG, version=VERSION, @@ -54,4 +57,5 @@ namespace_packages=[NAMESPACE_PACKAGE_NAME], packages=find_namespace_packages(include=[f"{NAMESPACE_PACKAGE_NAME}.*"]), install_requires=REQUIREMENTS, + extras_require={"develop": DEVELOPMENT_REQUIREMENTS}, ) From 168f1176f51ea2256825f0880bd4c9a23d60356a Mon Sep 17 00:00:00 2001 From: Austin Raney Date: Wed, 9 Jun 2021 14:44:14 -0400 Subject: [PATCH 2/4] remove development requires from namespace level setup.py --- setup.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/setup.py b/setup.py index 64d925c3..74d4ce91 100644 --- a/setup.py +++ b/setup.py @@ -39,9 +39,6 @@ LONG_DESCRIPTION = Path("README.md").read_text() LICENSE = Path("LICENSE").read_text() -# Development requirements -DEVELOPMENT_REQUIREMENTS = ["pytest"] - def get_subpackage_names() -> List[str]: # This assumes that each subpackage has a setup.py and is located under python/ From acfce9f3e0522b4f5cc545b7592b9e326d794048 Mon Sep 17 00:00:00 2001 From: Austin Raney Date: Wed, 9 Jun 2021 14:57:07 -0400 Subject: [PATCH 3/4] use [develop] extra_requires option in each subpackage to install dev deps. Still install namespace package in dev mode using python setup.py develop --- setup.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index 74d4ce91..04a9a3a3 100644 --- a/setup.py +++ b/setup.py @@ -87,9 +87,7 @@ def build_subpackage_mapping() -> Dict[str, str]: return subpackage_mapping -def install_subpackages( - sources: dict, -) -> None: +def install_subpackages(sources: dict, develop_flag: bool = False) -> None: """Install all subpackages in a namespace package Parameters @@ -104,6 +102,8 @@ def install_subpackages( for k, v in sources.items(): try: subpackage_dir = str(ROOT_DIR / v) + if develop_flag: + subpackage_dir = f"{subpackage_dir}[develop]" subprocess.check_call( [ sys.executable, @@ -125,12 +125,7 @@ def install_subpackages( # Development installation class Develop(develop): def run(self): - install_subpackages(SUBPACKAGES) - # Install development requirements - for dev_requirement in DEVELOPMENT_REQUIREMENTS: - subprocess.check_call( - [sys.executable, "-m", "pip", "install", dev_requirement] - ) + install_subpackages(SUBPACKAGES, develop_flag=True) setup( @@ -152,7 +147,6 @@ def run(self): url=URL, license=LICENSE, install_requires=REQUIREMENTS, - extras_require={"test": DEVELOPMENT_REQUIREMENTS}, python_requires=">=3.7", cmdclass={"develop": Develop}, ) From e3b24bf64dd688de089db9deb563270e0ad3264e Mon Sep 17 00:00:00 2001 From: Austin Raney Date: Wed, 9 Jun 2021 14:59:10 -0400 Subject: [PATCH 4/4] update contributing guide setup.py example. Now uses extra_require --- CONTRIBUTING.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a874fba2..81808ae2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -145,6 +145,9 @@ DESCRIPTION = "{{ SHORT_DESCRIPTION }}" # Package dependency requirements REQUIREMENTS = [] +# Development requirements +DEVELOPMENT_REQUIREMENTS = ["pytest"] + setup( name=SUBPACKAGE_SLUG, version=VERSION, @@ -157,6 +160,7 @@ setup( include=[f"{NAMESPACE_PACKAGE_NAME}.*"] ), install_requires=REQUIREMENTS, + extras_require={"develop": DEVELOPMENT_REQUIREMENTS}, ) ```