Skip to content

Commit 063d981

Browse files
committed
Updated __pkginfo__ and added anaconda support
1 parent 65b979d commit 063d981

File tree

6 files changed

+145
-8
lines changed

6 files changed

+145
-8
lines changed

.ci/travis_build_conda.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
set -e -x
4+
5+
export VERSION_NO="$TRAVIS_TAG"
6+
7+
./make_conda_recipe.py || exit 1
8+
9+
# Switch to miniconda
10+
source "$HOME/miniconda/etc/profile.d/conda.sh"
11+
hash -r
12+
conda config --set always_yes yes --set changeps1 no
13+
conda update -q conda
14+
conda info -a
15+
conda config --add channels domdfcoding || exit 1
16+
conda build conda --output-directory conda/dist
17+
18+
19+
for f in ../conda/dist/noarch/domdf_python_tools-*.tar.bz2; do
20+
conda install $f || exit 1
21+
if [ -z "$TRAVIS_TAG" ]; then
22+
echo "Skipping deploy because this is not a tagged commit"
23+
else
24+
echo "Deploying to Anaconda.org..."
25+
anaconda -t $ANACONDA_TOKEN upload $f || exit 1
26+
echo "Successfully deployed to Anaconda.org."
27+
fi
28+
done
29+
30+

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ python:
66
- "3.8"
77
- "pypy3"
88
install:
9-
- pip install coveralls tox tox-travis
9+
- sudo apt-get update
10+
- pip install coveralls tox tox-travis rst2txt
11+
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
12+
- bash miniconda.sh -b -p $HOME/miniconda
1013
script:
1114
- tox
1215
after_success:

README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ domdf_python_tools
2424

2525

2626
Helpful functions for Python
27+
28+
29+
.. conda install domdf_python_tools --channel http://conda.anaconda.org/domdfcoding
30+
31+
.. conda config --add channels http://conda.anaconda.org/domdfcoding

__pkginfo__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,12 @@
4141
"Source Code": github_url,
4242
}
4343

44-
install_requires = []
44+
repo_root = pathlib.Path(__file__).parent
4545

4646
# Get info from files; set: long_description
47-
if pathlib.Path.cwd().name == "doc-source":
48-
long_description = (pathlib.Path.cwd().parent / "README.rst").read_text() + '\n'
49-
else:
50-
long_description = pathlib.Path("README.rst").read_text() + '\n'
51-
47+
install_requires = []
48+
long_description = (repo_root / "README.rst").read_text() + '\n'
49+
extras_require = {"dates": ["pytz>=2019.1"]}
5250

5351
classifiers = [
5452
'Development Status :: 4 - Beta',

make_conda_recipe.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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}"')

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
license, long_description, classifiers,
77
entry_points, modname, py_modules,
88
short_desc, VERSION, web, project_urls,
9+
extras_require,
910
)
1011

1112
from setuptools import setup, find_packages
@@ -17,7 +18,7 @@
1718
description=short_desc,
1819
entry_points=entry_points,
1920
install_requires=install_requires,
20-
extras_require={"dates": ["pytz>=2019.1"]},
21+
extras_require=extras_require,
2122
license=license,
2223
long_description=long_description,
2324
name=modname,

0 commit comments

Comments
 (0)