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