Skip to content

Commit

Permalink
Merge pull request #7 from markvilar/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
markvilar authored May 15, 2024
2 parents 43d1b10 + c966e20 commit c917602
Show file tree
Hide file tree
Showing 17 changed files with 419 additions and 746 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
- name: Install tools
run: |
python -m pip install --upgrade pip
pip install --user pipenv wheel
pipenv install --deploy --dev
pip install --user poetry
- name: Install packages
run: |
poetry install
- name: Build
run: |
pipenv run build
poetry build
- name: Test and run
run: |
pipenv run tests
pipenv run main
poetry run pytest
poetry run main_script
13 changes: 8 additions & 5 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
- name: Install tools
run: |
python -m pip install --upgrade pip
pip install pylint
- name: Analysing the code with pylint
pip install --user poetry
- name: Install packages
run: |
pylint $(git ls-files '*.py')
poetry install
- name: Lint source code
run: |
poetry run black .
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,7 @@ dmypy.json
*.swa
*.swo
*.swp

# env files
*.env
.env*
25 changes: 0 additions & 25 deletions Pipfile

This file was deleted.

560 changes: 0 additions & 560 deletions Pipfile.lock

This file was deleted.

91 changes: 45 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,74 @@
# Python Project Template
# Python Template Project

![ci](https://github.com/markvilar/python_project_template/actions/workflows/ci.yml/badge.svg)
![pylint](https://github.com/markvilar/python_project_template/actions/workflows/pylint.yml/badge.svg)

Repository template for Python projects. The repository includes support for
the following tools:
* pipenv - management of virtual environments and dependencies
* setuptools - management of package setup
* pytest - unit tests
* twine - remote repository interaction
This is a small template repository for creating python projects with a modern toolchain.
The repository includes support for the following tools:
- poetry - package management and build system
- pytest - unit tests
- black - code linting

## Setting up a virtual environment

### Install pipenv
## Getting started

```sh
# Install pipenv
pip3 install --user pipenv
### Install poetry

```shell
# Install poetry
pip3 install --user poetry
```

### Install dependencies and activate shell
### Configure the project environment

```sh
# Install dependencies and setup environment
pipenv install --dev
```shell
# Set the Python version
poetry env use <python_version>

# Activate an interactive shell for the virtual environment
pipenv shell
# Validate the environment configuration
poetry env info
```

## Executing pipenv scripts
### Install dependencies and build the project

```shell
# Install dependencies
poetry install

# Build the project
poetry build

```sh
pipenv run tests
pipenv run main
pipenv run build
# Add new packages
poetry add <package-name>
```

## Building binaries and sources
### Running unit tests

```sh
python setup.py bdist_wheel sdist
```shell
poetry run pytest
```

## Running tests

```sh
# Run specific tests
python -m unittest tests/test_common.py
python -m unittest tests/test_math.py
## Other uses

# Run specific tests in verbose mode
python -m unittest -v tests/test_common.py
python -m unittest -v tests/test_math.py
### Managing the project environment

```shell
poetry env info
```

## Publishing the project
```sh
twine upload --repository python_template_project dist/*
```shell
poetry env remove
```

## Troubleshooting
### Activate the project environment in a shell

### Reinstalling the virtual environment
```shell
poetry shell
```

Reinstallation of the pipenv virtual environment can be necessary to update the
python version of the environment. In order to do this, execute the following
commands:
### Removing dependencies

```sh
pipenv --rm
pipenv install --python <python_version>
pipenv install --dev
```shell
poetry remove <package>
```
12 changes: 0 additions & 12 deletions main.py

This file was deleted.

Loading

0 comments on commit c917602

Please sign in to comment.