|
- import os
- import glob
- from setuptools import setup, find_packages
-
-
- mode = 'external'
-
- assert mode in ['internal', 'external']
-
- version_str = None
- if os.environ.get('PY_PACKAGE_VERSION'):
- version_str = os.environ.get('PY_PACKAGE_VERSION')
- if os.environ.get('RELEASE_VERSION'):
- version_str = os.environ.get('RELEASE_VERSION')
-
- if version_str == None:
- with open(os.path.join(os.path.realpath(os.path.dirname(__file__)), "VERSION.txt")) as version_file:
- version_str = version_file.read().strip()
-
- if mode == 'internal':
- excluded_packages = []
- elif mode == 'external':
- excluded_packages = []
-
- packaegs_to_pack = find_packages(where=".", exclude=excluded_packages)
-
- if mode == 'internal':
- mds = glob.glob('**/README_Enflame.md', recursive=True)
- elif mode == 'external':
- mds = glob.glob('**/README.md', recursive=True)
-
- jsons = glob.glob('**/*.json', recursive=True)
- shs = glob.glob('**/*.sh', recursive=True)
- txts = glob.glob('**/*.txt', recursive=True)
- pngs = glob.glob('**/*.png', recursive=True)
- ttfs = glob.glob('**/*.ttf', recursive=True)
-
- all_files = mds + jsons + shs + txts + pngs + ttfs
- this_path = os.path.dirname(os.path.abspath(__file__))
-
- all_files = [os.path.join(this_path, file) for file in all_files ]
-
- all_files = [file for file in all_files if not 'requirements' in file]
-
- if mode == 'external':
- all_files = [
- file for file in all_files if
- not 'stable_diffusion/pipelines/text2image' in file and
- not 'stable_diffusion/pipelines/image2image' in file and
- not 'stable_diffusion/docs/text2image' in file and
- not 'stable_diffusion/docs/image2image' in file and
- not 'stable_diffusion/tests/' in file
- ]
-
- package_data = {"": all_files}
-
-
- def get_requirements():
- with open(os.path.join(this_path, 'stable_diffusion/pipelines/requirements.txt'), 'r') as f:
- contents = f.read().strip().split('\n')
-
- dependency_links = []
- requirements = []
-
- for line in contents:
- if line.startswith('--extra-index-url') or line.startswith('--index-url') or line.startswith('-i'):
- dependency_links.append(line.split(' ')[1])
- else:
- requirements.append(line)
-
- return dependency_links, requirements
-
- _, requires = get_requirements()
-
- setup(
- name=f"stable_diffusion_gcu",
- version=version_str,
- author="Enflame-Tech",
- author_email="topstools@enflame-tech.com",
- description="Stable Diffusion Peielines provided by Enflame",
- long_description="This is a package for stable diffusion pipelines which run on Enflame GCUs.",
- keyworlds="Stable Diffusion Pipelines",
- url="www.enflame-tech.com",
- license="MIT",
- python_requires=">=3.8.0",
- packages=packaegs_to_pack,
- include_package_data=True,
- package_data=package_data,
- install_requires=requires
- )
|