Giter Site home page Giter Site logo

python-package-template's Introduction

Python Project Template

This project is a template for creating Python projects that follows the Python Standards declared in PEP 621. It uses a pyproject.yaml file to configure the project and Flit to simplify the build process and publish to PyPI. Flit simplifies the build and packaging process for Python projects by eliminating the need for separate setup.py and setup.cfg files. With Flit, you can manage all relevant configurations within the pyproject.toml file, streamlining development and promoting maintainability by centralizing project metadata, dependencies, and build specifications in one place.

Project Organization

  • .github/workflows: Contains GitHub Actions used for building, testing, and publishing.
  • .devcontainer/Dockerfile: Contains Dockerfile to build a development container for VSCode with all the necessary extensions for Python development installed.
  • .devcontainer/devcontainer.json: Contains the configuration for the development container for VSCode, including the Docker image to use, any additional VSCode extensions to install, and whether or not to mount the project directory into the container.
  • .vscode/settings.json: Contains VSCode settings specific to the project, such as the Python interpreter to use and the maximum line length for auto-formatting.
  • src: Place new source code here.
  • tests: Contains Python-based test cases to validate source code.
  • pyproject.toml: Contains metadata about the project and configurations for additional tools used to format, lint, type-check, and analyze Python code.

pyproject.toml

The pyproject.toml file is a centralized configuration file for modern Python projects. It streamlines the development process by managing project metadata, dependencies, and development tool configurations in a single, structured file. This approach ensures consistency and maintainability, simplifying project setup and enabling developers to focus on writing quality code. Key components include project metadata, required and optional dependencies, development tool configurations (e.g., linters, formatters, and test runners), and build system specifications.

In this particular pyproject.toml file, the [build-system] section specifies that the Flit package should be used to build the project. The [project] section provides metadata about the project, such as the name, description, authors, and classifiers. The [project.optional-dependencies] section lists optional dependencies, like pyspark, while the [project.urls] section supplies URLs for project documentation, source code, and issue tracking.

The file also contains various configuration sections for different tools, including bandit, black, coverage, flake8, pyright, pytest, tox, and pylint. These sections specify settings for each tool, such as the maximum line length for flake8 and the minimum code coverage percentage for coverage.

Tool Sections

black

Black is a Python code formatter that automatically reformats Python code to conform to the PEP 8 style guide. It is used to maintain a consistent code style throughout the project.

The pyproject.toml file specifies the maximum line length and whether or not to use a "fast" mode for formatting. Black also allows for a pyproject.toml configuration file to be included in the project directory to customize its behavior.

coverage

Coverage is a tool for measuring code coverage during testing. It generates a report of which lines of code were executed during testing and which were not.

The pyproject.toml file specifies that branch coverage should be measured and that the tests should fail if the coverage falls below 100%. Coverage can be integrated with a variety of test frameworks, including pytest.

pytest

Pytest is a versatile testing framework for Python projects that simplifies test case creation and execution. It supports both pytest-style and unittest-style tests, offering flexibility in testing approaches. Key features include fixture support for clean test environments, parameterized tests to reduce code duplication, and extensibility through plugins for customization. Adopt pytest to streamline testing and tailor the framework to your project's specific needs.

The pyproject.toml file plays an essential role in configuring pytest for your project. It includes various test markers, such as integration, notebooks, gpu, spark, slow, and unit, which are used during testing. It also specifies options for generating test coverage reports, setting the Python path, and outputting test results in the xunit2 format. You can easily modify the pyproject.toml file to customize pytest for your project's specific needs.

pylint

Pylint is a versatile Python linter and static analysis tool that identifies errors and style issues in your code. It generates an in-depth report, presenting errors, warnings, and conventions found in the codebase. Pylint configurations are centralized in the pyproject.toml file, covering extension management, warning suppression, output formatting, and code style settings such as maximum function arguments and class attributes. The unique scoring system provided by Pylint helps developers assess and maintain code quality, ensuring a focus on readability and maintainability throughout the project's development.

pyright

Pyright is a static type checker for Python that uses type annotations to analyze your code and catch type-related errors. It is capable of analyzing Python code that uses type annotations as well as code that uses docstrings to specify types.

The pyproject.toml file contains configurations for Pyright, such as the directories to include or exclude from analysis, the virtual environment to use, and various settings for reporting missing imports and type stubs. By using Pyright, you can catch errors related to type mismatches before they even occur, which can save you time and improve the quality of your code.

