Skip to content

Commit

Permalink
chore: setup project
Browse files Browse the repository at this point in the history
  • Loading branch information
RDWimmers committed Oct 27, 2023
1 parent 4027f9a commit 7e04eef
Show file tree
Hide file tree
Showing 7 changed files with 516 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
omit = */tests/*
source = src/pycptcore
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[flake8]
# just stop shouting as black decides line lengths.
max-line-length = 180
# E203, W504: due to black fmt
ignore = E203,W503
exclude = ["test*"]
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ venv/
ENV/
env.bak/
venv.bak/
.ENV

# Spyder project settings
.spyderproject
Expand Down Expand Up @@ -158,3 +159,6 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# VS-Code
.vscode
102 changes: 102 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,104 @@
# py-cptcore
Public python SDK for the CEMS CPTCore web-API

[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)


This repository is created by [CEMS BV](https://cemsbv.nl/) and is a public python wrapper around the CEMS [CPTCore web-API](https://nuclei.cemsbv.io/#/cptcore/api).

# Installation

To install a package in this repository run:

`$ pip install py-cptcore`


## ENV VARS

To use `py-cptcore` add the follow ENV vars to your environment. Or provide them when asked.

```
* NUCLEI_TOKEN
- Your NUCLEI user token
```

You can obtain your `NUCLEI_TOKEN` on [NUCLEI](https://nuclei.cemsbv.io/#/).
Go to `personal-access-tokens` and create a new user token.

# Contribution

## Environment

We recommend developing in Python3.9 with a clean virtual environment (using `virtualenv` or `conda`), installing the requirements from the requirements.txt file:

Example using `virtualenv` and `pip` to install the dependencies in a new environment .env on Linux:

```bash
python -m venv .env
source .env/bin/activate
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
pip install -e .
```

## Documentation

Build the docs:

```bash
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
pip install .

sphinx-build -b html docs public
```

## Format

We format our code with black and isort.

```bash
black --config "pyproject.toml" src/pycptcore tests
isort --settings-path "pyproject.toml" src/pycptcore tests
```

## Lint

To maintain code quality we use the GitHub super-linter.

To run the linters locally, run the `run_super_linters.sh` bash script from the root directory.

## UnitTest

Test the software with the use of coverage:

```bash
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
pip install .
coverage run -m pytest
```

## Requirements

Requirements are autogenerated by the `pip-compile` command with python 3.9

Install pip-tools with:

```bash
pip install pip-tools
```

Generate requirements.txt file with:

```bash
pip-compile --extra=test --extra=lint --extra=docs --output-file=requirements.txt pyproject.toml
```

Update the requirements within the defined ranges with:

```bash
pip-compile --upgrade --extra=test --extra=lint --extra=docs --output-file=requirements.txt pyproject.toml
```
87 changes: 87 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "py-cptcore"
version = "0.0.1"
description = "Public python SDK for the CEMS CPTCore web-API."
requires-python = ">=3.9"
dependencies = [
"requests>=2.25.1",
"pandas>=1.2,<3.0",
"matplotlib>3,<4",
]
license = { file = "LICENSE" }
readme = "README.md"
keywords = ["API", "CPTCore", "CEMS", "CRUX"]

[project.urls]
repository = "https://github.com/cemsbv/py-cptcore"

[project.optional-dependencies]
test = ["coveralls", "pytest"]
docs = [
"Sphinx==6.1.3",
"sphinx-autodoc-typehints==1.22",
"ipython==8.11.0",
"asteroid-sphinx-theme==0.0.3",
"sphinx_rtd_theme==1.2.0"
]
# lint dependencies from github super-linter v5
# See https://github.com/super-linter/super-linter/tree/main/dependencies/python
lint = [
"mypy==1.5.1",
"mypy-extensions==1.0.0",
"tomli==2.0.1",
"typing_extensions==4.7.1",
"black==23.3.0",
"click==8.1.3",
"packaging==23.2",
"pathspec==0.11.1",
"platformdirs==3.5.1",
"tomli==2.0.1,",
"isort==5.12.0",
"flake8==6.0.0",
"mccabe==0.7.0",
"pycodestyle==2.10.0",
"pyflakes==3.0.1",
'pandas-stubs>2,<3',
'types-tqdm>4,<5',
]

[tool.isort]
profile = "black"
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
line_length = 88

[tool.mypy]
files = ["pycptcore"]
mypy_path = 'src'
namespace_packages = true
show_error_codes = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_unused_configs = true
disallow_subclassing_any = true
no_implicit_optional = true
disallow_untyped_defs = true
disallow_any_generics = false
disallow_untyped_calls = true
warn_return_any = false
no_implicit_reexport = true
strict_equality = true
install_types = true

[[tool.mypy.overrides]]
module = ["matplotlib.*", "requests.*", "pytest.*"]
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = ["tests/*"]
disallow_untyped_defs = false
disallow_untyped_calls = false
Loading

0 comments on commit 7e04eef

Please sign in to comment.