From 46fd7e954668120c94f3a3cee451a7ea730de8f0 Mon Sep 17 00:00:00 2001 From: Will Cunningham Date: Tue, 17 Jan 2023 14:34:08 -0500 Subject: [PATCH] fixing sdk only installation (#1487) Co-authored-by: Alejandro Esquivel --- CHANGELOG.md | 1 + MANIFEST.in | 1 - setup.py | 49 +++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cd794c55..288918607 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - MNIST tutorial now shows non-Null outputs and the classifier training log image has been updated. - Minor changes to tutorials: autoencoder, quantum and classical svm, ensemble classification, iris classification with Pennylane, quantum chemistry, DNN tutorial, qaoa, spacetime tutorial etc. - The range of `networkx` versions in requirements.txt weren't compatible with each other, thus it is pinned to `2.8.6` now +- SDK-only sdist and installation should now work as expected, not packaging the server ### Added diff --git a/MANIFEST.in b/MANIFEST.in index f6dbb98c8..dcc69da71 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,6 @@ include VERSION include requirements.txt include requirements-client.txt -include covalent_ui/log_config.yml recursive-include covalent/executor/executor_plugins/ * recursive-include covalent_dispatcher/_service/ * recursive-include covalent_migrations/ * diff --git a/setup.py b/setup.py index 31a45cce0..18e5b7863 100644 --- a/setup.py +++ b/setup.py @@ -25,6 +25,7 @@ from setuptools import Command, find_packages, setup from setuptools.command.build_py import build_py from setuptools.command.develop import develop +from setuptools.command.egg_info import egg_info, manifest_maker site.ENABLE_USER_SITE = "--user" in sys.argv[1:] @@ -33,9 +34,20 @@ requirements_file = "requirements.txt" -sdk_only = os.environ.get("COVALENT_SDK_ONLY") -if sdk_only == "True": +exclude_modules = [ + "tests", + "tests.*", +] +sdk_only = os.environ.get("COVALENT_SDK_ONLY") == "1" +if sdk_only: requirements_file = "requirements-client.txt" + exclude_modules += [ + "covalent_dispatcher", + "covalent_dispatcher.*", + "covalent_ui", + "covalent_ui.*", + "covalent_migrations", + ] with open(requirements_file) as f: required = f.read().splitlines() @@ -151,9 +163,34 @@ def run(self): ) +class EggInfoCovalent(egg_info): + def find_sources(self): + manifest_filename = os.path.join(self.egg_info, "SOURCES.txt") + mm = manifest_maker(self.distribution) + mm.manifest = manifest_filename + + if os.path.exists("MANIFEST.in") and sdk_only: + with open("MANIFEST.in", "r") as f: + lines = f.readlines() + with open("MANIFEST_SDK.in", "w") as f: + for line in lines: + if not any(excluded in line for excluded in exclude_modules): + f.write(line) + + mm.template = "MANIFEST_SDK.in" + + mm.run() + self.filelist = mm.filelist + + try: + os.remove("MANIFEST_SDK.in") + except OSError: + pass + + setup_info = { "name": "covalent", - "packages": find_packages(exclude=["tests"]), + "packages": find_packages(exclude=exclude_modules), "version": version, "maintainer": "Agnostiq", "url": "https://github.com/AgnostiqHQ/covalent", @@ -166,11 +203,6 @@ def run(self): "long_description_content_type": "text/markdown", "include_package_data": True, "zip_safe": False, - "package_data": { - "covalent": ["executor/executor_plugins/local.py"], - "covalent_dispatcher": ["_service/app.py"], - "covalent_ui": recursively_append_files("covalent_ui/webapp/build"), - }, "install_requires": required, "extras_require": { "aws": ["boto3>=1.20.48"], @@ -199,6 +231,7 @@ def run(self): "Topic :: System :: Distributed Computing", ], "cmdclass": { + "egg_info": EggInfoCovalent, "build_py": BuildCovalent, "develop": DevelopCovalent, "docs": Docs,