diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 0ad87c3..e1eda02 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -7,17 +7,18 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.10", "3.11", "3.12"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install pylint + python -m pip install --upgrade pip poetry + poetry config virtualenvs.create false + poetry install - name: Analysing the code with pylint run: | pylint $(git ls-files '*.py') \ No newline at end of file diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index ada2b5c..9a54a21 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -5,29 +5,25 @@ on: [push, workflow_dispatch] jobs: build: runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + - uses: actions/checkout@v4 + - name: Set up Python 3.12 + uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} + python-version: '3.12' - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install pytest coverage - pip install . + python -m pip install --upgrade pip poetry + poetry config virtualenvs.create false + poetry install - name: Test run: | - coverage run -m pytest tests/ + coverage run -m pytest tests - name: Generate Report run: | coverage html - name: Upload report - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: coverage-report - path: | - htmlcov/* \ No newline at end of file + path: htmlcov/* \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3349c8a..ddbbe7c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,14 @@ name: Semantic Release on: - push: + workflow_run: + workflows: + - Pylint + - PyTest branches: - main + types: + - completed jobs: release: @@ -21,4 +26,5 @@ jobs: - name: Python Semantic Release uses: python-semantic-release/python-semantic-release@master with: + # This might need to be changed to the E4E Releaser PAT github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json index ee6ba6c..bddf977 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -5,5 +5,6 @@ "ms-toolsai.jupyter", "njpwerner.autodocstring", "ms-python.isort", + "ms-python.autopep8" ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 45321e7..d362e12 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,8 +3,12 @@ "tests" ], "python.testing.unittestEnabled": false, - "python.linting.pylintEnabled": true, "editor.rulers": [ 100 - ] + ], + "python.testing.pytestEnabled": true, + "editor.formatOnPaste": true, + "editor.formatOnSave": true, + "editor.formatOnSaveMode": "modifications", + "editor.formatOnType": true } \ No newline at end of file diff --git a/README.md b/README.md index 80c200e..df83674 100644 --- a/README.md +++ b/README.md @@ -4,28 +4,25 @@ Example Python Package Repository. This repository serves as an example of how ## .vscode This folder should contain at least a `launch.json` file that provides entry points into the package. This could be entry points to example programs, typical debug entry points, etc. Ideally, this will also contain a `settings.json` with folder specific VS Code settings. +All standard invocations that developers should be using MUST be saved into a `launch.json` entry. + ## Python Packages Almost all code should be organized into packages. This facilitates easy code reuse. See https://packaging.python.org/en/latest/ for more information on how to use packages in Python. ## tests -Tests should ideally be kept in an isolated folder. This example uses `pytest`, see https://docs.pytest.org/en/7.0.x/ for information on how to use `pytest`. +Tests should ideally be kept in an isolated folder. This example uses `pytest`, see https://docs.pytest.org/en/8.3.x/ for information on how to use `pytest`. ## .gitignore -This is an important file to put into your `git` repositories. This helps prevent `git` from including unnecessary files into the version control system, such as generated files, environment files, or log files. +This is an important file to put into your `git` repositories. This helps prevent `git` from including unnecessary files into the version control system, such as generated files, environment files, or log files. Please upgrade this using https://gitignore.io ## Jupyter Notebooks Jupyter Notebooks are a great way to add interactive reports or documentation. There is an example here. -## *.code-workspace -This is created by going to `File`->`Save Workspace As` in VS Code. This allows us to easily open the same development environment across computers and operating systems. Use this as the root of your development environment. - -You'll also notice here that there are some recommended extensions. This allows everyone on your team to have a consistent toolchain for how to interact with your code. See https://code.visualstudio.com/docs/editor/extension-marketplace#_workspace-recommended-extensions for instructions for how to configure these. - ## README.md This is a critical file to include. This should be an introduction to your repository. It should be a birds-eye view of what your repo is and how to use it, with links to the appropriate lower-level documentation. -## setup.py -This is the original way to package Python projects, which we probably still prefer. However, in general, if you can, you should probably start using the newer packaging tools (`pyproject.toml`) +## pyproject.toml +This is the standard way to package Python projects. This is now structured using Poetry, see https://python-poetry.org/ for tool documentation. See https://packaging.python.org/en/latest/tutorials/packaging-projects/ and https://docs.python.org/3/distutils/setupscript.html for more information about each tool. @@ -41,5 +38,20 @@ python -m venv .venv source .venv/bin/activate # for bash # Install in developer mode -python -m pip install -e .[dev] +poetry install ``` + +## Installing for end users +End users should do the following: +``` +# Create a virtual environment +python -m venv .venv + +# Activate the virtual environment +.venv/Scripts/activate.ps1 # for Windows PowerShell +.venv/Scripts/activate.bat # for Windows Command Prompt +source .venv/bin/activate # for bash + +# Install +pip install . +``` \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index f9464d2..152e4a8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,26 +1,36 @@ [build-system] -requires = ['setuptools'] -build-backend = 'setuptools.build_meta' +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" -[project] -name = 'example_package' +[tool.poetry] +name = "example_package" +version = "0.1.0" +description = "" authors = [ - {name = 'UCSD Engineers for Exploration', email = 'e4e@ucsd.edu'}, + "UCSD Engineers for Exploration " ] -description = '' -readme = 'REAME.md' -requires-python = '>=3.8' -keywords = [] -license = {file = 'LICENSE'} -dependencies = [ -] -dynamic = ['version'] +license = "UCSD" +readme = "README.md" +repository = 'https://github.com/UCSD-E4E/python-repo-example' + +[tool.poetry.dependencies] +python = "^3.12" -[project.scripts] +[tool.poetry.group.dev.dependencies] +pylint = "^3.2.7" +pytest = "^8.3.2" +jupyter = "^1.1.1" +autopep8 = "^2.3.1" +coverage = "^7.6.1" + +[tool.poetry.scripts] ExamplePythonConsoleScript = 'example_package.example_module:exampleEntryPoint' [tool.semantic_release] version_variables = ["example_package/__init__.py:__version__"] +version_toml = [ + "pyproject.toml:tool.poetry.version", +] assets = [] commit_message = "{version}\n\nAutomatically generated by python-semantic-release" commit_parser = "angular"