Skip to content

Commit 1148f7a

Browse files
committed
new location for VERSION file and adapted scripts to the new folder skeleton
1 parent 8c74a1a commit 1148f7a

File tree

4 files changed

+36
-33
lines changed

4 files changed

+36
-33
lines changed

.github/workflows/build-python-client.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
source .venv/bin/activate
3030
version=$(echo ${{ github.ref }} | grep -oP '(?<=refs/tags/v)\d+\.\d+\.\d+')
3131
python scripts/is_semantic_version.py "${version}"
32-
echo "${version}" > clients/python/client/VERSION
32+
echo "${version}" > clients/python/VERSION
3333
- name: Auto-generate python_client and build distributions
3434
run: |
3535
source .venv/bin/activate

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ tmp*
7878

7979
# auto generated python code
8080
/clients/python/artifacts/*
81-
/clients/python/client/build/*
82-
/clients/python/client/osparc/data/openapi.json
81+
/clients/python/src/build/*
82+
/clients/python/src/osparc/data/openapi.json
83+
/clients/python/VERSION
8384
/clients/python/test/e2e/pytest.ini
84-
/clients/python/client/VERSION
8585

8686

8787
# key-words in filename to ignore them

clients/python/Makefile

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-include ../../scripts/common.Makefile
22

3-
PYTHON_DIR := $(CLIENTS_DIR)/python
4-
ARTIFACTS_DIR := $(PYTHON_DIR)/artifacts
3+
CLIENTS_PYTHON_DIR := $(CLIENTS_DIR)/python
4+
ARTIFACTS_DIR := $(CLIENTS_PYTHON_DIR)/artifacts
55
CONTAINER_API_JSON := /local/$(OPENAPI_SPECS_JSON_REL_PATH)
66
GENERATOR := python
77
UID := $(shell id -u)
@@ -13,28 +13,20 @@ ADDITIONAL_PROPS := \
1313
packageUrl=$(shell bash $(SCRIPTS_DIR)/jq.bash -r .homepage $(REPO_ROOT)/api/config.json)\
1414
projectName=osparc_client
1515
ADDITIONAL_PROPS := $(foreach prop,$(ADDITIONAL_PROPS),$(strip $(prop)))
16-
VERSION_FILE := $(PYTHON_DIR)/client/VERSION
16+
VERSION_FILE := $(CLIENTS_PYTHON_DIR)/VERSION
1717

1818
.PHONY: generate_version
19-
client/VERSION:
19+
VERSION:
2020
@bash $(SCRIPTS_DIR)/generate_version.bash > $(VERSION_FILE)
2121

2222
.PHONY: artifacts_dir
2323
artifacts_dir:
24-
-mkdir $(ARTIFACTS_DIR)
24+
-mkdir --parents $(ARTIFACTS_DIR)
2525

26-
.PHONY: postprocess-build
27-
postprocess-build:
28-
black $(PYTHON_DIR)/artifacts/client/*.py
29-
@-rm -f $(PYTHON_DIR)/artifacts/client/README.md
30-
@echo "Please visit our [website](https://itisfoundation.github.io/osparc-simcore-clients/#/) for documentation" > $(PYTHON_DIR)/artifacts/client/README.md
31-
@-rm -rf $(PYTHON_DIR)/client/osparc/data/
32-
@-mkdir $(PYTHON_DIR)/client/osparc/data/
33-
@cp $(REPO_ROOT)/api/openapi.json $(PYTHON_DIR)/client/osparc/data/
3426

3527
# Generation of Python client
3628
.PHONY: python-client
37-
python-client: client/VERSION validate-api-specification artifacts_dir ## generate python client
29+
python-client: VERSION validate-api-specification artifacts_dir ## auto-generate python client
3830
$(eval VERSION := $(shell cat $(VERSION_FILE)))
3931
-rm -r $(ARTIFACTS_DIR)/client
4032
docker run --rm --user $(UID):$(UID)\
@@ -52,7 +44,7 @@ python-client: client/VERSION validate-api-specification artifacts_dir ## genera
5244
$(MAKE) postprocess-build
5345

5446
.PHONY: python-client-from-templates
55-
python-client-from-templates: client/VERSION validate-api-specification artifacts_dir ## generate python client using templates in a specified directory (usage: 'make python-client-from-templates -e TEMPLATE_DIR=path/to/templates')
47+
python-client-from-templates: VERSION validate-api-specification artifacts_dir ## generate python client using templates in a specified directory (usage: 'make python-client-from-templates -e TEMPLATE_DIR=path/to/templates')
5648
$(if $(TEMPLATE_DIR),,$(error The TEMPLATE_DIR environment variable must be set))
5749
@echo "Using template-dir: $(TEMPLATE_DIR)"
5850
$(eval VERSION := $(shell cat $(VERSION_FILE)))
@@ -109,22 +101,22 @@ install-dev: _check_venv_active ## install packages for development
109101

110102
.PHONY: install-unit-test
111103
install-unit-test: _check_venv_active ## install packages for unit testing client
112-
pip install -r $(PYTHON_DIR)/requirements/unit-test.txt
104+
pip install -r $(CLIENTS_PYTHON_DIR)/requirements/unit-test.txt
113105

114106
.PHONY: install-e2e-test
115107
install-e2e-test: _check_venv_active ## install packages for e2e testing client
116-
pip install -r $(PYTHON_DIR)/requirements/e2e-test.txt
108+
pip install -r $(CLIENTS_PYTHON_DIR)/requirements/e2e-test.txt
117109

118110
.PHONY: install-doc
119111
install-doc: _check_venv_active install-dev ## install packages for generating documentation
120-
pip install -r $(PYTHON_DIR)/requirements/doc.txt
112+
pip install -r $(CLIENTS_PYTHON_DIR)/requirements/doc.txt
121113

122114
.PHONY: pylint
123115
pylint: _check_venv_active ## runs linter (only to check errors. SEE .pylintrc enabled)
124-
pylint --rcfile "$(PYTHON_DIR)/.pylintrc" -v "$(ARTIFACTS_DIR)/client"
116+
pylint --rcfile "$(CLIENTS_PYTHON_DIR)/.pylintrc" -v "$(ARTIFACTS_DIR)/client"
125117

126118
.PHONY: mypy
127-
mypy: $(SCRIPTS_DIR)/mypy.bash $(PYTHON_DIR)/mypy.ini ## runs mypy python static type-checker on this services's code. Use AFTER make install-*
119+
mypy: $(SCRIPTS_DIR)/mypy.bash $(CLIENTS_PYTHON_DIR)/mypy.ini ## runs mypy python static type-checker on this services's code. Use AFTER make install-*
128120
@$(SCRIPTS_DIR)/mypy.bash client
129121

130122
.PHONY: test-dev
@@ -136,27 +128,38 @@ test-dev: _check_venv_active ## runs tests during development
136128
--failed-first \
137129
--durations=10 \
138130
--pdb \
139-
$(PYTHON_DIR)/test/test_osparc
131+
$(CLIENTS_PYTHON_DIR)/test/test_osparc
140132

141133
.PHONY: dist
142134
dist: artifacts_dir ## builds distribution wheel for `osparc_client` and `osparc` packages -> $(ARTIFACTS_DIR)/dist
143135
# installs pypa/build
144136
python -m pip install build
145137
# Build a binary wheel and a source tarball
146138
python -m build --sdist --wheel $(ARTIFACTS_DIR)/client
147-
python -m build --sdist --wheel $(PYTHON_DIR)/client
139+
python -m build --sdist --wheel $(CLIENTS_PYTHON_DIR)/src
148140
@-rm -rf $(ARTIFACTS_DIR)/dist
149141
@mkdir $(ARTIFACTS_DIR)/dist
150142
@cp $$(ls artifacts/client/dist/*.whl) $(ARTIFACTS_DIR)/dist
151143
@cp $$(ls client/dist/*.whl) $(ARTIFACTS_DIR)/dist
152-
@cp client/VERSION $(ARTIFACTS_DIR)/dist
144+
@cp VERSION $(ARTIFACTS_DIR)/dist
153145

154146

155147
.PHONY: build-n-install-osparc-dev
156148
build-n-install-osparc-dev: python-client ## install the built osparc package in editable mode
157149
python -m pip install -e artifacts/client
158150
python -m pip install -e client/
159151

152+
153+
.PHONY: postprocess-build
154+
postprocess-build:
155+
black $(ARTIFACTS_DIR)/client/*.py
156+
@-rm -f $(ARTIFACTS_DIR)/client/README.md
157+
@echo "Please visit our [website](https://itisfoundation.github.io/osparc-simcore-clients/#/) for documentation" > $(ARTIFACTS_DIR)/client/README.md
158+
@-rm -rf $(CLIENTS_PYTHON_DIR)/src/osparc/data/
159+
@-mkdir $(CLIENTS_PYTHON_DIR)/src/osparc/data/
160+
@cp $(REPO_ROOT)/api/openapi.json $(CLIENTS_PYTHON_DIR)/src/osparc/data/
161+
162+
160163
## TEST ---------------------------------------------------------------------------------
161164

162165
GH_TOKEN_FILE := $(wildcard $(HOME)/.gh-token)
@@ -189,9 +192,9 @@ e2e-shell: guard-GH_TOKEN ## shell for running e2e tests
189192
@echo "WARNING ##### $@ does not exist, cloning $< as $@ ############"; cp $< $@)
190193

191194
.PHONY: image
192-
image: client/VERSION ## builds image $(APP_NAME):version
195+
image: VERSION ## builds image $(APP_NAME):version
193196
docker build -f Dockerfile -t $(APP_NAME):$(shell cat $(VERSION_FILE)) $(CURDIR)
194197

195198
.PHONY: shell
196-
shell: client/VERSION ## runs container and opens bash shell
199+
shell: VERSION ## runs container and opens bash shell
197200
docker run -it $(APP_NAME):$(shell cat $(VERSION_FILE)) /bin/bash

clients/python/test/e2e/_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import pytest
88
from packaging.version import Version
99

10-
_python_dir: Path = Path(__file__).parent.parent.parent
11-
assert _python_dir.is_dir()
10+
_clients_python_dir: Path = Path(__file__).parent.parent.parent
11+
assert _clients_python_dir.is_dir()
1212

1313

1414
def osparc_dev_features_enabled() -> bool:
@@ -17,9 +17,9 @@ def osparc_dev_features_enabled() -> bool:
1717

1818
def repo_version() -> Version:
1919
subprocess.run(
20-
"make client/VERSION", cwd=_python_dir.resolve(), shell=True
20+
"make client/VERSION", cwd=_clients_python_dir.resolve(), shell=True
2121
).check_returncode()
22-
version_file: Path = Path(_python_dir / "client" / "VERSION")
22+
version_file: Path = Path(_clients_python_dir / "VERSION")
2323
assert version_file.is_file()
2424
return Version(version_file.read_text())
2525

0 commit comments

Comments
 (0)