flake8

Flake8 is a code linter for Python that checks your code for style and syntax issues. It checks your code for PEP 8 style guide violations, syntax errors, and more.

The pyproject.toml file contains configurations for Flake8, such as the maximum line length, which errors to ignore, and which style guide to follow. By using Flake8, you can ensure that your code follows the recommended style guide and catch syntax errors before they cause problems.

tox

In our repository, we use Tox to automate testing and building our Python package across various environments and versions. Configured through the pyproject.toml file, Tox is set up with four testing environments: py, integration, spark, and all. Each environment targets specific test categories or runs all tests together, ensuring compatibility and functionality in different scenarios.

The [tool.tox] section in the pyproject.toml file contains the Tox configuration details, including the legacy_tox_ini attribute. Our setup outlines the dependencies needed for each environment, as well as the test runner (e.g., pytest) and any associated commands. This ensures consistent test execution across all environments.

Tox helps us efficiently automate testing and building processes, maintaining the reliability and functionality of our Python package across a wide range of environments. By identifying potential compatibility issues early in the development process, we improve the quality and usability of our package. Our Tox configuration streamlines the development workflow, promoting code quality and consistency throughout the project.

Development

Codespaces

In our project, we use GitHub Codespaces to simplify development and enhance collaboration. Codespaces provides a consistent, cloud-based workspace accessible from any device with a web browser, eliminating the need for local software installations. Our configuration automatically sets up required dependencies and development tools, while customizable workspaces and seamless GitHub integration streamline the development process and improve teamwork.

When you create a Codespace from a template repository, you initially work within the browser version of Visual Studio Code. Or, connect your local VS Code to a remote Codespace and enjoy seamless development without the hassle of local software installations. GitHub now supports this fantastic feature, making it a breeze to work on projects from any device.

To get started, simply set the desktop version of Visual Studio Code as your default editor in GitHub account settings. Then, connect to your remote Codespace from within VS Code, and watch as your development process is revolutionized! With Codespaces, you'll benefit from the consistency and flexibility of a cloud-based workspace while retaining the comfort of your local editor. Say hello to the future of development!

GitHub Codespaces also supports Settings Sync, a feature that synchronizes extensions, settings, and preferences across multiple devices and instances of Visual Studio Code. Whether Settings Sync is enabled by default in a Codespace depends on your pre-existing settings and whether you access the Codespace via the browser or the desktop application. With Settings Sync, you can ensure a consistent development experience across devices, making it even more convenient to work on your projects within GitHub Codespaces.

Devcontainer

Dev Containers in Visual Studio Code allows you to use a Docker container as a complete development environment, opening any folder or repository inside a container and taking advantage of all of VS Code's features. A devcontainer.json file in your project describes how VS Code should access or create a development container with a well-defined tool and runtime stack. You can use an image as a starting point for your devcontainer.json. An image is like a mini-disk drive with various tools and an operating system pre-installed. You can pull images from a container registry, which is a collection of repositories that store images.

Creating a dev container in VS Code involves creating a devcontainer.json file that specifies how VS Code should start the container and what actions to take after it connects. You can customize the dev container by using a Dockerfile to install new software or make other changes that persist across sessions. Additional dev container configuration is also possible, including installing additional tools, automatically installing extensions, forwarding or publishing additional ports, setting runtime arguments, reusing or extending your existing Docker Compose setup, and adding more advanced container configuration.

After any changes are made, you must build your dev container to ensure changes take effect. Once your dev container is functional, you can connect to and start developing within it. If the predefined container configuration does not meet your needs, you can also attach to an already running container instead. If you want to install additional software in your dev container, you can use the integrated terminal in VS Code and execute any command against the OS inside the container.

When editing the contents of the .devcontainer folder, you'll need to rebuild for changes to take effect. You can use the Dev Containers: Rebuild Container command for your container to update. However, if you rebuild the container, you will have to reinstall anything you've installed manually. To avoid this problem, you can use the postCreateCommand property in devcontainer.json. There is also a postStartCommand that executes every time the container starts.

