|
| 1 | +#!/usr/bin/python3 |
| 2 | + |
| 3 | +import platform |
| 4 | +import rst2txt |
| 5 | +import sys |
| 6 | +from docutils.core import publish_file |
| 7 | +from io import StringIO |
| 8 | + |
| 9 | +from __pkginfo__ import ( |
| 10 | + author, extras_require, install_requires, long_description, |
| 11 | + modname, project_urls, repo_root, short_desc, VERSION, web, |
| 12 | + ) |
| 13 | + |
| 14 | +recipe_dir = repo_root / "conda" |
| 15 | + |
| 16 | +if not recipe_dir.exists(): |
| 17 | + recipe_dir.mkdir() |
| 18 | + |
| 19 | +# TODO: entry_points, manifest |
| 20 | + |
| 21 | +all_requirements = install_requires[:] |
| 22 | + |
| 23 | +if isinstance(extras_require, dict): |
| 24 | + for requires in extras_require.values(): |
| 25 | + all_requirements += requires |
| 26 | + |
| 27 | +all_requirements = set(x.replace(" ", '') for x in set(all_requirements)) |
| 28 | +requirements_block = "\n".join(f" - {req}" for req in all_requirements) |
| 29 | + |
| 30 | +txt_readme = publish_file(source=StringIO(long_description), writer=rst2txt.Writer()) |
| 31 | + |
| 32 | +with open(recipe_dir / "meta.yaml", "w") as fp: |
| 33 | + fp.write(f"""{{% set name = "{modname}" %}} |
| 34 | +{{% set version = "{VERSION}" %}} |
| 35 | +
|
| 36 | +package: |
| 37 | + name: "{{{{ name|lower }}}}" |
| 38 | + version: "{{{{ version }}}}" |
| 39 | +
|
| 40 | +source: |
| 41 | + url: "https://pypi.io/packages/source/{{{{ name[0] }}}}/{{{{ name }}}}/{{{{ name }}}}-{{{{ version }}}}.tar.gz" |
| 42 | +
|
| 43 | +build: |
| 44 | +# entry_points: |
| 45 | +# - {modname} = {modname}:main |
| 46 | +# skip_compile_pyc: |
| 47 | +# - "*/templates/*.py" # These should not (and cannot) be compiled |
| 48 | + noarch: python |
| 49 | + script: "{{{{ PYTHON }}}} -m pip install . -vv" |
| 50 | +
|
| 51 | +requirements: |
| 52 | + build: |
| 53 | + - python |
| 54 | + - setuptools |
| 55 | + - wheel |
| 56 | + host: |
| 57 | + - pip |
| 58 | + - python |
| 59 | +{requirements_block} |
| 60 | + run: |
| 61 | + - python |
| 62 | +{requirements_block} |
| 63 | +
|
| 64 | +test: |
| 65 | + imports: |
| 66 | + - domdf_python_tools |
| 67 | +
|
| 68 | +about: |
| 69 | + home: "{web}" |
| 70 | + license: "GNU Lesser General Public v3 (LGPLv3)" |
| 71 | + license_family: LGPL |
| 72 | + # license_file: requirements.txt |
| 73 | + summary: "{short_desc}" |
| 74 | + description: "txt_readme" |
| 75 | + doc_url: {project_urls["Documentation"]} |
| 76 | + dev_url: {project_urls["Source Code"]} |
| 77 | +
|
| 78 | +extra: |
| 79 | + maintainers: |
| 80 | + - {author} |
| 81 | + - github.com/domdfcoding |
| 82 | +
|
| 83 | +""") |
| 84 | + |
| 85 | +print(f"Wrote recipe to {recipe_dir / 'meta.yaml'}") |
| 86 | +# |
| 87 | +# plat = platform.system().lower() |
| 88 | +# arch = platform.architecture()[0][:2] |
| 89 | +# |
| 90 | +# if plat == "linux": |
| 91 | +# conda_arch = f"linux-{arch}" |
| 92 | +# elif plat == "windows": |
| 93 | +# conda_arch = f"win-{arch}" |
| 94 | +# elif plat == "darwin": |
| 95 | +# conda_arch = f"osx-{arch}" |
| 96 | +# else: |
| 97 | +# sys.exit(1) |
| 98 | +# |
| 99 | +# with open(recipe_dir / "conda_arch.sh", "w") as fp: |
| 100 | +# fp.write(f'#!/bin/bash\necho "{conda_arch}"') |
0 commit comments