Skip to content

Commit 0787ef6

Browse files
committed
chore: Use poetry (WIP)
1 parent ef8dbb8 commit 0787ef6

50 files changed

Lines changed: 1898 additions & 88 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 120

.gitignore

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
.idea/
2-
Pipfile.lock
3-
examples/
4-
output.md
52
__pycache__/
6-
src/dist/
7-
build/
3+
*.py[cod]
84
dist/
95
*.egg-info/
10-
*.pyc
6+
build/
7+
.coverage
8+
tests/tmp/*
9+
!tests/tmp/.gitkeep
10+
pip-wheel-metadata/
11+
.pytest_cache/

.gitlab-ci.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
variables:
2+
PIP_CACHE_DIR: "${CI_PROJECT_DIR}/.cache/pip"
3+
4+
cache:
5+
key: "${CI_JOB_NAME}"
6+
paths:
7+
- .cache/pip
8+
- .venv
9+
10+
stages:
11+
- quality
12+
- tests
13+
14+
.quality-template: &quality
15+
image: python:3.6
16+
stage: quality
17+
18+
check-black:
19+
<<: *quality
20+
before_script:
21+
- pip install black
22+
script: black --check src/ tests/
23+
24+
check-isort:
25+
<<: *quality
26+
before_script:
27+
- pip install isort[pyproject]
28+
script: isort -c -rc src/ tests/
29+
30+
check-flake8:
31+
<<: *quality
32+
before_script:
33+
- pip install flake8
34+
script: flake8 src/ tests/
35+
36+
check-bandit:
37+
<<: *quality
38+
before_script:
39+
- pip install bandit
40+
script: bandit -r src/
41+
42+
check-safety:
43+
<<: *quality
44+
before_script:
45+
- apt-get update
46+
- apt-get install -y python-enchant
47+
- pip install poetry
48+
- poetry config settings.virtualenvs.in-project true
49+
- poetry install -vv
50+
- poetry --version
51+
script: make check-safety
52+
53+
.test-template: &test
54+
stage: tests
55+
before_script:
56+
- apt-get update
57+
- apt-get install -y python-enchant
58+
- apt-get install -y aria2
59+
- pip install poetry
60+
- poetry config settings.virtualenvs.in-project true
61+
- poetry install -vv
62+
- poetry --version
63+
script: poetry run pytest -v
64+
65+
python3.6:
66+
<<: *test
67+
image: python:3.6
68+
69+
python3.7:
70+
<<: *test
71+
image: python:3.7
72+
73+
python3.8:
74+
<<: *test
75+
image: python:3.8-rc
76+
allow_failure: true
77+

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.6.8

CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at pawamoy@pm.me. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

CONTRIBUTING.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Contributing
2+
Contributions are welcome, and they are greatly appreciated!
3+
4+
Every little bit helps, and credit will always be given.
5+
6+
## Types of Contributions
7+
8+
### Bug Reports, Feature Requests, and Feedback
9+
Create a new [GitHub issue][1] or [GitLab issue][2]! Try to be as descriptive as possible.
10+
11+
### Bug Fixes, New Features and Documentation
12+
This project is developed using [`poetry`](https://github.com/sdispater/poetry).
13+
Follow the recommended installation method:
14+
15+
```bash
16+
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
17+
```
18+
19+
1. Fork the repository [on GitHub][3] or [on GitLab][4];
20+
1. Clone it on your machine;
21+
1. Go into the directory, and run `poetry install` to setup the development environment;
22+
1. Create a new branch with `git checkout -b bug-fix-or-feature-name`;
23+
1. Code!
24+
1. **Write tests. Run them all.** The commands to run the tests are:
25+
```bash
26+
poetry run pytest # to run all tests sequentially
27+
poetry run pytest -v # to print one test per line
28+
poetry run pytest -n 4 # to run tests in parallel (4 workers)
29+
poetry run pytest tests/test_api.py # to run tests in a specific file
30+
```
31+
32+
`pytest` provides the `-k` option to select tests based on their names:
33+
34+
```bash
35+
poetry run pytest -k "api and remove"
36+
poetry run pytest -k "utils or stats"
37+
```
38+
39+
See the [documentation for the `-k` option][5] for more examples.
40+
41+
7. When the tests pass, commit;
42+
8. Push;
43+
9. ...and finally, create a new [pull request][6] / [merge request][7]!
44+
Make sure to follow the guidelines.
45+
46+
## Merge/Pull Request Guidelines
47+
Make sure to have atomic commits and contextual commit messages!
48+
49+
[Check out this awesome blog post by Chris Beams for more information.][8]
50+
51+
[1]: https://github.com/pawamoy/aria2p/issues/new
52+
[2]: https://gitlab.com/pawamoy/aria2p/issues/new
53+
[3]: https://github.com/pawamoy/aria2p
54+
[4]: https://gitlab.com/pawamoy/aria2p
55+
[5]: https://docs.pytest.org/en/latest/example/markers.html#using-k-expr-to-select-tests-based-on-their-name
56+
[6]: https://github.com/pawamoy/aria2p/compare
57+
[7]: https://gitlab.com/pawamoy/aria2p/compare
58+
[8]: http://chris.beams.io/posts/git-commit/

CREDITS.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Credits
2+
These projects were used to build `aria2p`. **Thank you!**
3+
4+
[![`python`](https://www.vectorlogo.zone/logos/python/python-ar21.svg)](https://www.python.org/) |
5+
[`poetry`](https://poetry.eustace.io/)
6+
7+
### Direct dependencies
8+
[`flake8`](https://gitlab.com/pycqa/flake8) |
9+
[`ipython`](https://ipython.org) |
10+
[`pytest`](https://docs.pytest.org/en/latest/) |
11+
[`pytest-cov`](https://github.com/pytest-dev/pytest-cov) |
12+
[`pytest-sugar`](http://pivotfinland.com/pytest-sugar/) |
13+
[`pytest-xdist`](https://github.com/pytest-dev/pytest-xdist) |
14+
[`recommonmark`](https://github.com/rtfd/recommonmark) |
15+
[`requests`](http://python-requests.org) |
16+
[`responses`](https://github.com/getsentry/responses) |
17+
[`Sphinx`](http://sphinx-doc.org/) |
18+
[`sphinx-rtd-theme`](https://github.com/rtfd/sphinx_rtd_theme/) |
19+
[`sphinxcontrib-spelling`](https://github.com/sphinx-contrib/spelling)
20+
21+
### Indirect dependencies
22+
[`alabaster`](https://alabaster.readthedocs.io) |
23+
[`apipkg`](https://github.com/pytest-dev/apipkg) |
24+
[`atomicwrites`](https://github.com/untitaker/python-atomicwrites) |
25+
[`attrs`](https://www.attrs.org/) |
26+
[`Babel`](http://babel.pocoo.org/) |
27+
[`backcall`](https://github.com/takluyver/backcall) |
28+
[`certifi`](https://certifi.io/) |
29+
[`chardet`](https://github.com/chardet/chardet) |
30+
[![CommonMark](https://www.vectorlogo.zone/logos/commonmark/commonmark-ar21.svg)](https://github.com/rolandshoemaker/CommonMark-py) |
31+
[`coverage`](https://bitbucket.org/ned/coveragepy) |
32+
[`decorator`](https://github.com/micheles/decorator) |
33+
[`docutils`](http://docutils.sourceforge.net/) |
34+
[`execnet`](http://codespeak.net/execnet) |
35+
[`idna`](https://github.com/kjd/idna) |
36+
[`imagesize`](https://github.com/shibukawa/imagesize_py) |
37+
[`ipython-genutils`](http://ipython.org) |
38+
[`jedi`](https://github.com/davidhalter/jedi) |
39+
[![jinja2](https://www.vectorlogo.zone/logos/pocoo_jinja/pocoo_jinja-ar21.svg)](http://jinja.pocoo.org/?utm_source=vectorlogozone&utm_medium=referrer) |
40+
[`MarkupSafe`](https://www.palletsprojects.com/p/markupsafe/) |
41+
[`mccabe`](https://github.com/pycqa/mccabe) |
42+
[`more-itertools`](https://github.com/erikrose/more-itertools) |
43+
[`packaging`](https://github.com/pypa/packaging) |
44+
[`parso`](https://github.com/davidhalter/parso) |
45+
[`pexpect`](https://pexpect.readthedocs.io/) |
46+
[`pickleshare`](https://github.com/pickleshare/pickleshare) |
47+
[`pluggy`](https://github.com/pytest-dev/pluggy) |
48+
[`prompt-toolkit`](https://github.com/jonathanslenders/python-prompt-toolkit) |
49+
[`ptyprocess`](https://github.com/pexpect/ptyprocess) |
50+
[`py`](http://py.readthedocs.io/) |
51+
[`pycodestyle`](https://pycodestyle.readthedocs.io/) |
52+
[`pyenchant`](https://pythonhosted.org/pyenchant/) |
53+
[`pyflakes`](https://github.com/PyCQA/pyflakes) |
54+
[`Pygments`](http://pygments.org/) |
55+
[`pyparsing`](https://github.com/pyparsing/pyparsing/) |
56+
[`pytest-forked`](https://github.com/pytest-dev/pytest-forked) |
57+
[`pytz`](http://pythonhosted.org/pytz) |
58+
[`six`](https://github.com/benjaminp/six) |
59+
[`snowballstemmer`](https://github.com/shibukawa/snowball_py) |
60+
[`sphinxcontrib-websupport`](http://sphinx-doc.org/) |
61+
[`termcolor`](http://pypi.python.org/pypi/termcolor) |
62+
[`traitlets`](http://ipython.org) |
63+
[`urllib3`](https://urllib3.readthedocs.io/) |
64+
[`wcwidth`](https://github.com/jquast/wcwidth)
65+
66+
**[More credits from the author](http://pawamoy.github.io/credits/)**
67+
68+
*See one of your project without the logo? Make sure it's available on [VectorLogoZone](https://www.vectorlogo.zone/)
69+
([GitHub repo](https://github.com/VectorLogoZone/vectorlogozone)) and open an issue or send a pull/merge request!*

Makefile

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
.PHONY: help
2+
.PHONY: docs
3+
.PHONY: test-py36
4+
.PHONY: test-py37
5+
.PHONY: clean
6+
.PHONY: clean-tests
7+
.DEFAULT_GOAL := help
8+
9+
help: ## Print this help.
10+
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
11+
12+
readme: README.md ## Regenerate README.md.
13+
poetry run ./scripts/gen-readme-data.py | \
14+
poetry run jinja2 --format=json scripts/templates/README.md > README.md
15+
16+
docs: ## Build the documentation locally.
17+
poetry run sphinx-build -E -b html docs build/docs
18+
19+
check: check-bandit check-black check-flake8 check-isort check-safety check-ports check-docs-spelling ## Check it all!
20+
21+
update-spelling-wordlist: ## Update the spelling word list.
22+
scripts/update-spelling-wordlist.sh
23+
24+
check-docs-spelling: update-spelling-wordlist ## Check spelling in the documentation.
25+
scripts/check-docs-spelling.sh
26+
27+
check-black: ## Check if code is formatted nicely using black.
28+
poetry run black --check src/ tests/ docs/conf.py
29+
30+
check-isort: ## Check if imports are correctly ordered using isort.
31+
poetry run isort -c -rc src/ tests/ docs/conf.py
32+
33+
check-flake8: ## Check for general warnings in code using flake8.
34+
poetry run flake8 src/ tests/
35+
36+
check-bandit: ## Check for security warnings in code using bandit.
37+
poetry run bandit -r src/
38+
39+
check-safety: ## Check for vulnerabilities in dependencies using safety.
40+
poetry run pip freeze 2>/dev/null | \
41+
grep -v aria2p | \
42+
poetry run safety check --stdin --full-report 2>/dev/null
43+
44+
check-ports: ## Check if the ports used in the tests are all unique.
45+
scripts/check-ports.sh
46+
47+
run-black: ## Lint the code using black.
48+
poetry run black src/ tests/ docs/conf.py
49+
50+
run-isort: ## Sort the imports using isort.
51+
poetry run isort -y -rc src/ tests/ docs/conf.py
52+
53+
lint: run-black run-isort ## Run linting tools on the code.
54+
55+
clean-tests: ## Delete temporary tests files.
56+
@rm -rf tests/tmp/* 2>/dev/null
57+
58+
clean: clean-tests ## Delete temporary files.
59+
@rm -rf build 2>/dev/null
60+
@rm -rf dist 2>/dev/null
61+
@rm -rf src/aria2p.egg-info 2>/dev/null
62+
@rm -rf .coverage* 2>/dev/null
63+
@rm -rf .pytest_cache 2>/dev/null
64+
@rm -rf pip-wheel-metadata 2>/dev/null
65+
66+
test: check-ports clean-tests ## Run the tests using pytest.
67+
poetry run pytest -n6 2>/dev/null

Pipfile

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)