-
Notifications
You must be signed in to change notification settings - Fork 3
PB-1968: Update python and packages - #major #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b6667a3
PB-1968: Drop Python 2 support
msom a74730f
PB-1968: Update build system
msom 0029ac7
PB-1968: Add pipenv and makefile
msom cb1fb53
PB-1968: Add github workflows
msom 7a2f30d
PB-1968: Set up git versionioning
msom 2f91606
PB-1968: Autogenerate help
msom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [report] | ||
| show_missing = True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| name: on-pr | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: | ||
| - opened | ||
| - reopened | ||
| - synchronize | ||
| - edited | ||
|
|
||
| jobs: | ||
| pr-edit: | ||
| uses: geoadmin/.github/.github/workflows/pr-auto-semver.yml@master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| name: on-push | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| - develop | ||
|
|
||
| jobs: | ||
| release: | ||
| uses: geoadmin/.github/.github/workflows/semver-release.yml@master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,3 +64,6 @@ target/ | |
|
|
||
| # Vim temporary files | ||
| *.swp | ||
|
|
||
| # test report | ||
| nose2-junit.xml | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| [settings] | ||
| known_third_party=pytest | ||
| known_django=django | ||
| known_flask=flask | ||
| known_gatilegrid=gatilegrid | ||
| force_single_line=True | ||
| sections=FUTURE,STDLIB,THIRDPARTY,DJANGO,FLASK,GATILEGRID,FIRSTPARTY,LOCALFOLDER |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| [MAIN] | ||
| ignore=.venv | ||
|
|
||
| [MESSAGES CONTROL] | ||
| disable= | ||
| # no convention and refactor rules | ||
| C, | ||
| R, | ||
| # allow some unconventional stuff (assuming the library already works as intended) | ||
| unused-variable, | ||
| attribute-defined-outside-init, | ||
| unused-import, | ||
| possibly-used-before-assignment | ||
|
|
||
| generated-members= | ||
| # added via mixins | ||
| gatilegrid.tilegrids._TileGrid.MINX | ||
| gatilegrid.tilegrids._TileGrid.MAXX | ||
| gatilegrid.tilegrids._TileGrid.MINY | ||
| gatilegrid.tilegrids._TileGrid.MAXY | ||
| gatilegrid.tilegrids._TileGrid.RESOLUTIONS | ||
| gatilegrid.tilegrids._TileGrid.spatialReference | ||
| gatilegrid.tilegrids._TileGrid.tileAddressTemplate | ||
| gatilegrid.tilegrids._TileGrid.unit | ||
| gatilegrid.tilegrids._TileGrid.metersPerUnit | ||
| gatilegrid.tilegrids._TileGrid. | ||
|
|
||
| [REPORTS] | ||
| score = no |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| [style] | ||
| based_on_style=google | ||
| # Put closing brackets on a separate line, dedented, if the bracketed | ||
| # expression can't fit in a single line. Applies to all kinds of brackets, | ||
| # including function definitions and calls. For example: | ||
| # | ||
| # config = { | ||
| # 'key1': 'value1', | ||
| # 'key2': 'value2', | ||
| # } # <--- this bracket is dedented and on a separate line | ||
| # | ||
| # time_series = self.remote_client.query_entity_counters( | ||
| # entity='dev3246.region1', | ||
| # key='dns.query_latency_tcp', | ||
| # transform=Transformation.AVERAGE(window=timedelta(seconds=60)), | ||
| # start_ts=now()-timedelta(days=3), | ||
| # end_ts=now(), | ||
| # ) # <--- this bracket is dedented and on a separate line | ||
| dedent_closing_brackets=True | ||
| coalesce_brackets=True | ||
|
|
||
| # This avoid issues with complex dictionary | ||
| # see https://github.com/google/yapf/issues/392#issuecomment-407958737 | ||
| indent_dictionary_value=True | ||
| allow_split_before_dict_value=False | ||
|
|
||
| # Split before arguments, but do not split all sub expressions recursively | ||
| # (unless needed). | ||
| split_all_top_level_comma_separated_values=True | ||
|
|
||
| # Split lines longer than 100 characters (this only applies to code not to | ||
| # comment and docstring) | ||
| column_limit=100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| SHELL = /bin/bash | ||
|
|
||
| .DEFAULT_GOAL := help | ||
|
|
||
|
|
||
| CURRENT_DIR := $(shell pwd) | ||
|
|
||
| # Test reports configuration | ||
| TEST_REPORT_DIR ?= $(CURRENT_DIR)/tests/report | ||
| TEST_REPORT_FILE ?= nose2-junit.xml | ||
|
|
||
| # general targets timestamps | ||
| TIMESTAMPS = .timestamps | ||
| REQUIREMENTS := $(TIMESTAMPS) $(PIP_FILE) $(PIP_FILE_LOCK) | ||
|
|
||
| # Find all python files that are not inside a hidden directory (directory starting with .) | ||
| PYTHON_FILES := $(shell find ./* -type d \( -path ./build -o -path ./dist \) -prune -false -o -type f -name "*.py" -print) | ||
|
|
||
| # PIPENV files | ||
| PIP_FILE = Pipfile | ||
| PIP_FILE_LOCK = Pipfile.lock | ||
|
|
||
| # default configuration | ||
| ENV_FILE ?= .env.local | ||
|
|
||
| # Commands | ||
| PIPENV_RUN := pipenv run | ||
| PYTHON := $(PIPENV_RUN) python3 | ||
| PIP := $(PIPENV_RUN) pip3 | ||
| YAPF := $(PIPENV_RUN) yapf | ||
| ISORT := $(PIPENV_RUN) isort | ||
| NOSE := $(PIPENV_RUN) nose2 | ||
| PYLINT := $(PIPENV_RUN) pylint | ||
|
|
||
| PACKAGE_VERSION = $(shell awk '/^Version:/ {print $$2}' gatilegrid.egg-info/PKG-INFO) | ||
|
|
||
|
|
||
| all: help | ||
|
|
||
|
|
||
| .PHONY: help | ||
| help: | ||
| @echo "Usage: make <target>" | ||
| @echo | ||
| @echo "Possible targets:" | ||
| @echo -e " \033[1mSetup TARGETS\033[0m " | ||
| @echo "- setup Create the python virtual environment with developper tools" | ||
| @echo -e " \033[1mFORMATING, LINTING AND TESTING TOOLS TARGETS\033[0m " | ||
| @echo "- format Format the python source code" | ||
| @echo "- lint Lint the python source code" | ||
| @echo "- format-lint Format and lint the python source code" | ||
| @echo "- test Run the tests" | ||
| @echo -e " \033[1mPACKAGING TARGETS\033[0m " | ||
| @echo "- package Create package" | ||
| @echo "- publish Tag and publish package to PyPI" | ||
| @echo -e " \033[1mCLEANING TARGETS\033[0m " | ||
| @echo "- clean Clean generated files" | ||
| @echo "- clean-venv Clean python venv" | ||
| @echo "- clean-all Clean everything" | ||
|
|
||
|
|
||
| # Build targets. Calling setup is all that is needed for the local files to be installed as needed. | ||
|
|
||
| .PHONY: setup | ||
| setup: $(REQUIREMENTS) | ||
| pipenv install --dev | ||
|
|
||
| # linting target, calls upon yapf to make sure your code is easier to read and respects some conventions. | ||
|
|
||
| .PHONY: format | ||
| format: $(REQUIREMENTS) | ||
| $(YAPF) -p -i --style .style.yapf $(PYTHON_FILES) | ||
| $(ISORT) $(PYTHON_FILES) | ||
|
|
||
|
|
||
| .PHONY: ci-check-format | ||
| ci-check-format: format | ||
| @if [[ -n `git status --porcelain` ]]; then \ | ||
| >&2 echo "ERROR: the following files are not formatted correctly:"; \ | ||
| >&2 git status --porcelain; \ | ||
| exit 1; \ | ||
| fi | ||
|
|
||
|
|
||
| .PHONY: lint | ||
| lint: $(REQUIREMENTS) | ||
| $(PYLINT) $(PYTHON_FILES) | ||
|
|
||
|
|
||
| .PHONY: format-lint | ||
| format-lint: format lint | ||
|
|
||
|
|
||
| # Test target | ||
|
|
||
| .PHONY: test | ||
| test: $(DEV_REQUIREMENTS_TIMESTAMP) | ||
| mkdir -p $(TEST_REPORT_DIR) | ||
| $(NOSE) -v -c tests/unittest.cfg --junit-xml-path $(TEST_REPORT_DIR)/$(TEST_REPORT_FILE) -s tests/ | ||
|
|
||
|
|
||
| # Packaging target | ||
|
|
||
| .PHONY: package | ||
| package: $(DEV_REQUIREMENTS_TIMESTAMP) | ||
| $(PYTHON) -m build | ||
|
|
||
|
|
||
| .PHONY: publish | ||
| publish: publish-check package | ||
| @echo "Upload package version=$(PACKAGE_VERSION)" | ||
| $(PYTHON) -m twine upload dist/* | ||
|
|
||
|
|
||
| # Clean targets | ||
|
|
||
| .PHONY: clean-venv | ||
| clean-venv: | ||
| pipenv --rm | ||
|
|
||
| .PHONY: clean | ||
| clean: clean-venv | ||
| @# clean python cache files | ||
| find . -name __pycache__ -type d -print0 | xargs -I {} -0 rm -rf "{}" | ||
| rm -rf $(TEST_REPORT_DIR) | ||
| rm -rf $(TIMESTAMPS) | ||
| rm -rf dist | ||
| rm -rf build | ||
| rm -rf *.egg-info | ||
| rm -f .coverage | ||
|
|
||
| .PHONY: clean-all | ||
| clean-all: clean | ||
|
|
||
| # Actual builds targets with dependencies | ||
|
|
||
| $(TIMESTAMPS): | ||
| mkdir -p $(TIMESTAMPS) | ||
|
|
||
|
|
||
| $(VENV_TIMESTAMP): | ||
| test -d $(VENV) || $(SYSTEM_PYTHON) -m venv $(VENV) && $(PIP) install --upgrade pip setuptools | ||
| @touch $(VENV_TIMESTAMP) | ||
|
|
||
|
|
||
| $(DEV_REQUIREMENTS_TIMESTAMP): $(VENV_TIMESTAMP) $(DEV_REQUIREMENTS) | ||
| $(PIP) install -r $(DEV_REQUIREMENTS) | ||
| @touch $(DEV_REQUIREMENTS_TIMESTAMP) | ||
|
|
||
|
|
||
| publish-check: | ||
| @echo "Check if publish is allowed" | ||
| @if [ -n "`git status --porcelain`" ]; then echo "ERROR: Repo is dirty !" >&2; exit 1; fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| [[source]] | ||
| url = "https://pypi.python.org/simple" | ||
| verify_ssl = true | ||
| name = "pypi" | ||
|
|
||
| [dev-packages] | ||
| flake8 = "*" | ||
| nose2 = { version = "*", extras = ["coverage_plugin"] } | ||
| yapf = "*" | ||
| pylint = "*" | ||
| isort = "*" | ||
| setuptools = "*" | ||
| build = "*" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I like the way
service-controlimplemented the help part:https://github.com/geoadmin/service-control/blob/develop/Makefile#L178
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I didn't know this was even possible! I've changed it accordingly...