You can also use a Dockerfile to automate dev container creation. In your Dockerfile, use FROM to designate the image, and the RUN instruction to install any software. You can use && to string together multiple commands. If you don't want to create a devcontainer.json by hand, you can select the Dev Containers: Add Dev Container Configuration Files... command from the Command Palette (F1) to add the needed files to your project as a starting point, which you can further customize for your needs.

Setup

This project includes three files in the .devcontainer and .vscode directories that enable you to use GitHub Codespaces or Docker and VSCode locally to set up an environment that includes all the necessary extensions and tools for Python development.

The Dockerfile specifies the base image and dependencies needed for the development container. The Dockerfile installs the necessary dependencies for the development container, including Python 3 and flit, a tool used to build and publish Python packages. It sets an environment variable to indicate that flit should be installed globally. It then copies the pyproject.toml file into the container and creates an empty README.md file. It creates a directory src/python_package and installs only the development dependencies using flit. Finally, it removes unnecessary files, including the pyproject.toml, README.md, and src directory.

The devcontainer.json file is a configuration file that defines the development container's settings, including the Docker image to use, any additional VSCode extensions to install, and whether or not to mount the project directory into the container. It uses the python-3-miniconda container as its base, which is provided by Microsoft, and also includes customizations for VSCode, such as recommended extensions for Python development and specific settings for those extensions. In addition to the above, the settings.json file also contains a handy command that can automatically install pre-commit hooks. These hooks can help ensure the quality of the code before it's committed to the repository, improving the overall codebase and making collaboration easier.

The settings.json file is where we can customize various project-specific settings within VSCode. These settings can include auto-formatting options, auto-trimming of trailing whitespace, Git auto-fetching, and much more. By modifying this file, you can tailor the VSCode environment to your specific preferences and workflow. It also contains specific settings for Python, such as the default interpreter to use, the formatting provider, and whether to enable unittest or pytest. Additionally, it includes arguments for various tools such as Pylint, Black, Flake8, and Isort, which are specified in the pyproject.toml file.

Getting Started

To get started with this template, simply 'Use This Template' to create a new repository and start building your project within the src directory. Try to open the project in GitHub Codespace, and to run the unit tests using the VS Code Test extension.

Contributing

This project welcomes contributions and suggestions. For details, visit the repository's Contributor License Agreement (CLA) and Code of Conduct pages.

python-package-template's People

Contributors

abe-101 avatar davet2001 avatar dciborow avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

python-package-template's Issues

Fresh clone won't successfully build dev container

This could be a problem with my setup, but I'm not sure what ths issue is.

Steps to reproduce:

  1. git clone https://github.com/microsoft/python-package-template.git
  2. Open new folder in vscode
  3. Click reopen in container

What I expected to happen:
Container builds

What actually happens:

