diff --git a/.gitignore b/.gitignore index 3cb9027..1daa1a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,66 @@ -*.pyc -.idea -*.log \ No newline at end of file +# Compiler +.idea/ +.vscode/ + +# Byte-compiled / optimized / DLL files / logs +__pycache__/ +*.py[cod] +*$py.class +*.log + + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json diff --git a/.license-ignore b/.license-ignore index c045e65..869bdc7 100644 --- a/.license-ignore +++ b/.license-ignore @@ -9,10 +9,7 @@ .asf.yaml LICENSE NOTICE -README.md -requirements.txt requirements-dev.txt -rat-report.txt # directories .vscode @@ -21,5 +18,3 @@ rat-report.txt .gitignore .license-ignore ./samples/proto/* - - diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 457f604..e5f24b0 100755 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,6 +58,24 @@ git push origin your_awesome_patch Thanks for contributing! + + +### Development & Testing + +Before you start working on development, please install the necessary dependencies for Dubbo-Python using the following command: + +```shell +pip install -r requirements-dev.txt +``` + +Our project uses a `src` layout, and packaging is required before running tests. We strongly recommend using the **editable installation mode** for packaging and testing: + +```shell +pip install -e . +``` + + + ### Code style We use **ruff** as the linter and code formatter for Dubbo-Python, and **Mypy** as the static type checker. @@ -73,7 +91,7 @@ We have already set up the configurations for ruff and Mypy in the `pyproject.to By default, ruff will look for the `pyproject.toml` file in the current directory and its parent directories and load its configuration. - ```bash + ```shell # Default ruff format @@ -83,7 +101,7 @@ We have already set up the configurations for ruff and Mypy in the `pyproject.to 2. Code Linting - ```bash + ```shell # Just check ruff check @@ -95,7 +113,7 @@ We have already set up the configurations for ruff and Mypy in the `pyproject.to Mypy will also automatically look for the `pyproject.toml` file and load its configuration. - ```bash + ```shell # Default mypy diff --git a/README.md b/README.md index dcca35b..26e901c 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # Apache Dubbo for Python -![License](https://img.shields.io/github/license/apache/dubbo-python) +![License](https://img.shields.io/github/license/apache/dubbo-python?logo=apache&logoColor=red&label=LICENSE) ![GitHub last commit](https://img.shields.io/github/last-commit/apache/dubbo-python) ![GitHub branch check runs](https://img.shields.io/github/check-runs/apache/dubbo-python/main) - ---- +![PyPI - Version](https://img.shields.io/pypi/v/apache-dubbo?logo=pypi&logoColor=gold&label=PyPI&color=blue) +![PyPI - Python Version](https://img.shields.io/pypi/pyversions/apache-dubbo?logo=python&logoColor=gold&label=Python)

