mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-12 08:00:54 +00:00
merge template updates and refill vars
This commit is contained in:
@ -3,14 +3,14 @@ current_version = 0.1.5
|
|||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(-(?P<stage>[^.]*)\.(?P<devnum>\d+))?
|
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(-(?P<stage>[^.]*)\.(?P<devnum>\d+))?
|
||||||
serialize =
|
serialize =
|
||||||
{major}.{minor}.{patch}-{stage}.{devnum}
|
{major}.{minor}.{patch}-{stage}.{devnum}
|
||||||
{major}.{minor}.{patch}
|
{major}.{minor}.{patch}
|
||||||
|
|
||||||
[bumpversion:part:stage]
|
[bumpversion:part:stage]
|
||||||
optional_value = stable
|
optional_value = stable
|
||||||
first_value = stable
|
first_value = stable
|
||||||
values =
|
values =
|
||||||
alpha
|
alpha
|
||||||
beta
|
beta
|
||||||
stable
|
stable
|
||||||
@ -20,4 +20,3 @@ values =
|
|||||||
[bumpversion:file:setup.py]
|
[bumpversion:file:setup.py]
|
||||||
search = version="{current_version}",
|
search = version="{current_version}",
|
||||||
replace = version="{new_version}",
|
replace = version="{new_version}",
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
version: 2.0
|
version: 2.1
|
||||||
|
|
||||||
# heavily inspired by https://raw.githubusercontent.com/pinax/pinax-wiki/6bd2a99ab6f702e300d708532a6d1d9aa638b9f8/.circleci/config.yml
|
# heavily inspired by https://raw.githubusercontent.com/pinax/pinax-wiki/6bd2a99ab6f702e300d708532a6d1d9aa638b9f8/.circleci/config.yml
|
||||||
|
|
||||||
@ -14,64 +14,233 @@ common: &common
|
|||||||
command: ./.circleci/merge_pr.sh
|
command: ./.circleci/merge_pr.sh
|
||||||
when: on_fail
|
when: on_fail
|
||||||
- run:
|
- run:
|
||||||
name: merge pull request base (3nd try)
|
name: merge pull request base (3rd try)
|
||||||
command: ./.circleci/merge_pr.sh
|
command: ./.circleci/merge_pr.sh
|
||||||
when: on_fail
|
when: on_fail
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}
|
- cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}
|
||||||
- run:
|
- run:
|
||||||
name: install dependencies
|
name: install dependencies
|
||||||
command: pip install --user tox
|
command: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
python -m pip install tox
|
||||||
- run:
|
- run:
|
||||||
name: run tox
|
name: run tox
|
||||||
command: ~/.local/bin/tox -r
|
command: python -m tox run -r
|
||||||
- save_cache:
|
- save_cache:
|
||||||
paths:
|
paths:
|
||||||
- .hypothesis
|
- .hypothesis
|
||||||
- .tox
|
- .tox
|
||||||
- ~/.cache/pip
|
- ~/.cache/pip
|
||||||
- ~/.local
|
- ~/.local
|
||||||
- ./eggs
|
key: cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}
|
||||||
key: cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}
|
|
||||||
|
orbs:
|
||||||
|
win: circleci/windows@5.0.0
|
||||||
|
|
||||||
|
windows-wheel-steps:
|
||||||
|
windows-wheel-setup: &windows-wheel-setup
|
||||||
|
executor:
|
||||||
|
name: win/default
|
||||||
|
shell: bash.exe
|
||||||
|
working_directory: C:\Users\circleci\project\py-libp2p
|
||||||
|
environment:
|
||||||
|
TOXENV: windows-wheel
|
||||||
|
restore-cache-step: &restore-cache-step
|
||||||
|
restore_cache:
|
||||||
|
keys:
|
||||||
|
- cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}
|
||||||
|
install-pyenv-step: &install-pyenv-step
|
||||||
|
run:
|
||||||
|
name: install pyenv
|
||||||
|
command: |
|
||||||
|
pip install pyenv-win --target $HOME/.pyenv
|
||||||
|
echo 'export PYENV="$HOME/.pyenv/pyenv-win/"' >> $BASH_ENV
|
||||||
|
echo 'export PYENV_ROOT="$HOME/.pyenv/pyenv-win/"' >> $BASH_ENV
|
||||||
|
echo 'export PYENV_USERPROFILE="$HOME/.pyenv/pyenv-win/"' >> $BASH_ENV
|
||||||
|
echo 'export PATH="$PATH:$HOME/.pyenv/pyenv-win/bin"' >> $BASH_ENV
|
||||||
|
echo 'export PATH="$PATH:$HOME/.pyenv/pyenv-win/shims"' >> $BASH_ENV
|
||||||
|
source $BASH_ENV
|
||||||
|
pyenv update
|
||||||
|
install-latest-python-step: &install-latest-python-step
|
||||||
|
run:
|
||||||
|
name: install latest python version and tox
|
||||||
|
command: |
|
||||||
|
LATEST_VERSION=$(pyenv install --list | grep -E "${MINOR_VERSION}\.[0-9]+$" | tail -1)
|
||||||
|
echo "installing python version $LATEST_VERSION"
|
||||||
|
pyenv install $LATEST_VERSION
|
||||||
|
pyenv global $LATEST_VERSION
|
||||||
|
python3 -m pip install --upgrade pip
|
||||||
|
python3 -m pip install tox
|
||||||
|
run-tox-step: &run-tox-step
|
||||||
|
run:
|
||||||
|
name: run tox
|
||||||
|
command: |
|
||||||
|
echo 'running tox with' $(python3 --version)
|
||||||
|
python3 -m tox run -r
|
||||||
|
save-cache-step: &save-cache-step
|
||||||
|
save_cache:
|
||||||
|
paths:
|
||||||
|
- .tox
|
||||||
|
key: cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}
|
||||||
|
|
||||||
|
docs: &docs
|
||||||
|
docker:
|
||||||
|
- image: common
|
||||||
|
steps:
|
||||||
|
- run:
|
||||||
|
name: install latexpdf dependencies
|
||||||
|
command: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install latexmk tex-gyre texlive-fonts-extra
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docs:
|
docs:
|
||||||
<<: *common
|
<<: *docs
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/python:3.6
|
- image: cimg/python:3.8
|
||||||
environment:
|
environment:
|
||||||
TOXENV: docs
|
TOXENV: docs
|
||||||
lint:
|
|
||||||
|
py38-core:
|
||||||
<<: *common
|
<<: *common
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/python:3.6
|
- image: cimg/python:3.8
|
||||||
environment:
|
environment:
|
||||||
TOXENV: lint
|
TOXENV: py38-core
|
||||||
py36-core:
|
py39-core:
|
||||||
<<: *common
|
<<: *common
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/python:3.6
|
- image: cimg/python:3.9
|
||||||
environment:
|
environment:
|
||||||
TOXENV: py36-core
|
TOXENV: py39-core
|
||||||
py37-core:
|
py310-core:
|
||||||
<<: *common
|
<<: *common
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/python:3.7
|
- image: cimg/python:3.10
|
||||||
environment:
|
environment:
|
||||||
TOXENV: py37-core
|
TOXENV: py310-core
|
||||||
pypy3-core:
|
py311-core:
|
||||||
<<: *common
|
<<: *common
|
||||||
docker:
|
docker:
|
||||||
- image: pypy
|
- image: cimg/python:3.11
|
||||||
environment:
|
environment:
|
||||||
TOXENV: pypy3-core
|
TOXENV: py311-core
|
||||||
|
py312-core:
|
||||||
|
<<: *common
|
||||||
|
docker:
|
||||||
|
- image: cimg/python:3.12
|
||||||
|
environment:
|
||||||
|
TOXENV: py312-core
|
||||||
|
|
||||||
|
py38-lint:
|
||||||
|
<<: *common
|
||||||
|
docker:
|
||||||
|
- image: cimg/python:3.8
|
||||||
|
environment:
|
||||||
|
TOXENV: py38-lint
|
||||||
|
py39-lint:
|
||||||
|
<<: *common
|
||||||
|
docker:
|
||||||
|
- image: cimg/python:3.9
|
||||||
|
environment:
|
||||||
|
TOXENV: py39-lint
|
||||||
|
py310-lint:
|
||||||
|
<<: *common
|
||||||
|
docker:
|
||||||
|
- image: cimg/python:3.10
|
||||||
|
environment:
|
||||||
|
TOXENV: py310-lint
|
||||||
|
py311-lint:
|
||||||
|
<<: *common
|
||||||
|
docker:
|
||||||
|
- image: cimg/python:3.11
|
||||||
|
environment:
|
||||||
|
TOXENV: py311-lint
|
||||||
|
py312-lint:
|
||||||
|
<<: *common
|
||||||
|
docker:
|
||||||
|
- image: cimg/python:3.12
|
||||||
|
environment:
|
||||||
|
TOXENV: py312-lint
|
||||||
|
|
||||||
|
py38-wheel:
|
||||||
|
<<: *common
|
||||||
|
docker:
|
||||||
|
- image: cimg/python:3.8
|
||||||
|
environment:
|
||||||
|
TOXENV: py38-wheel
|
||||||
|
py39-wheel:
|
||||||
|
<<: *common
|
||||||
|
docker:
|
||||||
|
- image: cimg/python:3.9
|
||||||
|
environment:
|
||||||
|
TOXENV: py39-wheel
|
||||||
|
py310-wheel:
|
||||||
|
<<: *common
|
||||||
|
docker:
|
||||||
|
- image: cimg/python:3.10
|
||||||
|
environment:
|
||||||
|
TOXENV: py310-wheel
|
||||||
|
py311-wheel:
|
||||||
|
<<: *common
|
||||||
|
docker:
|
||||||
|
- image: cimg/python:3.11
|
||||||
|
environment:
|
||||||
|
TOXENV: py311-wheel
|
||||||
|
py312-wheel:
|
||||||
|
<<: *common
|
||||||
|
docker:
|
||||||
|
- image: cimg/python:3.12
|
||||||
|
environment:
|
||||||
|
TOXENV: py312-wheel
|
||||||
|
|
||||||
|
py311-windows-wheel:
|
||||||
|
<<: *windows-wheel-setup
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- <<: *restore-cache-step
|
||||||
|
- <<: *install-pyenv-step
|
||||||
|
- run:
|
||||||
|
name: set minor version
|
||||||
|
command: echo "export MINOR_VERSION='3.11'" >> $BASH_ENV
|
||||||
|
- <<: *install-latest-python-step
|
||||||
|
- <<: *run-tox-step
|
||||||
|
- <<: *save-cache-step
|
||||||
|
|
||||||
|
py312-windows-wheel:
|
||||||
|
<<: *windows-wheel-setup
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- <<: *restore-cache-step
|
||||||
|
- <<: *install-pyenv-step
|
||||||
|
- run:
|
||||||
|
name: set minor version
|
||||||
|
command: echo "export MINOR_VERSION='3.12'" >> $BASH_ENV
|
||||||
|
- <<: *install-latest-python-step
|
||||||
|
- <<: *run-tox-step
|
||||||
|
- <<: *save-cache-step
|
||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
version: 2
|
version: 2
|
||||||
test:
|
test:
|
||||||
jobs:
|
jobs:
|
||||||
- docs
|
- docs
|
||||||
- lint
|
- py38-core
|
||||||
- py36-core
|
- py39-core
|
||||||
- py37-core
|
- py310-core
|
||||||
- pypy3-core
|
- py311-core
|
||||||
|
- py312-core
|
||||||
|
- py38-lint
|
||||||
|
- py39-lint
|
||||||
|
- py310-lint
|
||||||
|
- py311-lint
|
||||||
|
- py312-lint
|
||||||
|
- py38-wheel
|
||||||
|
- py39-wheel
|
||||||
|
- py310-wheel
|
||||||
|
- py311-wheel
|
||||||
|
- py312-wheel
|
||||||
|
- py311-windows-wheel
|
||||||
|
- py312-windows-wheel
|
||||||
|
|||||||
4
.github/pull_request_template.md
vendored
4
.github/pull_request_template.md
vendored
@ -11,10 +11,8 @@ Summary of approach.
|
|||||||
[//]: # (Stay ahead of things, add list items here!)
|
[//]: # (Stay ahead of things, add list items here!)
|
||||||
- [ ] Clean up commit history
|
- [ ] Clean up commit history
|
||||||
|
|
||||||
[//]: # (For important changes that should go into the release notes please add a newsfragment file as explained here: https://github.com/libp2p/py-libp2p/blob/master/newsfragments/README.md)
|
|
||||||
|
|
||||||
[//]: # (See: https://py-libp2p.readthedocs.io/en/latest/contributing.html#pull-requests)
|
[//]: # (See: https://py-libp2p.readthedocs.io/en/latest/contributing.html#pull-requests)
|
||||||
- [ ] Add entry to the [release notes](https://github.com/libp2p/py-libp2p/blob/master/newsfragments/README.md)
|
- [ ] Add entry to the [release notes](https://github.com/libp2p/py-libp2p/blob/main/newsfragments/README.md)
|
||||||
|
|
||||||
#### Cute Animal Picture
|
#### Cute Animal Picture
|
||||||
|
|
||||||
|
|||||||
57
.gitignore
vendored
57
.gitignore
vendored
@ -11,6 +11,7 @@ __pycache__/
|
|||||||
*.egg-info
|
*.egg-info
|
||||||
dist
|
dist
|
||||||
build
|
build
|
||||||
|
.build
|
||||||
eggs
|
eggs
|
||||||
.eggs
|
.eggs
|
||||||
parts
|
parts
|
||||||
@ -21,7 +22,9 @@ develop-eggs
|
|||||||
.installed.cfg
|
.installed.cfg
|
||||||
lib
|
lib
|
||||||
lib64
|
lib64
|
||||||
|
pip-wheel-metadata
|
||||||
venv*
|
venv*
|
||||||
|
.venv*
|
||||||
.Python
|
.Python
|
||||||
downloads/
|
downloads/
|
||||||
wheels/
|
wheels/
|
||||||
@ -61,15 +64,37 @@ docs/modules.rst
|
|||||||
docs/*.internal.rst
|
docs/*.internal.rst
|
||||||
docs/*._utils.*
|
docs/*._utils.*
|
||||||
|
|
||||||
# Hypothese Property base testing
|
# Blockchain
|
||||||
|
chains
|
||||||
|
|
||||||
|
# Hypothesis Property base testing
|
||||||
.hypothesis
|
.hypothesis
|
||||||
|
|
||||||
# tox/pytest cache
|
# tox/pytest cache
|
||||||
.cache
|
.cache
|
||||||
|
.pytest_cache
|
||||||
|
|
||||||
|
# pycache
|
||||||
|
__pycache__/
|
||||||
|
|
||||||
# Test output logs
|
# Test output logs
|
||||||
logs
|
logs
|
||||||
|
|
||||||
|
# VIM temp files
|
||||||
|
*.sw[op]
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache
|
||||||
|
|
||||||
|
# macOS
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# vs-code
|
||||||
|
.vscode
|
||||||
|
|
||||||
### JetBrains template
|
### JetBrains template
|
||||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
@ -96,32 +121,33 @@ logs
|
|||||||
# Mongo Explorer plugin:
|
# Mongo Explorer plugin:
|
||||||
.idea/mongoSettings.xml
|
.idea/mongoSettings.xml
|
||||||
|
|
||||||
# VIM temp files
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||||
*.sw[op]
|
# For a more precise, explicit template, see:
|
||||||
|
# https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
# mypy
|
## General
|
||||||
.mypy_cache
|
.idea/*
|
||||||
|
.idea_modules/*
|
||||||
|
|
||||||
## File-based project format:
|
## File-based project format:
|
||||||
*.iws
|
*.iws
|
||||||
|
|
||||||
|
## IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
## Plugin-specific files:
|
## Plugin-specific files:
|
||||||
|
|
||||||
# IntelliJ
|
### JIRA plugin
|
||||||
/out/
|
|
||||||
|
|
||||||
# mpeltonen/sbt-idea plugin
|
|
||||||
.idea_modules/
|
|
||||||
|
|
||||||
# JIRA plugin
|
|
||||||
atlassian-ide-plugin.xml
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
### Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
com_crashlytics_export_strings.xml
|
com_crashlytics_export_strings.xml
|
||||||
crashlytics.properties
|
crashlytics.properties
|
||||||
crashlytics-build.properties
|
crashlytics-build.properties
|
||||||
fabric.properties
|
fabric.properties
|
||||||
|
|
||||||
|
# END JetBrains section
|
||||||
|
|
||||||
# PyInstaller
|
# PyInstaller
|
||||||
# Usually these files are written by a python script from a template
|
# Usually these files are written by a python script from a template
|
||||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
@ -146,9 +172,6 @@ target/
|
|||||||
# Jupyter Notebook
|
# Jupyter Notebook
|
||||||
.ipynb_checkpoints
|
.ipynb_checkpoints
|
||||||
|
|
||||||
# pyenv
|
|
||||||
.python-version
|
|
||||||
|
|
||||||
# celery beat schedule file
|
# celery beat schedule file
|
||||||
celerybeat-schedule
|
celerybeat-schedule
|
||||||
|
|
||||||
@ -172,5 +195,3 @@ env.bak/
|
|||||||
# mkdocs documentation
|
# mkdocs documentation
|
||||||
/site
|
/site
|
||||||
|
|
||||||
# vscode
|
|
||||||
.vscode/
|
|
||||||
|
|||||||
52
.pre-commit-config.yaml
Normal file
52
.pre-commit-config.yaml
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
exclude: '.project-template|docs/conf.py|.bumpversion.cfg'
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.5.0
|
||||||
|
hooks:
|
||||||
|
- id: check-yaml
|
||||||
|
- id: check-toml
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
|
rev: v3.15.0
|
||||||
|
hooks:
|
||||||
|
- id: pyupgrade
|
||||||
|
args: [--py38-plus]
|
||||||
|
- repo: https://github.com/psf/black
|
||||||
|
rev: 19.3b0
|
||||||
|
hooks:
|
||||||
|
- id: black
|
||||||
|
- repo: https://github.com/PyCQA/flake8
|
||||||
|
rev: 3.7.9
|
||||||
|
hooks:
|
||||||
|
- id: flake8
|
||||||
|
additional_dependencies:
|
||||||
|
- flake8-bugbear==23.9.16
|
||||||
|
exclude: setup.py
|
||||||
|
- repo: https://github.com/PyCQA/autoflake
|
||||||
|
rev: v2.2.1
|
||||||
|
hooks:
|
||||||
|
- id: autoflake
|
||||||
|
- repo: https://github.com/pycqa/isort
|
||||||
|
rev: 4.3.21
|
||||||
|
hooks:
|
||||||
|
- id: isort
|
||||||
|
- repo: https://github.com/pycqa/pydocstyle
|
||||||
|
rev: 6.3.0
|
||||||
|
hooks:
|
||||||
|
- id: pydocstyle
|
||||||
|
additional_dependencies:
|
||||||
|
- tomli # required until >= python311
|
||||||
|
- repo: https://github.com/executablebooks/mdformat
|
||||||
|
rev: 0.7.17
|
||||||
|
hooks:
|
||||||
|
- id: mdformat
|
||||||
|
additional_dependencies:
|
||||||
|
- mdformat-gfm
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||||
|
rev: v0.780
|
||||||
|
hooks:
|
||||||
|
- id: mypy
|
||||||
|
additional_dependencies:
|
||||||
|
- mypy-protobuf
|
||||||
|
exclude: tests/
|
||||||
71
.project-template/fill_template_vars.py
Normal file
71
.project-template/fill_template_vars.py
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import re
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def _find_files(project_root):
|
||||||
|
path_exclude_pattern = r"\.git($|\/)|venv|_build"
|
||||||
|
file_exclude_pattern = r"fill_template_vars\.py|\.swp$"
|
||||||
|
filepaths = []
|
||||||
|
for dir_path, _dir_names, file_names in os.walk(project_root):
|
||||||
|
if not re.search(path_exclude_pattern, dir_path):
|
||||||
|
for file in file_names:
|
||||||
|
if not re.search(file_exclude_pattern, file):
|
||||||
|
filepaths.append(str(Path(dir_path, file)))
|
||||||
|
|
||||||
|
return filepaths
|
||||||
|
|
||||||
|
|
||||||
|
def _replace(pattern, replacement, project_root):
|
||||||
|
print(f"Replacing values: {pattern}")
|
||||||
|
for file in _find_files(project_root):
|
||||||
|
try:
|
||||||
|
with open(file) as f:
|
||||||
|
content = f.read()
|
||||||
|
content = re.sub(pattern, replacement, content)
|
||||||
|
with open(file, "w") as f:
|
||||||
|
f.write(content)
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
project_root = Path(os.path.realpath(sys.argv[0])).parent.parent
|
||||||
|
|
||||||
|
module_name = input("What is your python module name? ")
|
||||||
|
|
||||||
|
pypi_input = input(f"What is your pypi package name? (default: {module_name}) ")
|
||||||
|
pypi_name = pypi_input or module_name
|
||||||
|
|
||||||
|
repo_input = input(f"What is your github project name? (default: {pypi_name}) ")
|
||||||
|
repo_name = repo_input or pypi_name
|
||||||
|
|
||||||
|
rtd_input = input(
|
||||||
|
f"What is your readthedocs.org project name? (default: {pypi_name}) "
|
||||||
|
)
|
||||||
|
rtd_name = rtd_input or pypi_name
|
||||||
|
|
||||||
|
project_input = input(
|
||||||
|
f"What is your project name (ex: at the top of the README)? (default: {repo_name}) "
|
||||||
|
)
|
||||||
|
project_name = project_input or repo_name
|
||||||
|
|
||||||
|
short_description = input("What is a one-liner describing the project? ")
|
||||||
|
|
||||||
|
_replace("<MODULE_NAME>", module_name, project_root)
|
||||||
|
_replace("<PYPI_NAME>", pypi_name, project_root)
|
||||||
|
_replace("<REPO_NAME>", repo_name, project_root)
|
||||||
|
_replace("<RTD_NAME>", rtd_name, project_root)
|
||||||
|
_replace("<PROJECT_NAME>", project_name, project_root)
|
||||||
|
_replace("<SHORT_DESCRIPTION>", short_description, project_root)
|
||||||
|
|
||||||
|
os.makedirs(project_root / module_name, exist_ok=True)
|
||||||
|
Path(project_root / module_name / "__init__.py").touch()
|
||||||
|
Path(project_root / module_name / "py.typed").touch()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@ -1,48 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
|
|
||||||
PROJECT_ROOT=$(dirname $(dirname $(python -c 'import os, sys; sys.stdout.write(os.path.realpath(sys.argv[1]))' "$0")))
|
|
||||||
|
|
||||||
echo "What is your python module name?"
|
|
||||||
read MODULE_NAME
|
|
||||||
|
|
||||||
echo "What is your pypi package name? (default: $MODULE_NAME)"
|
|
||||||
read PYPI_INPUT
|
|
||||||
PYPI_NAME=${PYPI_INPUT:-$MODULE_NAME}
|
|
||||||
|
|
||||||
echo "What is your github project name? (default: $PYPI_NAME)"
|
|
||||||
read REPO_INPUT
|
|
||||||
REPO_NAME=${REPO_INPUT:-$PYPI_NAME}
|
|
||||||
|
|
||||||
echo "What is your readthedocs.org project name? (default: $PYPI_NAME)"
|
|
||||||
read RTD_INPUT
|
|
||||||
RTD_NAME=${RTD_INPUT:-$PYPI_NAME}
|
|
||||||
|
|
||||||
echo "What is your project name (ex: at the top of the README)? (default: $REPO_NAME)"
|
|
||||||
read PROJECT_INPUT
|
|
||||||
PROJECT_NAME=${PROJECT_INPUT:-$REPO_NAME}
|
|
||||||
|
|
||||||
echo "What is a one-liner describing the project?"
|
|
||||||
read SHORT_DESCRIPTION
|
|
||||||
|
|
||||||
_replace() {
|
|
||||||
local find_cmd=(find "$PROJECT_ROOT" ! -perm -u=x ! -path '*/.git/*' -type f)
|
|
||||||
|
|
||||||
if [[ $(uname) == Darwin ]]; then
|
|
||||||
"${find_cmd[@]}" -exec sed -i '' "$1" {} +
|
|
||||||
else
|
|
||||||
"${find_cmd[@]}" -exec sed -i "$1" {} +
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
_replace "s/<MODULE_NAME>/$MODULE_NAME/g"
|
|
||||||
_replace "s/<PYPI_NAME>/$PYPI_NAME/g"
|
|
||||||
_replace "s/<REPO_NAME>/$REPO_NAME/g"
|
|
||||||
_replace "s/<RTD_NAME>/$RTD_NAME/g"
|
|
||||||
_replace "s/<PROJECT_NAME>/$PROJECT_NAME/g"
|
|
||||||
_replace "s/<SHORT_DESCRIPTION>/$SHORT_DESCRIPTION/g"
|
|
||||||
|
|
||||||
mkdir -p "$PROJECT_ROOT/$MODULE_NAME"
|
|
||||||
touch "$PROJECT_ROOT/$MODULE_NAME/__init__.py"
|
|
||||||
39
.project-template/refill_template_vars.py
Normal file
39
.project-template/refill_template_vars.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
template_dir = Path(os.path.dirname(sys.argv[0]))
|
||||||
|
template_vars_file = template_dir / "template_vars.txt"
|
||||||
|
fill_template_vars_script = template_dir / "fill_template_vars.py"
|
||||||
|
|
||||||
|
with open(template_vars_file, "r") as input_file:
|
||||||
|
content_lines = input_file.readlines()
|
||||||
|
|
||||||
|
process = subprocess.Popen(
|
||||||
|
[sys.executable, str(fill_template_vars_script)],
|
||||||
|
stdin=subprocess.PIPE,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
for line in content_lines:
|
||||||
|
process.stdin.write(line)
|
||||||
|
process.stdin.flush()
|
||||||
|
|
||||||
|
stdout, stderr = process.communicate()
|
||||||
|
|
||||||
|
if process.returncode != 0:
|
||||||
|
print(f"Error occurred: {stderr}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
print(stdout)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@ -1,2 +0,0 @@
|
|||||||
TEMPLATE_DIR=$(dirname $(readlink -f "$0"))
|
|
||||||
<"$TEMPLATE_DIR/template_vars.txt" "$TEMPLATE_DIR/fill_template_vars.sh"
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
[pydocstyle]
|
|
||||||
; All error codes found here:
|
|
||||||
; http://www.pydocstyle.org/en/3.0.0/error_codes.html
|
|
||||||
;
|
|
||||||
; Ignored:
|
|
||||||
; D1 - Missing docstring error codes
|
|
||||||
;
|
|
||||||
; Selected:
|
|
||||||
; D2 - Whitespace error codes
|
|
||||||
; D3 - Quote error codes
|
|
||||||
; D4 - Content related error codes
|
|
||||||
select=D2,D3,D4
|
|
||||||
|
|
||||||
; Extra ignores:
|
|
||||||
; D200 - One-line docstring should fit on one line with quotes
|
|
||||||
; D203 - 1 blank line required before class docstring
|
|
||||||
; D204 - 1 blank line required after class docstring
|
|
||||||
; D205 - 1 blank line required between summary line and description
|
|
||||||
; D212 - Multi-line docstring summary should start at the first line
|
|
||||||
; D302 - Use u""" for Unicode docstrings
|
|
||||||
; D400 - First line should end with a period
|
|
||||||
; D401 - First line should be in imperative mood
|
|
||||||
; D412 - No blank lines allowed between a section header and its content
|
|
||||||
add-ignore=D200,D203,D204,D205,D212,D302,D400,D401,D412
|
|
||||||
|
|
||||||
; Explanation:
|
|
||||||
; D400 - Enabling this error code seems to make it a requirement that the first
|
|
||||||
; sentence in a docstring is not split across two lines. It also makes it a
|
|
||||||
; requirement that no docstring can have a multi-sentence description without a
|
|
||||||
; summary line. Neither one of those requirements seem appropriate.
|
|
||||||
20
.readthedocs.yaml
Normal file
20
.readthedocs.yaml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
version: 2
|
||||||
|
|
||||||
|
build:
|
||||||
|
os: ubuntu-22.04
|
||||||
|
tools:
|
||||||
|
python: "3.8"
|
||||||
|
|
||||||
|
sphinx:
|
||||||
|
configuration: docs/conf.py
|
||||||
|
fail_on_warning: true
|
||||||
|
|
||||||
|
python:
|
||||||
|
install:
|
||||||
|
- method: pip
|
||||||
|
path: .
|
||||||
|
extra_requirements:
|
||||||
|
- docs
|
||||||
|
|
||||||
|
# Build all formats for RTD Downloads - htmlzip, pdf, epub
|
||||||
|
formats: all
|
||||||
37
.travis.yml
37
.travis.yml
@ -1,37 +0,0 @@
|
|||||||
language: python
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- python: 3.6-dev
|
|
||||||
dist: xenial
|
|
||||||
env: TOXENV=py36-test
|
|
||||||
- python: 3.7
|
|
||||||
dist: xenial
|
|
||||||
env: TOXENV=py37-test
|
|
||||||
- python: 3.7
|
|
||||||
dist: xenial
|
|
||||||
env: TOXENV=lint
|
|
||||||
- python: 3.7
|
|
||||||
dist: xenial
|
|
||||||
env: TOXENV=docs
|
|
||||||
- python: 3.7
|
|
||||||
dist: xenial
|
|
||||||
env: TOXENV=py37-interop GOBINPKG=go1.13.8.linux-amd64.tar.gz
|
|
||||||
sudo: true
|
|
||||||
before_install:
|
|
||||||
- wget https://dl.google.com/go/$GOBINPKG
|
|
||||||
- sudo tar -C /usr/local -xzf $GOBINPKG
|
|
||||||
- export GOPATH=$HOME/go
|
|
||||||
- export GOROOT=/usr/local/go
|
|
||||||
- export PATH=$GOROOT/bin:$GOPATH/bin:$PATH
|
|
||||||
- ./tests_interop/go_pkgs/install_interop_go_pkgs.sh
|
|
||||||
|
|
||||||
install:
|
|
||||||
- pip install --upgrade pip
|
|
||||||
- pip install tox
|
|
||||||
|
|
||||||
script:
|
|
||||||
- tox
|
|
||||||
|
|
||||||
notifications:
|
|
||||||
slack: py-libp2p:RK0WVoQZhQXLgIKfHNPL1TR2
|
|
||||||
21
LICENSE
21
LICENSE
@ -1,21 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2019 The Ethereum Foundation
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
12
MANIFEST.in
Normal file
12
MANIFEST.in
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
include LICENSE-APACHE
|
||||||
|
include LICENSE-MIT
|
||||||
|
include README.md
|
||||||
|
|
||||||
|
recursive-include tests *
|
||||||
|
|
||||||
|
global-include *.pyi
|
||||||
|
|
||||||
|
recursive-exclude * __pycache__
|
||||||
|
recursive-exclude * *.py[co]
|
||||||
|
prune .tox
|
||||||
|
prune venv*
|
||||||
66
Makefile
66
Makefile
@ -5,11 +5,11 @@ CURRENT_SIGN_SETTING := $(shell git config commit.gpgSign)
|
|||||||
help:
|
help:
|
||||||
@echo "clean-build - remove build artifacts"
|
@echo "clean-build - remove build artifacts"
|
||||||
@echo "clean-pyc - remove Python file artifacts"
|
@echo "clean-pyc - remove Python file artifacts"
|
||||||
@echo "lint - check style with flake8, etc"
|
@echo "lint - fix linting issues with pre-commit"
|
||||||
@echo "lint-roll - auto-correct styles with isort, black, docformatter, etc"
|
|
||||||
@echo "test - run tests quickly with the default Python"
|
@echo "test - run tests quickly with the default Python"
|
||||||
@echo "testall - run tests on every Python version with tox"
|
@echo "docs - generate docs and open in browser (linux-docs for version on linux)"
|
||||||
@echo "release - package and upload a release"
|
@echo "notes - consume towncrier newsfragments/ and update release notes in docs/"
|
||||||
|
@echo "release - package and upload a release (does not run notes target)"
|
||||||
@echo "dist - package"
|
@echo "dist - package"
|
||||||
|
|
||||||
FILES_TO_LINT = libp2p tests tests_interop examples setup.py
|
FILES_TO_LINT = libp2p tests tests_interop examples setup.py
|
||||||
@ -38,7 +38,6 @@ clean: clean-build clean-pyc
|
|||||||
clean-build:
|
clean-build:
|
||||||
rm -fr build/
|
rm -fr build/
|
||||||
rm -fr dist/
|
rm -fr dist/
|
||||||
rm -fr *.egg-info
|
|
||||||
|
|
||||||
clean-pyc:
|
clean-pyc:
|
||||||
find . -name '*.pyc' -exec rm -f {} +
|
find . -name '*.pyc' -exec rm -f {} +
|
||||||
@ -47,37 +46,36 @@ clean-pyc:
|
|||||||
find . -name '__pycache__' -exec rm -rf {} +
|
find . -name '__pycache__' -exec rm -rf {} +
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
mypy -p libp2p -p examples --config-file mypy.ini
|
@pre-commit run --all-files --show-diff-on-failure || ( \
|
||||||
flake8 $(FILES_TO_LINT)
|
echo "\n\n\n * pre-commit should have fixed the errors above. Running again to make sure everything is good..." \
|
||||||
black --check $(FILES_TO_LINT)
|
&& pre-commit run --all-files --show-diff-on-failure \
|
||||||
isort --recursive --check-only --diff $(FILES_TO_LINT)
|
)
|
||||||
docformatter --pre-summary-newline --check --recursive $(FILES_TO_LINT)
|
|
||||||
tox -e lint # This is probably redundant, but just in case...
|
|
||||||
|
|
||||||
lint-roll:
|
|
||||||
isort --recursive $(FILES_TO_LINT)
|
|
||||||
black $(FILES_TO_LINT)
|
|
||||||
docformatter -ir --pre-summary-newline $(FILES_TO_LINT)
|
|
||||||
$(MAKE) lint
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
pytest tests
|
pytest tests
|
||||||
|
|
||||||
test-all:
|
|
||||||
tox
|
|
||||||
|
|
||||||
build-docs:
|
build-docs:
|
||||||
sphinx-apidoc -o docs/ . setup.py "*conftest*" "libp2p/tools/interop*"
|
sphinx-apidoc -o docs/ . setup.py "*conftest*" "libp2p/tools/interop*"
|
||||||
$(MAKE) -C docs clean
|
$(MAKE) -C docs clean
|
||||||
$(MAKE) -C docs html
|
$(MAKE) -C docs html
|
||||||
$(MAKE) -C docs doctest
|
$(MAKE) -C docs doctest
|
||||||
./newsfragments/validate_files.py
|
|
||||||
towncrier --draft --version preview
|
build-docs-ci:
|
||||||
|
$(MAKE) -C docs latexpdf
|
||||||
|
$(MAKE) -C docs epub
|
||||||
|
|
||||||
docs: build-docs
|
validate-newsfragments:
|
||||||
|
python ./newsfragments/validate_files.py
|
||||||
|
towncrier build --draft --version preview
|
||||||
|
|
||||||
|
check-docs: build-docs validate-newsfragments
|
||||||
|
|
||||||
|
check-docs-ci: build-docs build-docs-ci validate-newsfragments
|
||||||
|
|
||||||
|
docs: check-docs
|
||||||
open docs/_build/html/index.html
|
open docs/_build/html/index.html
|
||||||
|
|
||||||
linux-docs: build-docs
|
linux-docs: check-docs
|
||||||
xdg-open docs/_build/html/index.html
|
xdg-open docs/_build/html/index.html
|
||||||
|
|
||||||
package: clean
|
package: clean
|
||||||
@ -85,17 +83,23 @@ package: clean
|
|||||||
python scripts/release/test_package.py
|
python scripts/release/test_package.py
|
||||||
|
|
||||||
notes:
|
notes:
|
||||||
|
check-bump:
|
||||||
|
ifndef bump
|
||||||
|
$(error bump must be set, typically: major, minor, patch, or devnum)
|
||||||
|
endif
|
||||||
|
|
||||||
|
notes: check-bump
|
||||||
# Let UPCOMING_VERSION be the version that is used for the current bump
|
# Let UPCOMING_VERSION be the version that is used for the current bump
|
||||||
$(eval UPCOMING_VERSION=$(shell bumpversion $(bump) --dry-run --list | grep new_version= | sed 's/new_version=//g'))
|
$(eval UPCOMING_VERSION=$(shell bumpversion $(bump) --dry-run --list | grep new_version= | sed 's/new_version=//g'))
|
||||||
# Now generate the release notes to have them included in the release commit
|
# Now generate the release notes to have them included in the release commit
|
||||||
towncrier --yes --version $(UPCOMING_VERSION)
|
towncrier build --yes --version $(UPCOMING_VERSION)
|
||||||
# Before we bump the version, make sure that the towncrier-generated docs will build
|
# Before we bump the version, make sure that the towncrier-generated docs will build
|
||||||
make build-docs
|
make build-docs
|
||||||
git commit -m "Compile release notes"
|
git commit -m "Compile release notes for v$(UPCOMING_VERSION)"
|
||||||
|
|
||||||
release: clean
|
release: check-bump clean
|
||||||
# require that you be on a branch that's linked to upstream/master
|
# require that upstream is configured for ethereum/py-libp2p
|
||||||
git status -s -b | head -1 | grep "\.\.upstream/master"
|
@git remote -v | grep -E "upstream\tgit@github.com:ethereum/py-libp2p.git \(push\)|upstream\thttps://(www.)?github.com/ethereum/py-libp2p \(push\)"
|
||||||
# verify that docs build correctly
|
# verify that docs build correctly
|
||||||
./newsfragments/validate_files.py is-empty
|
./newsfragments/validate_files.py is-empty
|
||||||
make build-docs
|
make build-docs
|
||||||
@ -103,11 +107,11 @@ release: clean
|
|||||||
git config commit.gpgSign true
|
git config commit.gpgSign true
|
||||||
bumpversion $(bump)
|
bumpversion $(bump)
|
||||||
git push upstream && git push upstream --tags
|
git push upstream && git push upstream --tags
|
||||||
python setup.py sdist bdist_wheel
|
python -m build
|
||||||
twine upload dist/*
|
twine upload dist/*
|
||||||
git config commit.gpgSign "$(CURRENT_SIGN_SETTING)"
|
git config commit.gpgSign "$(CURRENT_SIGN_SETTING)"
|
||||||
|
|
||||||
|
|
||||||
dist: clean
|
dist: clean
|
||||||
python setup.py sdist bdist_wheel
|
python -m build
|
||||||
ls -l dist
|
ls -l dist
|
||||||
|
|||||||
@ -73,11 +73,15 @@ Note that tests/libp2p/test_libp2p.py contains an end-to-end messaging test betw
|
|||||||
|
|
||||||
### Release setup
|
### Release setup
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
Releases follow the same basic pattern as releases of some tangentially-related projects,
|
Releases follow the same basic pattern as releases of some tangentially-related projects,
|
||||||
like Trinity. See [Trinity's release instructions](
|
like Trinity. See [Trinity's release instructions](
|
||||||
https://trinity-client.readthedocs.io/en/latest/contributing.html#releasing).
|
https://trinity-client.readthedocs.io/en/latest/contributing.html#releasing).
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
=======
|
||||||
|
To release a new version:
|
||||||
|
>>>>>>> template
|
||||||
|
|
||||||
The protobuf description in this repository was generated by `protoc` at version `3.7.1`.
|
The protobuf description in this repository was generated by `protoc` at version `3.7.1`.
|
||||||
|
|
||||||
|
|||||||
@ -85,17 +85,17 @@ qthelp:
|
|||||||
@echo
|
@echo
|
||||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||||
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/web3.qhcp"
|
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/libp2p.qhcp"
|
||||||
@echo "To view the help file:"
|
@echo "To view the help file:"
|
||||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/web3.qhc"
|
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/libp2p.qhc"
|
||||||
|
|
||||||
devhelp:
|
devhelp:
|
||||||
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
||||||
@echo
|
@echo
|
||||||
@echo "Build finished."
|
@echo "Build finished."
|
||||||
@echo "To view the help file:"
|
@echo "To view the help file:"
|
||||||
@echo "# mkdir -p $$HOME/.local/share/devhelp/web3"
|
@echo "# mkdir -p $$HOME/.local/share/devhelp/libp2p"
|
||||||
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/web3"
|
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/libp2p"
|
||||||
@echo "# devhelp"
|
@echo "# devhelp"
|
||||||
|
|
||||||
epub:
|
epub:
|
||||||
|
|||||||
166
docs/conf.py
166
docs/conf.py
@ -15,45 +15,46 @@
|
|||||||
# If extensions (or modules to document with autodoc) are in another directory,
|
# If extensions (or modules to document with autodoc) are in another directory,
|
||||||
# add these directories to sys.path here. If the directory is relative to the
|
# add these directories to sys.path here. If the directory is relative to the
|
||||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||||
#sys.path.insert(0, os.path.abspath('.'))
|
# sys.path.insert(0, os.path.abspath('.'))
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
DIR = os.path.dirname('__file__')
|
DIR = os.path.dirname("__file__")
|
||||||
with open (os.path.join(DIR, '../setup.py'), 'r') as f:
|
with open(os.path.join(DIR, "../setup.py"), "r") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
if 'version=' in line:
|
if "version=" in line:
|
||||||
setup_version = line.split('"')[1]
|
setup_version = line.split('"')[1]
|
||||||
break
|
break
|
||||||
|
|
||||||
# -- General configuration ------------------------------------------------
|
# -- General configuration ------------------------------------------------
|
||||||
|
|
||||||
# If your documentation needs a minimal Sphinx version, state it here.
|
# If your documentation needs a minimal Sphinx version, state it here.
|
||||||
#needs_sphinx = '1.0'
|
# needs_sphinx = '1.0'
|
||||||
|
|
||||||
# Add any Sphinx extension module names here, as strings. They can be
|
# Add any Sphinx extension module names here, as strings. They can be
|
||||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||||
# ones.
|
# ones.
|
||||||
extensions = [
|
extensions = [
|
||||||
'sphinx.ext.autodoc',
|
"sphinx.ext.autodoc",
|
||||||
'sphinx.ext.doctest',
|
"sphinx.ext.doctest",
|
||||||
'sphinx.ext.intersphinx',
|
"sphinx.ext.intersphinx",
|
||||||
|
"sphinx_rtd_theme",
|
||||||
]
|
]
|
||||||
|
|
||||||
# Add any paths that contain templates here, relative to this directory.
|
# Add any paths that contain templates here, relative to this directory.
|
||||||
templates_path = ['_templates']
|
templates_path = ["_templates"]
|
||||||
|
|
||||||
# The suffix of source filenames.
|
# The suffix of source filenames.
|
||||||
source_suffix = '.rst'
|
source_suffix = ".rst"
|
||||||
|
|
||||||
# The encoding of source files.
|
# The encoding of source files.
|
||||||
#source_encoding = 'utf-8-sig'
|
# source_encoding = 'utf-8-sig'
|
||||||
|
|
||||||
# The master toctree document.
|
# The master toctree document.
|
||||||
master_doc = 'index'
|
master_doc = "index"
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = 'py-libp2p'
|
project = "py-libp2p"
|
||||||
copyright = '2019, The Ethereum Foundation'
|
copyright = '2019, The Ethereum Foundation'
|
||||||
|
|
||||||
__version__ = setup_version
|
__version__ = setup_version
|
||||||
@ -62,176 +63,179 @@ __version__ = setup_version
|
|||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = '.'.join(__version__.split('.')[:2])
|
version = ".".join(__version__.split(".")[:2])
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = __version__
|
release = __version__
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
#language = None
|
# language = None
|
||||||
|
|
||||||
# There are two options for replacing |today|: either, you set today to some
|
# There are two options for replacing |today|: either, you set today to some
|
||||||
# non-false value, then it is used:
|
# non-false value, then it is used:
|
||||||
#today = ''
|
# today = ''
|
||||||
# Else, today_fmt is used as the format for a strftime call.
|
# Else, today_fmt is used as the format for a strftime call.
|
||||||
#today_fmt = '%B %d, %Y'
|
# today_fmt = '%B %d, %Y'
|
||||||
|
|
||||||
# List of patterns, relative to source directory, that match files and
|
# List of patterns, relative to source directory, that match files and
|
||||||
# directories to ignore when looking for source files.
|
# directories to ignore when looking for source files.
|
||||||
exclude_patterns = [
|
exclude_patterns = [
|
||||||
'_build',
|
"_build",
|
||||||
'modules.rst',
|
"modules.rst",
|
||||||
]
|
]
|
||||||
|
|
||||||
# The reST default role (used for this markup: `text`) to use for all
|
# The reST default role (used for this markup: `text`) to use for all
|
||||||
# documents.
|
# documents.
|
||||||
#default_role = None
|
# default_role = None
|
||||||
|
|
||||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||||
#add_function_parentheses = True
|
# add_function_parentheses = True
|
||||||
|
|
||||||
# If true, the current module name will be prepended to all description
|
# If true, the current module name will be prepended to all description
|
||||||
# unit titles (such as .. function::).
|
# unit titles (such as .. function::).
|
||||||
#add_module_names = True
|
# add_module_names = True
|
||||||
|
|
||||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||||
# output. They are ignored by default.
|
# output. They are ignored by default.
|
||||||
#show_authors = False
|
# show_authors = False
|
||||||
|
|
||||||
# The name of the Pygments (syntax highlighting) style to use.
|
# The name of the Pygments (syntax highlighting) style to use.
|
||||||
pygments_style = 'sphinx'
|
pygments_style = "sphinx"
|
||||||
|
|
||||||
# A list of ignored prefixes for module index sorting.
|
# A list of ignored prefixes for module index sorting.
|
||||||
#modindex_common_prefix = []
|
# modindex_common_prefix = []
|
||||||
|
|
||||||
# If true, keep warnings as "system message" paragraphs in the built documents.
|
# If true, keep warnings as "system message" paragraphs in the built documents.
|
||||||
#keep_warnings = False
|
# keep_warnings = False
|
||||||
|
|
||||||
|
|
||||||
# -- Options for HTML output ----------------------------------------------
|
# -- Options for HTML output ----------------------------------------------
|
||||||
|
|
||||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||||
# a list of builtin themes.
|
# a list of builtin themes.
|
||||||
html_theme = 'sphinx_rtd_theme'
|
html_theme = "sphinx_rtd_theme"
|
||||||
|
|
||||||
# Theme options are theme-specific and customize the look and feel of a theme
|
# Theme options are theme-specific and customize the look and feel of a theme
|
||||||
# further. For a list of options available for each theme, see the
|
# further. For a list of options available for each theme, see the
|
||||||
# documentation.
|
# documentation.
|
||||||
#html_theme_options = {}
|
# html_theme_options = {}
|
||||||
|
|
||||||
# Add any paths that contain custom themes here, relative to this directory.
|
# Add any paths that contain custom themes here, relative to this directory.
|
||||||
|
|
||||||
# The name for this set of Sphinx documents. If None, it defaults to
|
# The name for this set of Sphinx documents. If None, it defaults to
|
||||||
# "<project> v<release> documentation".
|
# "<project> v<release> documentation".
|
||||||
#html_title = None
|
# html_title = None
|
||||||
|
|
||||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||||
#html_short_title = None
|
# html_short_title = None
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top
|
# The name of an image file (relative to this directory) to place at the top
|
||||||
# of the sidebar.
|
# of the sidebar.
|
||||||
#html_logo = None
|
# html_logo = None
|
||||||
|
|
||||||
# The name of an image file (within the static path) to use as favicon of the
|
# The name of an image file (within the static path) to use as favicon of the
|
||||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||||
# pixels large.
|
# pixels large.
|
||||||
#html_favicon = None
|
# html_favicon = None
|
||||||
|
|
||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
# Add any paths that contain custom static files (such as style sheets) here,
|
||||||
# relative to this directory. They are copied after the builtin static files,
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||||
html_static_path = ['_static']
|
# html_static_path = ["_static"]
|
||||||
|
|
||||||
# Add any extra paths that contain custom files (such as robots.txt or
|
# Add any extra paths that contain custom files (such as robots.txt or
|
||||||
# .htaccess) here, relative to this directory. These files are copied
|
# .htaccess) here, relative to this directory. These files are copied
|
||||||
# directly to the root of the documentation.
|
# directly to the root of the documentation.
|
||||||
#html_extra_path = []
|
# html_extra_path = []
|
||||||
|
|
||||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||||
# using the given strftime format.
|
# using the given strftime format.
|
||||||
#html_last_updated_fmt = '%b %d, %Y'
|
# html_last_updated_fmt = '%b %d, %Y'
|
||||||
|
|
||||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||||
# typographically correct entities.
|
# typographically correct entities.
|
||||||
#html_use_smartypants = True
|
# html_use_smartypants = True
|
||||||
|
|
||||||
# Custom sidebar templates, maps document names to template names.
|
# Custom sidebar templates, maps document names to template names.
|
||||||
#html_sidebars = {}
|
# html_sidebars = {}
|
||||||
|
|
||||||
# Additional templates that should be rendered to pages, maps page names to
|
# Additional templates that should be rendered to pages, maps page names to
|
||||||
# template names.
|
# template names.
|
||||||
#html_additional_pages = {}
|
# html_additional_pages = {}
|
||||||
|
|
||||||
# If false, no module index is generated.
|
# If false, no module index is generated.
|
||||||
#html_domain_indices = True
|
# html_domain_indices = True
|
||||||
|
|
||||||
# If false, no index is generated.
|
# If false, no index is generated.
|
||||||
#html_use_index = True
|
# html_use_index = True
|
||||||
|
|
||||||
# If true, the index is split into individual pages for each letter.
|
# If true, the index is split into individual pages for each letter.
|
||||||
#html_split_index = False
|
# html_split_index = False
|
||||||
|
|
||||||
# If true, links to the reST sources are added to the pages.
|
# If true, links to the reST sources are added to the pages.
|
||||||
#html_show_sourcelink = True
|
# html_show_sourcelink = True
|
||||||
|
|
||||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||||
#html_show_sphinx = True
|
# html_show_sphinx = True
|
||||||
|
|
||||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||||
#html_show_copyright = True
|
# html_show_copyright = True
|
||||||
|
|
||||||
# If true, an OpenSearch description file will be output, and all pages will
|
# If true, an OpenSearch description file will be output, and all pages will
|
||||||
# contain a <link> tag referring to it. The value of this option must be the
|
# contain a <link> tag referring to it. The value of this option must be the
|
||||||
# base URL from which the finished HTML is served.
|
# base URL from which the finished HTML is served.
|
||||||
#html_use_opensearch = ''
|
# html_use_opensearch = ''
|
||||||
|
|
||||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||||
#html_file_suffix = None
|
# html_file_suffix = None
|
||||||
|
|
||||||
# Output file base name for HTML help builder.
|
# Output file base name for HTML help builder.
|
||||||
htmlhelp_basename = 'libp2pdoc'
|
htmlhelp_basename = "libp2pdocs"
|
||||||
|
|
||||||
|
|
||||||
# -- Options for LaTeX output ---------------------------------------------
|
# -- Options for LaTeX output ---------------------------------------------
|
||||||
|
|
||||||
latex_elements = {
|
latex_elements = {
|
||||||
# The paper size ('letterpaper' or 'a4paper').
|
# The paper size ('letterpaper' or 'a4paper').
|
||||||
#'papersize': 'letterpaper',
|
#'papersize': 'letterpaper',
|
||||||
|
# The font size ('10pt', '11pt' or '12pt').
|
||||||
# The font size ('10pt', '11pt' or '12pt').
|
#'pointsize': '10pt',
|
||||||
#'pointsize': '10pt',
|
# Additional stuff for the LaTeX preamble.
|
||||||
|
#'preamble': '',
|
||||||
# Additional stuff for the LaTeX preamble.
|
|
||||||
#'preamble': '',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Grouping the document tree into LaTeX files. List of tuples
|
# Grouping the document tree into LaTeX files. List of tuples
|
||||||
# (source start file, target name, title,
|
# (source start file, target name, title,
|
||||||
# author, documentclass [howto, manual, or own class]).
|
# author, documentclass [howto, manual, or own class]).
|
||||||
latex_documents = [
|
latex_documents = [
|
||||||
('index', 'libp2p.tex', 'py-libp2p Documentation',
|
(
|
||||||
'The Ethereum Foundation', 'manual'),
|
"index",
|
||||||
|
"libp2p.tex",
|
||||||
|
"py-libp2p Documentation",
|
||||||
|
"The Ethereum Foundation",
|
||||||
|
"manual",
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top of
|
# The name of an image file (relative to this directory) to place at the top of
|
||||||
# the title page.
|
# the title page.
|
||||||
#latex_logo = None
|
# latex_logo = None
|
||||||
|
|
||||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||||
# not chapters.
|
# not chapters.
|
||||||
#latex_use_parts = False
|
# latex_use_parts = False
|
||||||
|
|
||||||
# If true, show page references after internal links.
|
# If true, show page references after internal links.
|
||||||
#latex_show_pagerefs = False
|
# latex_show_pagerefs = False
|
||||||
|
|
||||||
# If true, show URL addresses after external links.
|
# If true, show URL addresses after external links.
|
||||||
#latex_show_urls = False
|
# latex_show_urls = False
|
||||||
|
|
||||||
# Documents to append as an appendix to all manuals.
|
# Documents to append as an appendix to all manuals.
|
||||||
#latex_appendices = []
|
# latex_appendices = []
|
||||||
|
|
||||||
# If false, no module index is generated.
|
# If false, no module index is generated.
|
||||||
#latex_domain_indices = True
|
# latex_domain_indices = True
|
||||||
|
|
||||||
|
|
||||||
# -- Options for manual page output ---------------------------------------
|
# -- Options for manual page output ---------------------------------------
|
||||||
@ -239,12 +243,17 @@ latex_documents = [
|
|||||||
# One entry per manual page. List of tuples
|
# One entry per manual page. List of tuples
|
||||||
# (source start file, name, description, authors, manual section).
|
# (source start file, name, description, authors, manual section).
|
||||||
man_pages = [
|
man_pages = [
|
||||||
('index', 'libp2p', 'py-libp2p Documentation',
|
(
|
||||||
['The Ethereum Foundation'], 1)
|
"index",
|
||||||
|
"libp2p",
|
||||||
|
"py-libp2p Documentation",
|
||||||
|
["The Ethereum Foundation"],
|
||||||
|
1,
|
||||||
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
# If true, show URL addresses after external links.
|
# If true, show URL addresses after external links.
|
||||||
#man_show_urls = False
|
# man_show_urls = False
|
||||||
|
|
||||||
|
|
||||||
# -- Options for Texinfo output -------------------------------------------
|
# -- Options for Texinfo output -------------------------------------------
|
||||||
@ -253,34 +262,41 @@ man_pages = [
|
|||||||
# (source start file, target name, title, author,
|
# (source start file, target name, title, author,
|
||||||
# dir menu entry, description, category)
|
# dir menu entry, description, category)
|
||||||
texinfo_documents = [
|
texinfo_documents = [
|
||||||
('index', 'py-libp2p', 'py-libp2p Documentation',
|
(
|
||||||
'The Ethereum Foundation', 'py-libp2p', 'The Python implementation of the libp2p networking stack',
|
"index",
|
||||||
'Miscellaneous'),
|
"py-libp2p",
|
||||||
|
"py-libp2p Documentation",
|
||||||
|
"The Ethereum Foundation",
|
||||||
|
"py-libp2p",
|
||||||
|
"The Python implementation of the libp2p networking stack",
|
||||||
|
"Miscellaneous",
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
# Documents to append as an appendix to all manuals.
|
# Documents to append as an appendix to all manuals.
|
||||||
#texinfo_appendices = []
|
# texinfo_appendices = []
|
||||||
|
|
||||||
# If false, no module index is generated.
|
# If false, no module index is generated.
|
||||||
#texinfo_domain_indices = True
|
# texinfo_domain_indices = True
|
||||||
|
|
||||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||||
#texinfo_show_urls = 'footnote'
|
# texinfo_show_urls = 'footnote'
|
||||||
|
|
||||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||||
#texinfo_no_detailmenu = False
|
# texinfo_no_detailmenu = False
|
||||||
|
|
||||||
# -- Intersphinx configuration ------------------------------------------------
|
# -- Intersphinx configuration ------------------------------------------------
|
||||||
|
|
||||||
intersphinx_mapping = {
|
intersphinx_mapping = {
|
||||||
'python': ('https://docs.python.org/3.6', None),
|
"python": ("https://docs.python.org/3.10", None),
|
||||||
}
|
}
|
||||||
|
|
||||||
# -- Doctest configuration ----------------------------------------
|
# -- Doctest configuration ----------------------------------------
|
||||||
|
|
||||||
import doctest
|
import doctest
|
||||||
|
|
||||||
doctest_default_flags = (0
|
doctest_default_flags = (
|
||||||
|
0
|
||||||
| doctest.DONT_ACCEPT_TRUE_FOR_1
|
| doctest.DONT_ACCEPT_TRUE_FOR_1
|
||||||
| doctest.ELLIPSIS
|
| doctest.ELLIPSIS
|
||||||
| doctest.IGNORE_EXCEPTION_DETAIL
|
| doctest.IGNORE_EXCEPTION_DETAIL
|
||||||
|
|||||||
18
mypy.ini
18
mypy.ini
@ -1,18 +0,0 @@
|
|||||||
[mypy]
|
|
||||||
|
|
||||||
check_untyped_defs = True
|
|
||||||
disallow_incomplete_defs = True
|
|
||||||
disallow_untyped_defs = True
|
|
||||||
disallow_any_generics = True
|
|
||||||
disallow_untyped_calls = True
|
|
||||||
disallow_untyped_decorators = True
|
|
||||||
disallow_subclassing_any = False
|
|
||||||
ignore_missing_imports = True
|
|
||||||
incremental = False
|
|
||||||
strict_optional = False
|
|
||||||
warn_unused_ignores = True
|
|
||||||
strict_equality = True
|
|
||||||
warn_redundant_casts = True
|
|
||||||
warn_return_any = False
|
|
||||||
warn_unused_configs = True
|
|
||||||
warn_unreachable = True
|
|
||||||
@ -6,15 +6,17 @@ commit message and PR description, which are a description of the change as
|
|||||||
relevant to people working on the code itself.)
|
relevant to people working on the code itself.)
|
||||||
|
|
||||||
Each file should be named like `<ISSUE>.<TYPE>.rst`, where
|
Each file should be named like `<ISSUE>.<TYPE>.rst`, where
|
||||||
`<ISSUE>` is an issue numbers, and `<TYPE>` is one of:
|
`<ISSUE>` is an issue number, and `<TYPE>` is one of:
|
||||||
|
|
||||||
* `feature`
|
- `breaking`
|
||||||
* `bugfix`
|
- `bugfix`
|
||||||
* `performance`
|
- `deprecation`
|
||||||
* `doc`
|
- `docs`
|
||||||
* `internal`
|
- `feature`
|
||||||
* `removal`
|
- `internal`
|
||||||
* `misc`
|
- `misc`
|
||||||
|
- `performance`
|
||||||
|
- `removal`
|
||||||
|
|
||||||
So for example: `123.feature.rst`, `456.bugfix.rst`
|
So for example: `123.feature.rst`, `456.bugfix.rst`
|
||||||
|
|
||||||
@ -23,5 +25,5 @@ then open up the PR first and use the PR number for the newsfragment.
|
|||||||
|
|
||||||
Note that the `towncrier` tool will automatically
|
Note that the `towncrier` tool will automatically
|
||||||
reflow your text, so don't try to do any fancy formatting. Run
|
reflow your text, so don't try to do any fancy formatting. Run
|
||||||
`towncrier --draft` to get a preview of what the release notes entry
|
`towncrier build --draft` to get a preview of what the release notes entry
|
||||||
will look like in the final release notes.
|
will look like in the final release notes.
|
||||||
|
|||||||
@ -3,23 +3,24 @@
|
|||||||
# Towncrier silently ignores files that do not match the expected ending.
|
# Towncrier silently ignores files that do not match the expected ending.
|
||||||
# We use this script to ensure we catch these as errors in CI.
|
# We use this script to ensure we catch these as errors in CI.
|
||||||
|
|
||||||
import os
|
|
||||||
import pathlib
|
import pathlib
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
ALLOWED_EXTENSIONS = {
|
ALLOWED_EXTENSIONS = {
|
||||||
'.bugfix.rst',
|
".breaking.rst",
|
||||||
'.doc.rst',
|
".bugfix.rst",
|
||||||
'.feature.rst',
|
".deprecation.rst",
|
||||||
'.internal.rst',
|
".docs.rst",
|
||||||
'.misc.rst',
|
".feature.rst",
|
||||||
'.performance.rst',
|
".internal.rst",
|
||||||
'.removal.rst',
|
".misc.rst",
|
||||||
|
".performance.rst",
|
||||||
|
".removal.rst",
|
||||||
}
|
}
|
||||||
|
|
||||||
ALLOWED_FILES = {
|
ALLOWED_FILES = {
|
||||||
'validate_files.py',
|
"validate_files.py",
|
||||||
'README.md',
|
"README.md",
|
||||||
}
|
}
|
||||||
|
|
||||||
THIS_DIR = pathlib.Path(__file__).parent
|
THIS_DIR = pathlib.Path(__file__).parent
|
||||||
@ -27,17 +28,18 @@ THIS_DIR = pathlib.Path(__file__).parent
|
|||||||
num_args = len(sys.argv) - 1
|
num_args = len(sys.argv) - 1
|
||||||
assert num_args in {0, 1}
|
assert num_args in {0, 1}
|
||||||
if num_args == 1:
|
if num_args == 1:
|
||||||
assert sys.argv[1] in ('is-empty', )
|
assert sys.argv[1] in ("is-empty",)
|
||||||
|
|
||||||
for fragment_file in THIS_DIR.iterdir():
|
for fragment_file in THIS_DIR.iterdir():
|
||||||
|
|
||||||
if fragment_file.name in ALLOWED_FILES:
|
if fragment_file.name in ALLOWED_FILES:
|
||||||
continue
|
continue
|
||||||
elif num_args == 0:
|
elif num_args == 0:
|
||||||
full_extension = "".join(fragment_file.suffixes)
|
full_extension = "".join(fragment_file.suffixes)
|
||||||
if full_extension not in ALLOWED_EXTENSIONS:
|
if full_extension not in ALLOWED_EXTENSIONS:
|
||||||
raise Exception(f"Unexpected file: {fragment_file}")
|
raise Exception(f"Unexpected file: {fragment_file}")
|
||||||
elif sys.argv[1] == 'is-empty':
|
elif sys.argv[1] == "is-empty":
|
||||||
raise Exception(f"Unexpected file: {fragment_file}")
|
raise Exception(f"Unexpected file: {fragment_file}")
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("Strange: arguments {sys.argv} were validated, but not found")
|
raise RuntimeError(
|
||||||
|
f"Strange: arguments {sys.argv} were validated, but not found"
|
||||||
|
)
|
||||||
|
|||||||
121
pyproject.toml
121
pyproject.toml
@ -1,15 +1,86 @@
|
|||||||
|
[tool.autoflake]
|
||||||
|
remove_all_unused_imports = true
|
||||||
|
exclude = "__init__.py"
|
||||||
|
|
||||||
|
[tool.isort]
|
||||||
|
combine_as_imports = false
|
||||||
|
extra_standard_library = "pytest"
|
||||||
|
force_grid_wrap = 1
|
||||||
|
force_sort_within_sections = true
|
||||||
|
known_third_party = "anyio,factory,lru,p2pclient,pytest,noise"
|
||||||
|
known_first_party = "libp2p"
|
||||||
|
multi_line_output = 3
|
||||||
|
profile = "black"
|
||||||
|
skip_glob= "*_pb2*.py, *.pyi"
|
||||||
|
|
||||||
|
[tool.mypy]
|
||||||
|
check_untyped_defs = true
|
||||||
|
disallow_incomplete_defs = true
|
||||||
|
disallow_untyped_defs = true
|
||||||
|
disallow_any_generics = true
|
||||||
|
disallow_untyped_calls = true
|
||||||
|
disallow_untyped_decorators = true
|
||||||
|
disallow_subclassing_any = false
|
||||||
|
ignore_missing_imports = true
|
||||||
|
incremental = false
|
||||||
|
strict_optional = false
|
||||||
|
strict_equality = true
|
||||||
|
warn_redundant_casts = true
|
||||||
|
warn_return_any = false
|
||||||
|
warn_unused_configs = true
|
||||||
|
warn_unused_ignores = true
|
||||||
|
|
||||||
|
|
||||||
|
[tool.pydocstyle]
|
||||||
|
# All error codes found here:
|
||||||
|
# http://www.pydocstyle.org/en/3.0.0/error_codes.html
|
||||||
|
#
|
||||||
|
# Ignored:
|
||||||
|
# D1 - Missing docstring error codes
|
||||||
|
#
|
||||||
|
# Selected:
|
||||||
|
# D2 - Whitespace error codes
|
||||||
|
# D3 - Quote error codes
|
||||||
|
# D4 - Content related error codes
|
||||||
|
select = "D2,D3,D4"
|
||||||
|
|
||||||
|
# Extra ignores:
|
||||||
|
# D200 - One-line docstring should fit on one line with quotes
|
||||||
|
# D203 - 1 blank line required before class docstring
|
||||||
|
# D204 - 1 blank line required after class docstring
|
||||||
|
# D205 - 1 blank line required between summary line and description
|
||||||
|
# D212 - Multi-line docstring summary should start at the first line
|
||||||
|
# D302 - Use u""" for Unicode docstrings
|
||||||
|
# D400 - First line should end with a period
|
||||||
|
# D401 - First line should be in imperative mood
|
||||||
|
# D412 - No blank lines allowed between a section header and its content
|
||||||
|
# D415 - First line should end with a period, question mark, or exclamation point
|
||||||
|
add-ignore = "D200,D203,D204,D205,D212,D302,D400,D401,D412,D415"
|
||||||
|
|
||||||
|
# Explanation:
|
||||||
|
# D400 - Enabling this error code seems to make it a requirement that the first
|
||||||
|
# sentence in a docstring is not split across two lines. It also makes it a
|
||||||
|
# requirement that no docstring can have a multi-sentence description without a
|
||||||
|
# summary line. Neither one of those requirements seem appropriate.
|
||||||
|
|
||||||
|
[tool.pytest.ini_options]
|
||||||
|
addopts = "-v --showlocals --durations 50 --maxfail 10"
|
||||||
|
xfail_strict = true
|
||||||
|
log_format = "%(levelname)8s %(asctime)s %(filename)20s %(message)s"
|
||||||
|
log_date_format = "%m-%d %H:%M:%S"
|
||||||
|
|
||||||
[tool.towncrier]
|
[tool.towncrier]
|
||||||
# Read https://github.com/libp2p/py-libp2p/newsfragments/README.md for instructions
|
# Read https://github.com/ethereum/py-libp2p/blob/main/newsfragments/README.md for instructions
|
||||||
package = "libp2p"
|
package = "libp2p"
|
||||||
filename = "docs/release_notes.rst"
|
filename = "docs/release_notes.rst"
|
||||||
directory = "newsfragments"
|
directory = "newsfragments"
|
||||||
underlines = ["-", "~", "^"]
|
underlines = ["-", "~", "^"]
|
||||||
title_format = "libp2p v{version} ({project_date})"
|
title_format = "py-libp2p v{version} ({project_date})"
|
||||||
issue_format = "`#{issue} <https://github.com/libp2p/py-libp2p/issues/{issue}>`__"
|
issue_format = "`#{issue} <https://github.com/ethereum/py-libp2p/issues/{issue}>`__"
|
||||||
|
|
||||||
[[tool.towncrier.type]]
|
[[tool.towncrier.type]]
|
||||||
directory = "feature"
|
directory = "breaking"
|
||||||
name = "Features"
|
name = "Breaking Changes"
|
||||||
showcontent = true
|
showcontent = true
|
||||||
|
|
||||||
[[tool.towncrier.type]]
|
[[tool.towncrier.type]]
|
||||||
@ -18,18 +89,18 @@ name = "Bugfixes"
|
|||||||
showcontent = true
|
showcontent = true
|
||||||
|
|
||||||
[[tool.towncrier.type]]
|
[[tool.towncrier.type]]
|
||||||
directory = "performance"
|
directory = "deprecation"
|
||||||
name = "Performance improvements"
|
name = "Deprecations"
|
||||||
showcontent = true
|
showcontent = true
|
||||||
|
|
||||||
[[tool.towncrier.type]]
|
[[tool.towncrier.type]]
|
||||||
directory = "doc"
|
directory = "docs"
|
||||||
name = "Improved Documentation"
|
name = "Improved Documentation"
|
||||||
showcontent = true
|
showcontent = true
|
||||||
|
|
||||||
[[tool.towncrier.type]]
|
[[tool.towncrier.type]]
|
||||||
directory = "removal"
|
directory = "feature"
|
||||||
name = "Deprecations and Removals"
|
name = "Features"
|
||||||
showcontent = true
|
showcontent = true
|
||||||
|
|
||||||
[[tool.towncrier.type]]
|
[[tool.towncrier.type]]
|
||||||
@ -39,27 +110,15 @@ showcontent = true
|
|||||||
|
|
||||||
[[tool.towncrier.type]]
|
[[tool.towncrier.type]]
|
||||||
directory = "misc"
|
directory = "misc"
|
||||||
name = "Miscellaneous changes"
|
name = "Miscellaneous Changes"
|
||||||
showcontent = false
|
showcontent = false
|
||||||
|
|
||||||
[tool.black]
|
[[tool.towncrier.type]]
|
||||||
target_version = ['py37']
|
directory = "performance"
|
||||||
include = '\.pyi?$'
|
name = "Performance Improvements"
|
||||||
exclude = '''
|
showcontent = true
|
||||||
|
|
||||||
(
|
[[tool.towncrier.type]]
|
||||||
/(
|
directory = "removal"
|
||||||
\.eggs # exclude a few common directories in the
|
name = "Removals"
|
||||||
| \.git # root of the project
|
showcontent = true
|
||||||
| \.hg
|
|
||||||
| \.mypy_cache
|
|
||||||
| \.tox
|
|
||||||
| \.venv
|
|
||||||
| _build
|
|
||||||
| buck-out
|
|
||||||
| build
|
|
||||||
| dist
|
|
||||||
)/
|
|
||||||
| \w*_pb2\w*\.py # pb2 files
|
|
||||||
)
|
|
||||||
'''
|
|
||||||
|
|||||||
@ -1,9 +0,0 @@
|
|||||||
[pytest]
|
|
||||||
addopts= -v --showlocals --durations 50 --maxfail 10
|
|
||||||
python_paths= .
|
|
||||||
xfail_strict=true
|
|
||||||
log_format = %(levelname)8s %(asctime)s %(filename)20s %(message)s
|
|
||||||
log_date_format = %m-%d %H:%M:%S
|
|
||||||
|
|
||||||
[pytest-watch]
|
|
||||||
runner= pytest --failed-first --maxfail=1 --no-success-flaky-report
|
|
||||||
@ -1 +0,0 @@
|
|||||||
.[doc]
|
|
||||||
69
setup.py
69
setup.py
@ -2,46 +2,36 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from setuptools import find_packages, setup
|
from setuptools import (
|
||||||
|
find_packages,
|
||||||
|
setup,
|
||||||
|
)
|
||||||
|
|
||||||
extras_require = {
|
extras_require = {
|
||||||
|
"dev": [
|
||||||
|
"build>=0.9.0",
|
||||||
|
"bumpversion>=0.5.3",
|
||||||
|
"ipython",
|
||||||
|
"pre-commit>=3.4.0",
|
||||||
|
"tox>=4.0.0",
|
||||||
|
"twine",
|
||||||
|
"wheel",
|
||||||
|
],
|
||||||
|
"docs": [
|
||||||
|
"sphinx>=6.0.0",
|
||||||
|
"sphinx_rtd_theme>=1.0.0",
|
||||||
|
"towncrier>=21,<22",
|
||||||
|
],
|
||||||
"test": [
|
"test": [
|
||||||
"pytest>=4.6.3,<5.0.0",
|
"pytest>=7.0.0",
|
||||||
"pytest-xdist>=1.30.0",
|
"pytest-xdist>=2.4.0",
|
||||||
"pytest-trio>=0.5.2",
|
"pytest-trio>=0.5.2",
|
||||||
"factory-boy>=2.12.0,<3.0.0",
|
"factory-boy>=2.12.0,<3.0.0",
|
||||||
],
|
],
|
||||||
"lint": [
|
|
||||||
"flake8==3.7.9", # flake8 is not semver: it has added new warnings at minor releases
|
|
||||||
"isort==4.3.21",
|
|
||||||
"mypy==0.780", # mypy is not semver: it has added new warnings at minor releases
|
|
||||||
"mypy-protobuf==1.15",
|
|
||||||
"black==19.3b0",
|
|
||||||
"flake8-bugbear>=19.8.0,<20",
|
|
||||||
"docformatter>=1.3.1,<2",
|
|
||||||
"trio-typing~=0.5.0",
|
|
||||||
],
|
|
||||||
"doc": [
|
|
||||||
"Sphinx>=2.2.1,<3",
|
|
||||||
"sphinx_rtd_theme>=0.4.3,<=1",
|
|
||||||
"towncrier>=19.2.0, <20",
|
|
||||||
],
|
|
||||||
"dev": [
|
|
||||||
"bumpversion>=0.5.3,<1",
|
|
||||||
"pytest-watch>=4.1.0,<5",
|
|
||||||
"wheel",
|
|
||||||
"twine",
|
|
||||||
"ipython",
|
|
||||||
"setuptools>=36.2.0",
|
|
||||||
"tox>=3.13.2,<4.0.0",
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extras_require["dev"] = (
|
extras_require["dev"] = (
|
||||||
extras_require["dev"]
|
extras_require["dev"] + extras_require["docs"] + extras_require["test"]
|
||||||
+ extras_require["test"]
|
|
||||||
+ extras_require["lint"]
|
|
||||||
+ extras_require["doc"]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
fastecdsa = [
|
fastecdsa = [
|
||||||
@ -58,7 +48,6 @@ fastecdsa = [
|
|||||||
"fastecdsa==1.7.5;sys_platform!='win32'",
|
"fastecdsa==1.7.5;sys_platform!='win32'",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
with open("./README.md") as readme:
|
with open("./README.md") as readme:
|
||||||
long_description = readme.read()
|
long_description = readme.read()
|
||||||
|
|
||||||
@ -93,21 +82,22 @@ setup(
|
|||||||
name="libp2p",
|
name="libp2p",
|
||||||
# *IMPORTANT*: Don't manually change the version here. Use `make bump`, as described in readme
|
# *IMPORTANT*: Don't manually change the version here. Use `make bump`, as described in readme
|
||||||
version="0.1.5",
|
version="0.1.5",
|
||||||
description="libp2p implementation written in python",
|
description="""libp2p: The Python implementation of the libp2p networking stack""",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
maintainer="The Ethereum Foundation",
|
author="The Ethereum Foundation",
|
||||||
maintainer_email="snakecharmers@ethereum.org",
|
author_email="snakecharmers@ethereum.org",
|
||||||
url="https://github.com/libp2p/py-libp2p",
|
url="https://github.com/libp2p/py-libp2p",
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
install_requires=install_requires,
|
install_requires=install_requires,
|
||||||
python_requires=">=3.6,<4",
|
python_requires=">=3.8, <4",
|
||||||
extras_require=extras_require,
|
extras_require=extras_require,
|
||||||
py_modules=["libp2p"],
|
py_modules=["libp2p"],
|
||||||
license="MIT/APACHE2.0",
|
license="MIT/APACHE2.0",
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
keywords="libp2p p2p",
|
keywords="libp2p p2p",
|
||||||
packages=find_packages(exclude=["tests", "tests.*"]),
|
packages=find_packages(exclude=["tests", "tests.*"]),
|
||||||
|
package_data={"libp2p": ["py.typed"]},
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"Development Status :: 4 - Beta",
|
"Development Status :: 4 - Beta",
|
||||||
"Intended Audience :: Developers",
|
"Intended Audience :: Developers",
|
||||||
@ -115,8 +105,11 @@ setup(
|
|||||||
"License :: OSI Approved :: Apache Software License",
|
"License :: OSI Approved :: Apache Software License",
|
||||||
"Natural Language :: English",
|
"Natural Language :: English",
|
||||||
"Programming Language :: Python :: 3",
|
"Programming Language :: Python :: 3",
|
||||||
"Programming Language :: Python :: 3.6",
|
"Programming Language :: Python :: 3.8",
|
||||||
"Programming Language :: Python :: 3.7",
|
"Programming Language :: Python :: 3.9",
|
||||||
|
"Programming Language :: Python :: 3.10",
|
||||||
|
"Programming Language :: Python :: 3.11",
|
||||||
|
"Programming Language :: Python :: 3.12",
|
||||||
],
|
],
|
||||||
platforms=["unix", "linux", "osx"],
|
platforms=["unix", "linux", "osx"],
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,2 +0,0 @@
|
|||||||
def test_import():
|
|
||||||
import libp2p # noqa: F401
|
|
||||||
4
tests/core/test_import_and_version.py
Normal file
4
tests/core/test_import_and_version.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
def test_import_and_version():
|
||||||
|
import libp2p
|
||||||
|
|
||||||
|
assert isinstance(libp2p.__version__, str)
|
||||||
111
tox.ini
111
tox.ini
@ -1,66 +1,67 @@
|
|||||||
# Reference: https://github.com/ethereum/ethereum-python-project-template/blob/master/tox.ini
|
|
||||||
|
|
||||||
# TODO: consider pypy3 support
|
|
||||||
[tox]
|
[tox]
|
||||||
envlist =
|
envlist=
|
||||||
py{36,37}-test
|
py{38,39,310,311,312}-core
|
||||||
py37-interop
|
py{38,39,310,311,312}-lint
|
||||||
lint
|
py{38,39,310,311,312}-wheel
|
||||||
|
windows-wheel
|
||||||
docs
|
docs
|
||||||
|
|
||||||
[isort]
|
|
||||||
combine_as_imports=False
|
|
||||||
force_sort_within_sections=True
|
|
||||||
include_trailing_comma=True
|
|
||||||
known_third_party=anyio,factory,lru,p2pclient,pytest,noise
|
|
||||||
known_first_party=libp2p
|
|
||||||
line_length=88
|
|
||||||
multi_line_output=3
|
|
||||||
use_parentheses=True
|
|
||||||
force_grid_wrap=0
|
|
||||||
skip_glob=
|
|
||||||
*_pb2*.py
|
|
||||||
*.pyi
|
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
max-line-length = 100
|
exclude=venv*,.tox,docs,build,*_pb2*.py
|
||||||
exclude = venv*,.tox,docs,build,*_pb2*.py
|
extend-ignore=E203
|
||||||
ignore = E203, W503
|
max-line-length=88
|
||||||
max-complexity = 18
|
per-file-ignores=__init__.py:F401
|
||||||
select = B,C,E,F,W,T4,B9
|
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
usedevelop=True
|
usedevelop=True
|
||||||
commands =
|
commands=
|
||||||
test: pytest {posargs:tests/}
|
core: pytest {posargs:tests/}
|
||||||
docs: make build-docs
|
docs: make check-docs-ci
|
||||||
basepython =
|
basepython=
|
||||||
docs: python
|
docs: python
|
||||||
py37: python3.7
|
windows-wheel: python
|
||||||
py36: python3.6
|
py38: python3.8
|
||||||
extras =
|
py39: python3.9
|
||||||
|
py310: python3.10
|
||||||
|
py311: python3.11
|
||||||
|
py312: python3.12
|
||||||
|
extras=
|
||||||
test
|
test
|
||||||
docs: doc
|
docs
|
||||||
whitelist_externals = make
|
allowlist_externals=make,pre-commit
|
||||||
deps =
|
|
||||||
passenv = CI TRAVIS TRAVIS_*
|
|
||||||
|
|
||||||
[testenv:lint]
|
[testenv:py{38,39,310,311,312}-lint]
|
||||||
basepython = python3
|
deps=pre-commit
|
||||||
extras = lint
|
commands=
|
||||||
commands =
|
pre-commit install
|
||||||
mypy -p {toxinidir}/libp2p -p examples --config-file {toxinidir}/mypy.ini
|
pre-commit run --all-files --show-diff-on-failure
|
||||||
flake8 {toxinidir}/libp2p {toxinidir}/tests tests_interop examples setup.py
|
|
||||||
black --check libp2p tests tests_interop examples setup.py
|
|
||||||
isort --recursive --check-only --diff {toxinidir}/libp2p {toxinidir}/tests tests_interop examples setup.py
|
|
||||||
docformatter --pre-summary-newline --check --recursive libp2p tests tests_interop examples setup.py
|
|
||||||
|
|
||||||
[testenv:py37-interop]
|
[testenv:py{38,39,310,311,312}-wheel]
|
||||||
deps =
|
deps=
|
||||||
p2pclient
|
wheel
|
||||||
passenv = CI TRAVIS TRAVIS_* GOPATH
|
build[virtualenv]
|
||||||
extras = test
|
allowlist_externals=
|
||||||
commands =
|
/bin/rm
|
||||||
pytest tests_interop/
|
/bin/bash
|
||||||
basepython =
|
commands=
|
||||||
py37: python3.7
|
python -m pip install --upgrade pip
|
||||||
|
/bin/rm -rf build dist
|
||||||
|
python -m build
|
||||||
|
/bin/bash -c 'python -m pip install --upgrade "$(ls dist/libp2p-*-py3-none-any.whl)" --progress-bar off'
|
||||||
|
python -c "import libp2p"
|
||||||
|
skip_install=true
|
||||||
|
|
||||||
|
[testenv:windows-wheel]
|
||||||
|
deps=
|
||||||
|
wheel
|
||||||
|
build[virtualenv]
|
||||||
|
allowlist_externals=
|
||||||
|
bash.exe
|
||||||
|
commands=
|
||||||
|
python --version
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
bash.exe -c "rm -rf build dist"
|
||||||
|
python -m build
|
||||||
|
bash.exe -c 'python -m pip install --upgrade "$(ls dist/libp2p-*-py3-none-any.whl)" --progress-bar off'
|
||||||
|
python -c "import libp2p"
|
||||||
|
skip_install=true
|
||||||
|
|||||||
Reference in New Issue
Block a user