Skip to content

Commit 4531a06

Browse files
committed
build ui into the package
1 parent a4c9350 commit 4531a06

File tree

7 files changed

+41
-13
lines changed

7 files changed

+41
-13
lines changed

.github/workflows/pypi.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,19 @@ jobs:
6363
python -m pip install --upgrade pip
6464
pip install setuptools wheel twine
6565
make install
66+
6667
- name: Check Branch
6768
id: check-branch
6869
run: |
6970
if [[ ${{ github.ref }} =~ ^refs/heads/(master|v[0-9]+\.[0-9]+.*)$ ]]; then
7071
echo ::set-output name=match::true
7172
fi # See: https://stackoverflow.com/a/58869470/1123955
7273
74+
- name: Check Branch
75+
id: check-branch
76+
run: |
77+
make ui
78+
7379
- name: Is A Publish Branch
7480
if: steps.check-branch.outputs.match == 'true'
7581
env:

MANIFEST.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
include LICENSE README.md VERSION
22
recursive-include src **/*.py
3-
recursive-include src **/*.pyi
4-
recursive-exclude src **/*_test.py
3+
recursive-include src **/*.pyi **/ui/
4+
recursive-exclude src **/*_test.py **/__pycache__ **/.mypy_cache

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ all : clean lint
2020

2121
.PHONY: clean
2222
clean:
23-
rm -fr dist/* .pytype ./src/wechaty/**/*.pyi ./src/wechaty/*.pyi
23+
rm -fr dist/* .pytype src/wechaty/ui ui/
2424

2525
.PHONY: lint
2626
lint: pylint pycodestyle flake8 mypy
@@ -113,6 +113,10 @@ code:
113113
run:
114114
python3 bin/run.py
115115

116+
.PHONY: ui
117+
ui:
118+
./scripts/build_ui.sh
119+
116120
.PHONY: dist
117121
dist:
118122
python3 setup.py sdist bdist_wheel

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pytest
1212
pytest-asyncio==0.18.3
1313
pytest-cov
1414
pytype
15-
semver
15+
semver==3.0.0.dev3
1616
pyee
1717
requests
1818
qrcode

scripts/build_ui.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# start to build wechaty-ui into wechaty
2+
3+
make clean
4+
git clone https://github.com/wechaty/wechaty-ui ui
5+
cd ui
6+
cnpm i && cnpm run build
7+
8+
# move the dist files to
9+
echo "starting to copy files to the package ..."
10+
pwd
11+
cp -r dist/ ../src/wechaty/ui

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def get_install_requires() -> List[str]:
7676
long_description_content_type='text/markdown',
7777
license='Apache-2.0',
7878
url='https://github.com/wechaty/python-wechaty',
79-
packages=setuptools.find_packages('src'),
79+
packages=setuptools.find_packages('src', exclude=['__pycache__', '.mypy_cache']),
80+
include_package_data=True,
8081
package_dir={'wechaty': 'src/wechaty'},
8182
install_requires=get_install_requires(),
8283
classifiers=[

src/wechaty/config.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,27 @@ class Config:
9292
"""
9393
get the configuration from the environment variables
9494
"""
95-
def __init__(self) -> None:
96-
self._cache_dir: Optional[str] = None
97-
9895
@property
9996
def cache_dir(self) -> str:
10097
"""get the cache dir in the lazy loading mode
10198
10299
Returns:
103100
str: the path of cache dir
104101
"""
105-
if self._cache_dir is not None:
106-
return self._cache_dir
107-
self._cache_dir = os.environ.get("CACHE_DIR", '.wechaty')
108-
assert self._cache_dir is not None
109-
return self._cache_dir
102+
return os.environ.get("CACHE_DIR", '.wechaty')
103+
104+
@property
105+
def ui_dir(self) -> str:
106+
"""get the ui directory
107+
108+
Returns:
109+
str: the path of the ui dir
110+
"""
111+
default_ui_dir = os.path.join(
112+
os.path.dirname(__file__),
113+
'ui'
114+
)
115+
return os.environ.get("UI_DIR", default_ui_dir)
110116

111117

112118
# export const CHATIE_OFFICIAL_ACCOUNT_ID = 'gh_051c89260e5d'

0 commit comments

Comments
 (0)