Skip to content

Commit 19b17a3

Browse files
authored
Use Python venv (#102)
1 parent 6ee9250 commit 19b17a3

2 files changed

Lines changed: 31 additions & 18 deletions

File tree

.gitignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
*.pyc
2-
.tox/
32
.coverage
4-
tests/configuration*.json
5-
!tests/configuration.example.json
6-
example.png
3+
.tox/
4+
/.venv/
75
aspose_barcode_cloud.egg-info/
86
build/
97
dist/
8+
example.png
109
snippets_test/
10+
tests/configuration*.json
11+
!tests/configuration.example.json

Makefile

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
SRC=./aspose_barcode_cloud
22

3+
ifneq ($(wildcard .venv),)
4+
PYTHON = .venv/bin/python
5+
else
6+
PYTHON = python
7+
endif
8+
39
.PHONY: all
410
all: format lint test-tox
511

@@ -10,11 +16,11 @@ check_git:
1016

1117
.PHONY: dist
1218
dist:
13-
python setup.py sdist bdist_wheel --universal
19+
$(PYTHON) setup.py sdist bdist_wheel --universal
1420

1521
.PHONY: format
1622
format:
17-
black --line-length=120 -v $(SRC) tests/ scripts/ snippets/ *.py
23+
$(PYTHON) -m black --line-length=120 -v $(SRC) tests/ scripts/ snippets/ *.py
1824

1925
.PHONY: format_doc
2026
format_doc:
@@ -25,48 +31,54 @@ format_doc:
2531

2632
.PHONY: init
2733
init:
28-
python -m pip install --upgrade pip
29-
python -m pip install -r requirements.txt -r lint-requirements.txt -r test-requirements.txt
34+
$(PYTHON) -m pip install --upgrade pip
35+
$(PYTHON) -m pip install -r requirements.txt -r lint-requirements.txt -r test-requirements.txt
36+
37+
.PHONY: venv
38+
venv:
39+
python -m venv .venv
40+
.venv/bin/python -m pip install --upgrade pip
41+
.venv/bin/python -m pip install -r requirements.txt -r lint-requirements.txt -r test-requirements.txt
3042

3143
.PHONY: init-docker
3244
init-docker:
33-
python -m pip install -r publish-requirements.txt -r requirements.txt
45+
$(PYTHON) -m pip install -r publish-requirements.txt -r requirements.txt
3446

3547
.PHONY: lint
3648
lint:
3749
# stop the build if there are Python syntax errors or undefined names
38-
python -m flake8 aspose_barcode_cloud --count --select=E9,F63,F7,F82 --show-source --statistics --extend-exclude '.*'
50+
$(PYTHON) -m flake8 aspose_barcode_cloud --count --select=E9,F63,F7,F82 --show-source --statistics --extend-exclude '.*'
3951
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
40-
python -m flake8 aspose_barcode_cloud --count --exit-zero --max-line-length=127 --statistics --extend-ignore=E501 --extend-exclude '.*'
52+
$(PYTHON) -m flake8 aspose_barcode_cloud --count --exit-zero --max-line-length=127 --statistics --extend-ignore=E501 --extend-exclude '.*'
4153

4254
.PHONY: publish
4355
publish: check_git test-tox dist
44-
python -m twine upload dist/*
56+
$(PYTHON) -m twine upload dist/*
4557

4658
.PHONY: publish-docker
4759
publish-docker: init-docker unittest dist
48-
python -m twine upload dist/* --verbose
60+
$(PYTHON) -m twine upload dist/* --verbose
4961

5062
.PHONY: test
5163
test:
52-
python -m pytest --cov=aspose_barcode_cloud tests/
64+
$(PYTHON) -m pytest --cov=aspose_barcode_cloud tests/
5365
./scripts/run_snippets.sh
5466

5567
.PHONY: cover
5668
cover:
57-
python -Werror -m pytest --cov-report html:coverage --cov=aspose_barcode_cloud tests/
69+
$(PYTHON) -Werror -m pytest --cov-report html:coverage --cov=aspose_barcode_cloud tests/
5870

5971
.PHONY: unittest
6072
unittest:
61-
python -Werror -m unittest discover -v
73+
$(PYTHON) -Werror -m unittest discover -v
6274

6375
.PHONY: test-example
6476
test-example:
65-
python -Werror example.py
77+
$(PYTHON) -Werror example.py
6678

6779
.PHONY: test-tox
6880
test-tox:
69-
python -m tox $(SRC)
81+
$(PYTHON) -m tox $(SRC)
7082

7183
.PHONY: insert-examples
7284
insert-examples:

0 commit comments

Comments
 (0)