Skip to content
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

Feat/use pyproject toml and flit #5

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 12 additions & 29 deletions {{cookiecutter.project_slug}}/.circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,33 @@ jobs:
BASH_ENV: /root/.bashrc
steps:
- checkout
- run:
name: Compute Python dependencies key
command: cat requirements/*.pip > python.deps
- run:
name: Get the base reference branch
command: export BASE_BRANCH=$(base_branch)
- restore_cache:
keys:
{%- raw %}
- py-cache-{{ arch }}-{{ checksum "python.deps" }}
- py-cache-{{ arch }}-{{ checksum "pyproject.toml" }}
- py-cache-{{ arch }}-{{ .Branch }}
- py-cache-{{ arch }}-{{ .Environment.BASE_BRANCH }}
{%- endraw %}
- run:
name: Install python dependencies
command: |
virtualenv venv
source venv/bin/activate
pip install -r requirements/develop.pip || pip install -r requirements/develop.pip
{%- raw %}
make deps
- save_cache:
key: py-cache-{{ arch }}-{{ checksum "python.deps" }}
key: py-cache-{{ arch }}-{{ checksum "pyproject.toml" }}
paths:
- venv
- save_cache:
key: py-cache-{{ arch }}-{{ .Branch }}
paths:
- venv
{%- endraw %}
- run:
name: Run tests
command: |
source venv/bin/activate
inv qa test --report
make test
- store_test_results:
path: reports/
- store_artifacts:
Expand All @@ -56,37 +49,25 @@ jobs:
command: |
source venv/bin/activate
# Build a wheel release
if [[ $CIRCLE_TAG ]]; then
# This is a tagged release
inv dist
elif [[ "$CIRCLE_BRANCH" == feature/* ]]; then
# This is a feature branch
inv dist -b $CIRCLE_BUILD_NUM+${CIRCLE_BRANCH#*/}
else
# This is a simple development build
inv dist -b $CIRCLE_BUILD_NUM
fi
make build
- store_artifacts:
path: dist
- persist_to_workspace:
root: .
paths:
- dist
- venv
- .

publish:
docker:
- image: udata/circleci:2-alpine
steps:
- attach_workspace:
at: .
- run:
name: Install Twine
command: pip install twine
- deploy:
name: Publish on PyPI
command: twine upload --username "${PYPI_USERNAME}" --password "${PYPI_PASSWORD}" dist/*.whl

command: |
source venv/bin/activate
FLIT_USERNAME=${PYPI_USERNAME} FLIT_PASSWORD=${PYPI_PASSWORD} make publish
workflows:
version: 2
build:
Expand All @@ -100,7 +81,9 @@ workflows:
- build
filters:
branches:
ignore: /.*/
only:
- main
- /[0-9]+(\.[0-9]+)+/
tags:
only: /v[0-9]+(\.[0-9]+)*/
context: org-global
21 changes: 21 additions & 0 deletions {{cookiecutter.project_slug}}/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.PHONY: deps install lint build publish test

deps: ## Install dependencies
python -m pip install --upgrade pip
python -m pip install .[dev,test]

install: ## Install the package
python -m flit install

lint: ## Lint and static-check
python -m flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
python -m flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

build: ## Build dist
python -m flit build

publish: ## Publish to PyPi
python -m flit publish

test: ## Run tests
python -m pytest -ra --junitxml=reports/python/tests.xml
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Usage

Install the plugin package in you udata environement:
Install the plugin package in you udata environment:

```bash
pip install {{ cookiecutter.project_slug }}
Expand Down
5 changes: 2 additions & 3 deletions {{cookiecutter.project_slug}}/bumpr.rc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ commit = true
tag = true
tag_format = v{version}
push = true
clean = inv clean
tests = inv test
publish = inv dist
tests = make test
publish = make install
files =
README.md

Expand Down
95 changes: 95 additions & 0 deletions {{cookiecutter.project_slug}}/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@

[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[project]
name = "{{cookiecutter.project_slug}}"
description = "{{cookiecutter.description}}"
authors = [{name = "{{cookiecutter.author}}", email = "{{cookiecutter.email}}"}]
readme = "README.md"
license = {text = "{{cookiecutter.license}}"}
dynamic = ["version"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.9"
]
dependencies = [
"udata>=4.0.1",
]

[project.optional-dependencies]
dev = [
"flake8==3.7.8",
"invoke==1.3.0",
"pytest-cov==2.6.1",
"flit==3.6.0"



]
test = [
"httpretty==0.9.7",
"mock==3.0.5",
"pytest-flask==0.15.0",
"pytest-sugar==0.9.2",
"pytest==4.6.3"
]

[project.entry-points."udata.plugins"]
event-consumer = "udata_event_consumer"

{% if cookiecutter.has_harvester == 'yes' -%}
[project.entry-points."data.harvesters"]
{{cookiecutter.identifier}} = "{{cookiecutter.pypackage}}.harvesters:{{ cookiecutter.identifier.title().replace('-', '') }}Backend"
{%- endif %}

{% if cookiecutter.has_theme == 'yes' -%}
[project.entry-points."data.theme"]
{{cookiecutter.identifier}} = "{{cookiecutter.pypackage}}.theme"
{%- endif %}

{% if cookiecutter.has_views == 'yes' -%}
[project.entry-points."data.views"]
{{cookiecutter.identifier}} = "{{cookiecutter.pypackage}}.views"
{%- endif %}

{% if cookiecutter.has_metrics == 'yes' -%}
[project.entry-points."data.metrics"]
{{cookiecutter.identifier}} = "{{cookiecutter.pypackage}}.metrics"
{%- endif %}

{% if cookiecutter.has_models == 'yes' -%}
[project.entry-points."data.models"]
{{cookiecutter.identifier}} = "{{cookiecutter.pypackage}}.models"
{%- endif %}

{% if cookiecutter.has_linkchecker == 'yes' -%}
[project.entry-points."data.linkcheckers"[
{{cookiecutter.identifier}} = "{{cookiecutter.pypackage}}.linkchecker:{{ cookiecutter.identifier.title().replace('-', '') }}LinkChecker"
{%- endif %}

{% if cookiecutter.has_tasks == 'yes' -%}
[project.entry-points."data.tasks"]
{{cookiecutter.identifier}} = "{{cookiecutter.pypackage}}.tasks"
{%- endif %}

{% if cookiecutter.has_preview == 'yes' -%}
[project.entry-points."data.preview"]
{{cookiecutter.identifier}} = "{{cookiecutter.pypackage}}.preview:{{ cookiecutter.identifier.title().replace('-', '') }}Preview"
{%- endif %}

{% if cookiecutter.has_generic_plugin == 'yes' -%}
[project.entry-points."data.plugins"]
{{cookiecutter.identifier}} = "{{cookiecutter.pypackage}}"
{%- endif %}

[project.urls]
Home = "{{cookiecutter.website}}"

[tool.flit.module]
name = "udata_event_consumer"
5 changes: 0 additions & 5 deletions {{cookiecutter.project_slug}}/requirements/develop.pip

This file was deleted.

1 change: 0 additions & 1 deletion {{cookiecutter.project_slug}}/requirements/install.pip

This file was deleted.

5 changes: 0 additions & 5 deletions {{cookiecutter.project_slug}}/requirements/test.pip

This file was deleted.

120 changes: 0 additions & 120 deletions {{cookiecutter.project_slug}}/setup.py

This file was deleted.

Loading