Logo @@ -29,19 +29,22 @@ Visit [the official website](https://dubbo.apache.org/) for more information. - **Serialization**: Customizable(protobuf, json...) - ## Installation -Before you start, make sure you have **`python 3.11+`** installed. +Before you start, make sure you have **`python 3.9+`** installed. + +1. Install Directly -1. Install from source + ```sh + pip install apache-dubbo + ``` +2. Install from source ```sh git clone https://github.com/apache/dubbo-python.git cd dubbo-python && pip install . ``` - ## Getting started Get up and running with Dubbo-Python in just 5 minutes by following our [Quick Start Guide](https://github.com/apache/dubbo-python/tree/main/samples). @@ -116,7 +119,11 @@ It's as simple as the code snippet below. With just a few lines of code, you can ``` - +## Contributing + +We are excited to welcome contributions to the Dubbo-Python project! Whether you are fixing bugs, adding new features, or improving documentation, your input is highly valued. + +To ensure a smooth collaboration, please review our [Contributing Guide](https://github.com/apache/dubbo-python/blob/main/CONTRIBUTING.md) for detailed instructions on how to get started, adhere to coding standards, and submit your contributions effectively. ## License diff --git a/pyproject.toml b/pyproject.toml index f493e4c..7f9f425 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ requires = ["hatchling", "hatch-fancy-pypi-readme"] build-backend = "hatchling.build" [project] -name="dubbo-python" +name="apache-dubbo" requires-python = ">=3.9" authors = [ {name = "Apache Dubbo Community", email = "dev@dubbo.apache.org"} @@ -41,6 +41,8 @@ classifiers=[ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Framework :: AsyncIO", "Topic :: Internet", "Topic :: Internet :: WWW/HTTP", diff --git a/scripts/rat.sh b/scripts/rat.sh index ee77741..d76d692 100755 --- a/scripts/rat.sh +++ b/scripts/rat.sh @@ -19,17 +19,16 @@ ### Apache RAT license check script ### # This script downloads Apache RAT and runs it to check the license headers of the source files. -set -e # Exit immediately if a command exits with a non-zero status. +set -e -# Some variables ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)" -TEMP_DIR="${ROOT_DIR}/temp" +TMP_DIR="$(mktemp -d)" + RAT_VERSION="0.16.1" -RAT_JAR="${TEMP_DIR}/apache-rat-${RAT_VERSION}.jar" +RAT_JAR="${TMP_DIR}/apache-rat-${RAT_VERSION}.jar" cd "${ROOT_DIR}" -mkdir -p "${TEMP_DIR}" # Set Java command if [ -x "${JAVA_HOME}/bin/java" ]; then @@ -39,48 +38,43 @@ else fi -# Download Apache RAT jar file if not exists -if [ ! -f "${RAT_JAR}" ]; then - RAT_URL="https://repo1.maven.org/maven2/org/apache/rat/apache-rat/${RAT_VERSION}/apache-rat-${RAT_VERSION}.jar" - JAR_PART="${RAT_JAR}.part" - - echo "Downloading Apache RAT ${RAT_VERSION}..." +# Download Apache RAT jar +echo "Downloading Apache RAT ${RAT_VERSION}..." - if command -v curl &> /dev/null; then - curl -L --silent "${RAT_URL}" -o "${JAR_PART}" - elif command -v wget &> /dev/null; then - wget --quiet "${RAT_URL}" -O "${JAR_PART}" - else - echo "Neither curl nor wget found." - exit 1 - fi +RAT_URL="https://repo1.maven.org/maven2/org/apache/rat/apache-rat/${RAT_VERSION}/apache-rat-${RAT_VERSION}.jar" +JAR_PART="${RAT_JAR}.part" - mv "${JAR_PART}" "${RAT_JAR}" +if command -v curl &> /dev/null; then + curl -L --silent "${RAT_URL}" -o "${JAR_PART}" && mv "${JAR_PART}" "${RAT_JAR}" +elif command -v wget &> /dev/null; then + wget --quiet "${RAT_URL}" -O "${JAR_PART}" && mv "${JAR_PART}" "${RAT_JAR}" +else + echo "Neither curl nor wget found." + exit 1 +fi +unzip -tq "${RAT_JAR}" > /dev/null +if [ $? -ne 0 ]; then + echo "Downloaded Apache RAT jar is invalid" + exit 1 +fi - # TODO: Strange phenomenon:its integrity cannot be verified, but it still works normally. (Ignore the check for now) - # Check if the JAR file is valid -# if ! unzip -tq "${RAT_JAR}" &> /dev/null; then -# rm "${RAT_JAR}" -# echo "Download ${RAT_JAR} failed or the file is not a valid JAR." -# exit 1 -# fi +echo "Downloaded Apache RAT ${RAT_VERSION} successfully." - echo "Downloaded Apache RAT ${RAT_VERSION} successfully." -fi # Run Apache RAT echo "Running Apache license check, this may take a while..." +${java_cmd} -jar ${RAT_JAR} -d ${ROOT_DIR} -E "${ROOT_DIR}/.license-ignore" > "${TMP_DIR}/rat-report.txt" -"${java_cmd}" -jar "${RAT_JAR}" -E "${ROOT_DIR}/.license-ignore" -d "${ROOT_DIR}" > "${TEMP_DIR}/rat-report.txt" -if grep -q "??" "${TEMP_DIR}/rat-report.txt"; then +# Check the result +if [ $? -ne 0 ]; then + echo "RAT exited abnormally" + exit 1 +elif grep -q "??" "${TMP_DIR}/rat-report.txt"; then echo >&2 "Could not find Apache license headers in the following files:" - grep "??" "${TEMP_DIR}/rat-report.txt" >&2 + grep "??" "${TMP_DIR}/rat-report.txt" >&2 exit 1 else echo "Apache license check passed." fi - -# Clean up -rm -rf "${TEMP_DIR}"