[19 ms] Dev Containers 0.282.0 in VS Code 1.76.0 (92da9481c0904c6adfe372c12da3b7748d74bdcb).
[19 ms] Start: Resolving Remote
[27 ms] Setting up container for folder or workspace: /home/dave/dev/python-package-template
[45 ms] Start: Check Docker is running
[45 ms] Start: Run: docker version --format {{.Server.APIVersion}}
[103 ms] Server API version: 1.42
[103 ms] Start: Run: docker volume ls -q
[157 ms] Start: Run: docker ps -q -a --filter label=vsch.local.folder=/home/dave/dev/python-package-template --filter label=vsch.quality=stable
[219 ms] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=/home/dave/dev/python-package-template --filter label=devcontainer.config_file=/home/dave/dev/python-package-template/.devcontainer/devcontainer.json
[266 ms] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=/home/dave/dev/python-package-template
[313 ms] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=/home/dave/dev/python-package-template
[359 ms] Start: Run: /usr/share/code/code --ms-enable-electron-run-as-node /home/dave/.vscode/extensions/ms-vscode-remote.remote-containers-0.282.0/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /home/dave/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --container-session-data-folder /tmp/devcontainers-8ec073a0-9e7f-483c-895e-23f8769211a01678227224650 --workspace-folder /home/dave/dev/python-package-template --workspace-mount-consistency cached --id-label devcontainer.local_folder=/home/dave/dev/python-package-template --id-label devcontainer.config_file=/home/dave/dev/python-package-template/.devcontainer/devcontainer.json --log-level debug --log-format json --config /home/dave/dev/python-package-template/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[554 ms] (node:24120) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[555 ms] (Use `code --trace-deprecation ...` to show where the warning was created)
[555 ms] @devcontainers/cli 0.31.0. Node.js v16.14.2. linux 5.15.0-58-generic x64.
[555 ms] Start: Run: docker buildx version
[633 ms] github.com/docker/buildx v0.10.2 00ed17d
[633 ms] 
[633 ms] Start: Resolving Remote
[636 ms] Start: Run: git rev-parse --show-cdup
[639 ms] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=/home/dave/dev/python-package-template --filter label=devcontainer.config_file=/home/dave/dev/python-package-template/.devcontainer/devcontainer.json
[687 ms] Start: Run: docker inspect --type image mcr.microsoft.com/vscode/devcontainers/miniconda:0-3
[1587 ms] local container features stored at: /home/dave/.vscode/extensions/ms-vscode-remote.remote-containers-0.282.0/dist/node_modules/vscode-dev-containers/container-features
[1591 ms] Start: Run: tar --no-same-owner -x -f -
[1637 ms] * Processing feature: azure-cli
[1637 ms] (!) WARNING: Using the deprecated 'azure-cli' Feature. See https://github.com/devcontainers/features/tree/main/src/azure-cli#example-usage for the updated Feature.
[2504 ms] * Fetching feature: azure-cli_1_oci
[2919 ms] Start: Run: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-dave/container-features/0.31.0-1678227226595/Dockerfile-with-features -t vsc-python-package-template-dea278e8e0a73c483ed75e5dfd0e7447 --target dev_containers_target_stage --build-arg NODE_VERSION=none --build-context dev_containers_feature_content_source=/tmp/devcontainercli-dave/container-features/0.31.0-1678227226595 --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label --build-arg _DEV_CONTAINERS_IMAGE_USER=root --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp /home/dave/dev/python-package-template
[+] Building 14.2s (15/20)                                                      
 => [internal] load build definition from Dockerfile-with-features         0.0s
 => => transferring dockerfile: 6.18kB                                     0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 2B                                            0.0s
 => resolve image config for docker.io/docker/dockerfile:1.4               0.8s
 => CACHED docker-image://docker.io/docker/dockerfile:1.4@sha256:9ba7531b  0.0s
 => [internal] load metadata for mcr.microsoft.com/vscode/devcontainers/m  0.2s
 => [context dev_containers_feature_content_source] load .dockerignore     0.0s
 => => transferring dev_containers_feature_content_source: 2B              0.0s
 => [context dev_containers_feature_content_source] load from client       0.0s
 => => transferring dev_containers_feature_content_source: 306.52kB        0.0s
 => [dev_container_auto_added_stage_label 1/7] FROM mcr.microsoft.com/vsc  0.0s
 => [internal] load build context                                          0.0s
 => => transferring context: 1.87kB                                        0.0s
 => CACHED [dev_container_auto_added_stage_label 2/7] RUN if [ "none" !=   0.0s
 => CACHED [dev_container_auto_added_stage_label 3/7] COPY environment.ym  0.0s
 => CACHED [dev_container_auto_added_stage_label 4/7] RUN if [ -f "/tmp/c  0.0s
 => CACHED [dev_container_auto_added_stage_label 5/7] RUN conda install -  0.0s
 => CACHED [dev_container_auto_added_stage_label 6/7] COPY .pre-commit-co  0.0s
 => ERROR [dev_container_auto_added_stage_label 7/7] RUN git init . && p  12.9s
------                                                                          
 > [dev_container_auto_added_stage_label 7/7] RUN git init . && pre-commit install-hooks:
#0 0.315 hint: Using 'master' as the name for the initial branch. This default branch name
#0 0.315 hint: is subject to change. To configure the initial branch name to use in all
#0 0.315 hint: of your new repositories, which will suppress this warning, call:
#0 0.315 hint: 
#0 0.315 hint:  git config --global init.defaultBranch <name>
#0 0.315 hint: 
#0 0.315 hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
#0 0.315 hint: 'development'. The just-created branch can be renamed via this command:
#0 0.315 hint: 
#0 0.315 hint:  git branch -m <name>
#0 0.316 Initialized empty Git repository in /.git/
#0 0.453 [INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
#0 1.298 [INFO] Initializing environment for https://github.com/PyCQA/isort.
#0 3.267 [INFO] Initializing environment for https://github.com/asottile/pyupgrade.
#0 4.104 [INFO] Initializing environment for https://github.com/hadialqattan/pycln.
#0 5.183 [INFO] Initializing environment for https://github.com/codespell-project/codespell.
#0 6.183 [INFO] Initializing environment for https://github.com/pre-commit/pygrep-hooks.
#0 6.942 [INFO] Initializing environment for https://github.com/mgedmin/check-manifest.
#0 7.721 [INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
#0 7.721 [INFO] Once installed this environment will be reused.
#0 7.721 [INFO] This may take a few minutes...
#0 10.64 [INFO] Installing environment for https://github.com/PyCQA/isort.
#0 10.64 [INFO] Once installed this environment will be reused.
#0 10.64 [INFO] This may take a few minutes...
#0 12.83 An unexpected error has occurred: CalledProcessError: command: ('/root/.cache/pre-commit/repo73dmi5u3/py_env-python3/bin/python', '-mpip', 'install', '.')
#0 12.83 return code: 1
#0 12.83 stdout:
#0 12.83     Processing /root/.cache/pre-commit/repo73dmi5u3
#0 12.83       Installing build dependencies: started
#0 12.83       Installing build dependencies: finished with status 'done'
#0 12.83       Getting requirements to build wheel: started
#0 12.83       Getting requirements to build wheel: finished with status 'done'
#0 12.83       Preparing metadata (pyproject.toml): started
#0 12.83       Preparing metadata (pyproject.toml): finished with status 'error'
#0 12.83 stderr:
#0 12.83       error: subprocess-exited-with-error
#0 12.83       
#0 12.83       × Preparing metadata (pyproject.toml) did not run successfully.
#0 12.83       │ exit code: 1
#0 12.83       ╰─> [14 lines of output]
#0 12.83           Traceback (most recent call last):
#0 12.83             File "/root/.cache/pre-commit/repo73dmi5u3/py_env-python3/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
#0 12.83               main()
#0 12.83             File "/root/.cache/pre-commit/repo73dmi5u3/py_env-python3/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
#0 12.83               json_out['return_val'] = hook(**hook_input['kwargs'])
#0 12.83             File "/root/.cache/pre-commit/repo73dmi5u3/py_env-python3/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
#0 12.83               return hook(metadata_directory, config_settings)
#0 12.83             File "/tmp/pip-build-env-cj2uaj8h/overlay/lib/python3.8/site-packages/poetry/core/masonry/api.py", line 40, in prepare_metadata_for_build_wheel
#0 12.83               poetry = Factory().create_poetry(Path(".").resolve(), with_groups=False)
#0 12.83             File "/tmp/pip-build-env-cj2uaj8h/overlay/lib/python3.8/site-packages/poetry/core/factory.py", line 57, in create_poetry
#0 12.83               raise RuntimeError("The Poetry configuration is invalid:\n" + message)
#0 12.83           RuntimeError: The Poetry configuration is invalid:
#0 12.83             - [extras.pipfile_deprecated_finder.2] 'pip-shims<=0.3.4' does not match '^[a-zA-Z-_.0-9]+$'
#0 12.83           
#0 12.83           [end of output]
#0 12.83       
#0 12.83       note: This error originates from a subprocess, and is likely not a problem with pip.
#0 12.83     error: metadata-generation-failed
#0 12.83     
#0 12.83     × Encountered error while generating package metadata.
#0 12.83     ╰─> See above for output.
#0 12.83     
#0 12.83     note: This is an issue with the package mentioned above, not pip.
#0 12.83     hint: See above for details.
#0 12.83 Check the log at /root/.cache/pre-commit/pre-commit.log
------
Dockerfile-with-features:26
--------------------
  24 |     
  25 |     COPY .pre-commit-config.yaml .
  26 | >>> RUN git init . && pre-commit install-hooks
  27 |     
  28 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c git init . && pre-commit install-hooks" did not complete successfully: exit code: 3
[17577 ms] Error: Command failed: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-dave/container-features/0.31.0-1678227226595/Dockerfile-with-features -t vsc-python-package-template-dea278e8e0a73c483ed75e5dfd0e7447 --target dev_containers_target_stage --build-arg NODE_VERSION=none --build-context dev_containers_feature_content_source=/tmp/devcontainercli-dave/container-features/0.31.0-1678227226595 --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label --build-arg _DEV_CONTAINERS_IMAGE_USER=root --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp /home/dave/dev/python-package-template
[17577 ms]     at hie (/home/dave/.vscode/extensions/ms-vscode-remote.remote-containers-0.282.0/dist/spec-node/devContainersSpecCLI.js:1931:1698)
[17578 ms]     at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
[17578 ms]     at async FF (/home/dave/.vscode/extensions/ms-vscode-remote.remote-containers-0.282.0/dist/spec-node/devContainersSpecCLI.js:1930:3910)
[17578 ms]     at async S7 (/home/dave/.vscode/extensions/ms-vscode-remote.remote-containers-0.282.0/dist/spec-node/devContainersSpecCLI.js:1930:2839)
[17579 ms]     at async xie (/home/dave/.vscode/extensions/ms-vscode-remote.remote-containers-0.282.0/dist/spec-node/devContainersSpecCLI.js:1945:2625)
[17579 ms]     at async Wf (/home/dave/.vscode/extensions/ms-vscode-remote.remote-containers-0.282.0/dist/spec-node/devContainersSpecCLI.js:1945:3750)
[17579 ms]     at async noe (/home/dave/.vscode/extensions/ms-vscode-remote.remote-containers-0.282.0/dist/spec-node/devContainersSpecCLI.js:2069:17325)
[17580 ms]     at async roe (/home/dave/.vscode/extensions/ms-vscode-remote.remote-containers-0.282.0/dist/spec-node/devContainersSpecCLI.js:2069:17066)
[17587 ms] Exit code 1
[17591 ms] Command failed: /usr/share/code/code --ms-enable-electron-run-as-node /home/dave/.vscode/extensions/ms-vscode-remote.remote-containers-0.282.0/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /home/dave/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --container-session-data-folder /tmp/devcontainers-8ec073a0-9e7f-483c-895e-23f8769211a01678227224650 --workspace-folder /home/dave/dev/python-package-template --workspace-mount-consistency cached --id-label devcontainer.local_folder=/home/dave/dev/python-package-template --id-label devcontainer.config_file=/home/dave/dev/python-package-template/.devcontainer/devcontainer.json --log-level debug --log-format json --config /home/dave/dev/python-package-template/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[17591 ms] Exit code 1

Upgrade Semantic PR check action to v5

Upgrade Semantic PR Check / Validate PR title (pull_request_target) to v5
Currently with v4 you get this warning

> Run amannn/action-semantic-pull-request@v4

Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

Codespace build fails with "AttributeError: cython_sources"

I just created a new project from this template, tried to create a codespace, and it failed (consistently/repeatedly) with the following error (verbose, becaause I'm not sure which bits are important):

=================================================================================
2023-12-04 07:51:42.603Z: Running blocking commands...
2023-12-04 07:51:42.633Z: $ devcontainer up --id-label Type=codespaces --workspace-folder /var/lib/docker/codespacemount/workspace/poormans-python-testing --mount type=bind,source=/.codespaces/agent/mount/cache,target=/vscode --user-data-folder /var/lib/docker/codespacemount/.persistedshare --container-data-folder .vscode-remote/data/Machine --container-system-data-folder /var/vscode-remote --log-level trace --log-format json --update-remote-user-uid-default never --mount-workspace-git-root false --omit-config-remote-env-from-metadata --skip-non-blocking-commands --expect-existing-container --config "/var/lib/docker/codespacemount/workspace/poormans-python-testing/.devcontainer/devcontainer.json" --override-config /root/.codespaces/shared/merged_devcontainer.json --default-user-env-probe loginInteractiveShell --container-session-data-folder /workspaces/.codespaces/.persistedshare/devcontainers-cli/cache --secrets-file /root/.codespaces/shared/user-secrets-envs.json
2023-12-04 07:51:42.865Z: @devcontainers/cli 0.52.1. Node.js v18.17.1. linux 6.2.0-1016-azure x64.
2023-12-04 07:51:43.226Z: Running the onCreateCommand from devcontainer.json...

2023-12-04 07:51:43.234Z: pre-commit install-hooks
2023-12-04 07:51:43.840Z: [INFO]�[m Initializing environment for ********/pre-commit/pre-commit-hooks.
2023-12-04 07:51:44.942Z: [INFO]�[m Initializing environment for ********/PyCQA/isort.
2023-12-04 07:51:45.678Z: [INFO]�[m Initializing environment for ********/asottile/pyupgrade.
2023-12-04 07:51:46.354Z: [INFO]�[m Initializing environment for ********/hadialqattan/pycln.
2023-12-04 07:51:47.068Z: [INFO]�[m Initializing environment for ********/codespell-project/codespell.
2023-12-04 07:51:47.725Z: [INFO]�[m Initializing environment for ********/pre-commit/pygrep-hooks.
2023-12-04 07:51:48.302Z: [INFO]�[m Initializing environment for ********/mgedmin/check-manifest.
2023-12-04 07:51:48.938Z: [INFO]�[m Installing environment for ********/pre-commit/pre-commit-hooks.
[INFO]�[m Once installed this environment will be reused.
[INFO]�[m This may take a few minutes...
2023-12-04 07:51:54.899Z: [INFO]�[m Installing environment for ********/PyCQA/isort.
2023-12-04 07:51:54.907Z: [INFO]�[m Once installed this environment will be reused.
[INFO]�[m This may take a few minutes...
2023-12-04 07:51:57.913Z: [INFO]�[m Installing environment for ********/asottile/pyupgrade.
[INFO]�[m Once installed this environment will be reused.
[INFO]�[m This may take a few minutes...
2023-12-04 07:52:01.732Z: [INFO]�[m Installing environment for ********/hadialqattan/pycln.
[INFO]�[m Once installed this environment will be reused.
[INFO]�[m This may take a few minutes...
2023-12-04 07:52:20.173Z: An unexpected error has occurred: CalledProcessError: command: ('/home/vscode/.cache/pre-commit/repo52rhy_om/py_env-python3/bin/python', '-mpip', 'install', '.')
return code: 1
stdout:
    Processing /home/vscode/.cache/pre-commit/repo52rhy_om
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'done'
      Preparing metadata (pyproject.toml): started
      Preparing metadata (pyproject.toml): finished with status 'done'
    Collecting libcst<0.4.0,>=0.3.10 (from pycln==1.2.5)
      Downloading libcst-0.3.23-py3-none-any.whl (517 kB)
         ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 517.4/517.4 kB 9.2 MB/s eta 0:00:00
    Collecting pathspec<0.10.0,>=0.9.0 (from pycln==1.2.5)
      Downloading pathspec-0.9.0-py2.py3-none-any.whl (31 kB)
    Collecting pyyaml<6.0.0,>=5.3.1 (from pycln==1.2.5)
      Downloading PyYAML-5.4.1.tar.gz (175 kB)
         ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 175.1/175.1 kB 5.1 MB/s eta 0:00:00
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'error'
stderr:
      error: subprocess-exited-with-error
      
      × Getting requirements to build wheel did not run successfully.
      │ exit code: 1
      ╰─> [54 lines of output]
          running egg_info
          writing lib3/PyYAML.egg-info/PKG-INFO
          writing dependency_links to lib3/PyYAML.egg-info/dependency_links.txt
          writing top-level names to lib3/PyYAML.egg-info/top_level.txt
          Traceback (most recent call last):
            File "/home/vscode/.cache/pre-commit/repo52rhy_om2023-12-04 07:52:20.179Z: /py_env-python3/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
              main()
            File "/home/vscode/.cache/pre-commit/repo52rhy_om/py_env-python3/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
              json_out['return_val'] = hook(**hook_input['kwargs'])
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/home/vscode/.cache/pre-commit/repo52rhy_om/py_env-python3/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
              return hook(config_settings)
                     ^^^^^^^^^^^^^^^^^^^^^
            File "/tmp/pip-build-env-dtb0y3el/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
              return self._get_build_requires(config_settings, requirements=['wheel'])
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/tmp/pip-build-env-dtb0y3el/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
              self.run_setup()
            File "/tmp/pip-build-env-dtb0y3el/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 311, in run_setup
              exec(code, locals())
            File "<string>", line 271, in <module>
            File "/tmp/pip-build-env-dtb0y3el/overlay/lib/python3.12/site-packages/setuptools/__init__.py", line 103, in setup
              return distutils.core.setup(**attrs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/tmp/pip-build-env-dtb0y3el/overlay/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 185, in setup
              return run_commands(dist)
                     ^^^^^^^^^^^^^^^^^^
            File "/tmp/pip-build-env-dtb0y3el/overlay/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
              dist.run_commands()
            File "/tmp/pip-build-env-dtb0y3el/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
              self.run_command(cmd)
            File "/tmp/pip-build-env-dtb0y3el/overlay/lib/python3.12/site-packages/setuptools/dist.py", line 963, in run_command
              super().run_command(command)
            File "/tmp/pip-build-env-dtb0y3el/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
              cmd_obj.run()
            File "/tmp/pip-build-env-dtb0y3el/overlay/lib/python3.12/site-packages/setuptools/command/egg_info.py", line 321, in run
              self.find_sources()
            File "/tmp/pip-build-env-dtb0y3el/overlay/lib/python3.12/site-packages/setuptools/command/egg_info.py", line 329, in find_sources
              mm.run()
            File "/tmp/pip-build-env-dtb0y3el/overlay/lib/python3.12/site-packages/setuptools/command/egg_info.py", line 551, in run
              self.add_defaults()
            File "/tmp/pip-build-env-dtb0y3el/overlay/lib/python3.12/site-packages/setuptools/command/egg_info.py", line 589, in add_defaults
              sdist.add_defaults(self)
            File "/tmp/pip-build-env-dtb0y3el/overlay/lib/python3.12/site-packages/setuptools/command/sdist.py", line 112, in add_defaults
              super().add_defaults()
            File "/tmp/pip-build-env-dtb0y3el/overlay/lib/python3.12/site-packages/setuptools/_distutils/command/sdist.py", line 251, in add_defaults
              self._add_defaults_ext()
            File "/tmp/pip-build-env-dtb0y3el/overlay/lib/python3.12/site-packages/setuptools/_distutils/command/sdist.py", line 336, in _add_defaults_ext
              self.filelist.extend(build_ext.get_source_files())
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "<string>", line 201, in get_source_files
            File "/tmp/pip-build-env-dtb0y3el/overlay/2023-12-04 07:52:20.187Z: lib/python3.12/site-packages/setuptools/_distutils/cmd.py", line 107, in __getattr__
              raise AttributeError(attr)
          AttributeError: cython_sources
          [end of output]
      
      note: This error originates from a subprocess, and is likely not a problem with pip.
    error: subprocess-exited-with-error
    
    × Getting requirements to build wheel did not run successfully.
    │ exit code: 1
    ╰─> See above for output.
    
    note: This error originates from a subprocess, and is likely not a problem with pip.
2023-12-04 07:52:20.189Z: Check the log at /home/vscode/.cache/pre-commit/pre-commit.log
2023-12-04 07:52:20.237Z: onCreateCommand failed with exit code 3. Skipping any further user-provided commands.

2023-12-04 07:52:20.248Z: Error: Command failed: /bin/sh -c pre-commit install-hooks
2023-12-04 07:52:20.254Z:     at WY (/usr/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:235:130)
2023-12-04 07:52:20.261Z:     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2023-12-04 07:52:20.298Z: {"outcome":"error","message":"Command failed: /bin/sh -c pre-commit install-hooks","description":"The onCreateCommand in the devcontainer.json failed.","containerId":"63f3ec8410a6bc47d1c4723747eb4471684227113686782fe8af91f0a4768f6e"}
2023-12-04 07:52:20.304Z:     at async bl (/usr/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:227:4393)
2023-12-04 07:52:20.314Z:     at async Ll (/usr/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:227:3738)
2023-12-04 07:52:20.321Z:     at async vl (/usr/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:227:2745)
2023-12-04 07:52:20.326Z:     at async Js (/usr/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:227:2386)
2023-12-04 07:52:20.330Z:     at async QAA (/usr/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:462:1496)
2023-12-04 07:52:20.334Z:     at async kK (/usr/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:462:964)
2023-12-04 07:52:20.337Z:     at async NAA (/usr/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:479:3660)
2023-12-04 07:52:20.342Z:     at async vC (/usr/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:479:4775)
2023-12-04 07:52:20.347Z: devcontainer process exited with exit code 1

====================================== ERROR ====================================
2023-12-04 07:52:20.352Z: Failed to create container.
=================================================================================
2023-12-04 07:52:20.359Z: Error: Command failed: /bin/sh -c pre-commit install-hooks
2023-12-04 07:52:20.364Z: Error code: 1302 (UnifiedContainersErrorFatalCreatingContainer)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.