Skip to content

Commit ab899cc

Browse files
authored
[feat] setup.py for web ui files (#1627)
1 parent b4ab306 commit ab899cc

File tree

6 files changed

+89
-31
lines changed

6 files changed

+89
-31
lines changed

.github/workflows/python-package.yml

+45-24
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,58 @@ on:
1616
workflow_dispatch:
1717

1818
jobs:
19+
aim-ui-dist:
20+
if: ${{ github.event_name == 'schedule' || github.actor == 'gorarakelyan' || github.actor == 'alberttorosyan' || github.actor == 'roubkar' }}
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout sources
24+
uses: actions/checkout@v2
25+
with:
26+
ref: ${{ inputs.branch || github.ref }}
27+
28+
- name: Use node v16
29+
uses: actions/setup-node@v2
30+
with:
31+
node-version: '16'
32+
33+
- name: Build UI
34+
working-directory: ./aim/web/ui
35+
run: |
36+
npm i
37+
CI=false npm run build
38+
39+
- name: Setup python
40+
uses: actions/setup-python@v2
41+
with:
42+
python-version: 3.9
43+
architecture: x64
44+
45+
- name: Install dev dependencies
46+
run: |
47+
python -m pip install -r requirements.dev.txt
48+
49+
- name: Build sdist
50+
working-directory: ./aim/web/ui
51+
run: |
52+
python setup.py sdist
53+
54+
- name: Publish wheel
55+
env:
56+
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
57+
working-directory: ./aim/web/ui
58+
run: |
59+
python -m twine upload -u __token__ -p "${PYPI_PASSWORD}" dist/*
60+
1961
linux-dist:
2062
if: ${{ github.event_name == 'schedule' || github.actor == 'gorarakelyan' || github.actor == 'alberttorosyan' || github.actor == 'roubkar' }}
2163
runs-on: ubuntu-latest
2264
name: Linux wheels build (using Docker)
65+
needs: aim-ui-dist
2366
steps:
2467
- name: Install Docker & pull images
2568
run: |
2669
apt update && apt install -y docker.io
2770
sudo systemctl enable --now docker
28-
2971
docker pull quay.io/pypa/manylinux_2_24_x86_64
3072
3173
- name: Checkout sources
@@ -39,17 +81,6 @@ jobs:
3981
AIM_VERSION=$(< ./aim/VERSION)
4082
echo "::set-output name=AIM_VERSION::$AIM_VERSION"
4183
42-
- name: Use node v16
43-
uses: actions/setup-node@v2
44-
with:
45-
node-version: '16'
46-
47-
- name: Build UI
48-
working-directory: ./aim/web/ui
49-
run: |
50-
npm i
51-
CI=false npm run build
52-
5384
- name: Setup python
5485
uses: actions/setup-python@v2
5586
with:
@@ -63,7 +94,7 @@ jobs:
6394
6495
- name: Build bdist wheels
6596
run: |
66-
docker run --mount type=bind,source=$PWD,target=/opt/aim quay.io/pypa/manylinux_2_24_x86_64 bash /opt/aim/docker/build-wheels.sh
97+
docker run --mount type=bind,source=$PWD,target=/opt/aim quay.io/pypa/manylinux_2_24_x86_64 bash /opt/aim/docker/build-wheels.sh
6798
6899
- name: Publish wheels
69100
env:
@@ -93,23 +124,13 @@ jobs:
93124
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.10' ]
94125
os: [ 'macos-latest' ]
95126
name: Python ${{ matrix.python-version }} on ${{ matrix.os }} build
127+
needs: aim-ui-dist
96128
steps:
97129
- name: Checkout sources
98130
uses: actions/checkout@v2
99131
with:
100132
ref: ${{ inputs.branch || github.ref }}
101133

102-
- name: Use node v16
103-
uses: actions/setup-node@v2
104-
with:
105-
node-version: '16'
106-
107-
- name: Build UI
108-
working-directory: ./aim/web/ui
109-
run: |
110-
npm i
111-
CI=false npm run build
112-
113134
- name: Setup python
114135
uses: actions/setup-python@v2
115136
with:

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ include README.md LICENSE aim/VERSION
22
recursive-include aim/storage *.h *.hpp *.cpp *.cxx *.pxd *.pyx
33
recursive-include aim/storage/migrations *
44
recursive-include aim/web/migrations *
5-
recursive-include aim/web/ui/build *
5+

aim/web/ui/VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../VERSION

aim/web/ui/setup.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import os
2+
3+
from setuptools import setup
4+
5+
here = os.path.abspath(os.path.dirname(__file__))
6+
7+
version_file = os.path.join(here, 'VERSION')
8+
with open(version_file) as vf:
9+
__version__ = vf.read().strip()
10+
11+
# Package meta-data.
12+
NAME = 'aim-ui'
13+
DESCRIPTION = 'Aim UI'
14+
VERSION = __version__
15+
16+
17+
def package_files(directory):
18+
paths = []
19+
for (path, _, filenames) in os.walk(directory):
20+
for filename in filenames:
21+
paths.append(os.path.join(path, filename))
22+
return paths
23+
24+
25+
files = package_files('build')
26+
27+
# This is a symlink so main version
28+
files.append('VERSION')
29+
30+
setup(
31+
name=NAME,
32+
version=__version__,
33+
description=DESCRIPTION,
34+
packages=["aim.web.ui"],
35+
package_dir={'aim.web.ui': '.'},
36+
package_data={'aim.web.ui': files}
37+
)

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# installs dependencies from ./setup.py, and the package itself,
22
# in editable mode
3+
-e ./aim/web/ui
34
-e .

setup.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import sys
22
import os
3-
import io
3+
44
from shutil import rmtree
55
from setuptools import find_packages, setup, Command, Extension
66
from Cython.Build import cythonize
77

88
version_file = 'aim/VERSION'
99

10-
__version__ = None
1110
with open(version_file) as vf:
1211
__version__ = vf.read().strip()
1312

14-
1513
here = os.path.abspath(os.path.dirname(__file__))
1614

1715
# Package meta-data.
@@ -33,7 +31,6 @@ def package_files(directory):
3331
return paths
3432

3533

36-
ui_files = package_files('aim/web/ui/build')
3734
migration_files = package_files('aim/web/migrations')
3835
storage_migration_files = package_files('aim/storage/migrations')
3936
version_files = ['../aim/VERSION', ]
@@ -47,6 +44,7 @@ def package_files(directory):
4744

4845
# What packages are required for this module to be executed?
4946
REQUIRED = [
47+
f'aim-ui=={__version__}',
5048
'aimrecords==0.0.7',
5149
'aimrocks==0.1.0',
5250
'cachetools>=4.0.0',
@@ -128,7 +126,7 @@ def run(self):
128126
setup_requires=SETUP_REQUIRED,
129127
install_requires=REQUIRED,
130128
packages=packages,
131-
package_data={'aim': ui_files + migration_files + storage_migration_files + version_files},
129+
package_data={'aim': migration_files + storage_migration_files + version_files},
132130
include_package_data=True,
133131
classifiers=[
134132
'License :: OSI Approved :: MIT License',
@@ -215,5 +213,5 @@ def run(self):
215213
},
216214
cmdclass={
217215
'upload': UploadCommand
218-
},
216+
}
219217
)

0 commit comments

Comments
 (0)