Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 12 additions & 25 deletions .github/workflows/functional-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,12 @@ jobs:
with:
python-version: 3.12

- run: |
# Separate 'run' creates differnet pipenv env. Does them in one run for now.
pip install --upgrade pip
pip install --upgrade pipenv
pipenv lock --clear
pipenv install -d --system
pytest ${{ matrix.test_targets.target}} --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
- name: Install uv
run: make install-uv

- name: Run Tests
run: |
uv run pytest ${{ matrix.test_targets.target}} --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
env:
LOCAL_PREBUILT_WDA: ${{ github.workspace }}/wda/WebDriverAgentRunner-Runner.app

Expand Down Expand Up @@ -161,12 +160,8 @@ jobs:
api-level: ${{ env.API_LEVEL }}
arch: ${{ env.ARCH }}
script: |
# Separate 'run' creates differnet pipenv env. Does them in one run for now.
pip install --upgrade pip
pip install --upgrade pipenv
pipenv lock --clear
pipenv install -d --system
pytest ${{ matrix.test_targets.target}} --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
make install-uv
uv run pytest ${{ matrix.test_targets.target}} --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
target: google_apis
profile: Nexus 5X
disable-spellchecker: true
Expand Down Expand Up @@ -251,12 +246,8 @@ jobs:
with:
api-level: ${{ env.API_LEVEL }}
script: |
pip install --upgrade pip
pip install --upgrade pipenv
pipenv lock --clear
pipenv install -d --system
export PLATFORM=android
pytest test/functional/flutter_integration/*_test.py --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
make install-uv
uv run pytest test/functional/flutter_integration/*_test.py --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
target: default
disable-spellchecker: true
disable-animations: true
Expand Down Expand Up @@ -296,10 +287,6 @@ jobs:
- name: Run IOS tests
if: matrix.e2e-tests == 'flutter-ios'
run: |
# Separate 'run' creates differnet pipenv env. Does them in one run for now.
pip install --upgrade pip
pip install --upgrade pipenv
pipenv lock --clear
pipenv install -d --system
make install-uv
export PLATFORM=ios
pytest test/functional/flutter_integration/*_test.py --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
uv run pytest test/functional/flutter_integration/*_test.py --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
24 changes: 4 additions & 20 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,7 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
run: pip install tox
- name: Run Tox
run: tox -e py

# test-win:
# runs-on: windows-latest
# strategy:
# matrix:
# python-version: ["3.7", "3.8", "3.9", "3.10"]
# 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 tox
# run: pip install tox
# - name: Run Tox
# run: tox -e py
- name: Install uv
run: make install-uv
- name: Run Unit Tests
run: uv run pytest test/unit
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ __pycache__

# Virtual Environments
venv*
.venv
.tox

Pipfile.lock

.coverage
27 changes: 21 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,42 @@ check: check-lint check-format

.PHONY: check-lint
check-lint:
python -m ruff check .
uv run ruff check .

.PHONY: check-format
check-format:
python -m ruff format --check .
uv run ruff format --check .

.PHONY: fix
fix: fix-lint fix-format

.PHONY: fix-lint
fix-lint:
python -m ruff check --fix .
uv run ruff check --fix .

.PHONY: fix-format
fix-format:
python -m ruff format .

uv run ruff format .

.PHONY: install-uv
install-uv:
@command -v uv >/dev/null 2>&1 || { \
echo "Installing uv"; \
curl -LsSf https://astral.sh/uv/install.sh | sh; \
if [ -n "$$GITHUB_PATH" ]; then \
echo "PATH=$$HOME/.local/bin:$$PATH" >> $$GITHUB_PATH; \
else \
echo "Please restart your shell or run 'exec $$SHELL'"; \
fi; \
}

.PHONY: sync-dev
sync-dev:
uv sync

.PHONY: unittest
unittest: ## Run unittest
python -m pytest $(ARGS) test/unit/
uv run pytest $(ARGS) test/unit/

.PHONY: help
help: ## Display this help screen
Expand Down
19 changes: 0 additions & 19 deletions Pipfile

This file was deleted.

65 changes: 43 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ the Selenium Python binding update might affect the Appium Python Client behavio
For example, some changes in the Selenium binding could break the Appium client.

> **Note**
> We strongly recommend you manage dependencies with version management tools such as Pipenv and requirements.txt
> to keep compatible version combinations.
> We strongly recommend you manage dependencies with version management tools such as
> [uv](https://docs.astral.sh/uv/) to keep compatible version combinations.


### Quick migration guide from v4 to v5
Expand Down Expand Up @@ -448,61 +448,82 @@ You have two methods to extend the read timeout.

### Setup

- `pip install --user pipenv`
- `python -m pipenv lock --clear`
- If you experience `Locking Failed! unknown locale: UTF-8` error, then refer [pypa/pipenv#187](https://github.com/pypa/pipenv/issues/187) to solve it.
- `python -m pipenv install --dev --system`
- `pre-commit install`
```bash
make install-uv
exec $SHELL
make sync-dev
```

Running above commands should automatically setup the virtual environment for the project
using the default system Python version and put it into the `.venv` folder under the project root.
If you'd like to customize the Python version then run the following command before `make sync-dev`:

```bash
uv venv --python <V>
```

where `<V>` is the actual Python version, for example `3.12`.

### Run tests
If you want to customize the folder where uv stores the virtual environment by default
(e.g. `.venv`) then add an argument containing the destination folder path to the above command:

```bash
uv venv /venv/root/folder
```

In order to activate the newly created virtual environment you may either source it:

```bash
source /venv/root/folder/bin/activate
```

You can run all of the tests running on CI via `tox` in your local.
or add it to PATH:

```bash
$ tox
export "PATH=/venv/root/folder/bin:$PATH"
```

You also can run particular tests like below.
### Testing

#### Unit

```bash
$ pytest test/unit
uv run pytest test/unit
```

Run with `pytest-xdist`
Run in parallel (2 threads)

```bash
$ pytest -n 2 test/unit
uv run pytest -n 2 test/unit
```

#### Functional

```bash
$ pytest test/functional/ios/search_context/find_by_ios_class_chain_tests.py
uv run pytest test/functional/ios/search_context/find_by_ios_class_chain_tests.py
```

#### In parallel for iOS

1. Create simulators named 'iPhone X - 8100' and 'iPhone X - 8101'
2. Install test libraries via pip, `pip install pytest pytest-xdist`
3. Run tests
1. Run tests

```bash
$ pytest -n 2 test/functional/ios/search_context/find_by_ios_class_chain_tests.py
uv run pytest -n 2 test/functional/ios/search_context/find_by_ios_class_chain_tests.py
```

## Release

Follow the below steps.

```bash
$ pip install twine
$ pip install git+git://github.com/vaab/gitchangelog.git # Getting via GitHub repository is necessary for Python 3.7
uv pip install setuptools
uv pip install twine
uv pip install git+https://github.com/vaab/gitchangelog.git # Getting via GitHub repository is necessary for Python 3.7
# Type the new version number and 'yes' if you can publish it
# You can test the command with DRY_RUN
$ DRY_RUN=1 ./release.sh
$ ./release.sh # release
DRY_RUN=1 ./release.sh
./release.sh # release
```

If the `pypi` was not able to publish with user name and password, please try out `-u` and `-p` option by yourself with `twine` such as `twine upload -u <name> -p <pass> dist/Appium-Python-Client-4.1.0.tar.gz`.
Expand Down
42 changes: 42 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[project]
name = "Appium-Python-Client"
dynamic = [
"version",
"description",
"readme",
"license",
"authors",
"maintainers",
"keywords",
"classifiers"
]
requires-python = ">=3.9"
dependencies = [
"selenium>=4.26,<5.0",
"typing-extensions~=4.13.2",
]

[tool.uv]
dev-dependencies = [
"httpretty~=1.1",
"mock~=5.2",
"pre-commit~=4.2",
"pytest~=8.4",
"pytest-cov~=6.2",
"pytest-xdist~=3.8",
"python-dateutil~=2.9",
"ruff~=0.12.7",
"types-python-dateutil~=2.9",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.version]
source = "regex"
path = "appium/version.py"
pattern = "(?P<version>\\d+\\.\\d+\\.\\d+)"

[tool.hatch.build.targets.wheel]
packages = ["appium"]
8 changes: 1 addition & 7 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
set -e
set -o pipefail

if [ -z "$PYTHON_BIN_PATH" ]; then
PYTHON_BIN_PATH=$(which python || true)
fi

export PYTHON_BIN_PATH

CONFIGURE_DIR=$(dirname "$0")
"$PYTHON_BIN_PATH" "${CONFIGURE_DIR}/script/release.py" "$@"
uv run python "${CONFIGURE_DIR}/script/release.py" "$@"

echo "Finish release process"
19 changes: 4 additions & 15 deletions script/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ def commit_version_code(new_version_num):

def tag_and_generate_changelog(new_version_num):
call_bash_script('git tag "v{}"'.format(new_version_num))
call_bash_script('gitchangelog > {}'.format(CHANGELOG_PATH))
call_bash_script('uv run gitchangelog > {}'.format(CHANGELOG_PATH))
call_bash_script('git commit {} -m "Update changelog for {}"'.format(CHANGELOG_PATH, new_version_num))


def upload_sdist(new_version_num):
push_file = 'dist/appium_python_client-{}.tar.gz'.format(new_version_num)
try:
call_bash_script('twine upload "{}"'.format(push_file))
call_bash_script('uv run twine upload "{}"'.format(push_file))
except Exception as e:
print(
'Failed to upload {} to pypi. Please fix the original error and push it again later. Original error: {}'.format(
Expand All @@ -99,21 +99,12 @@ def ensure_publication(new_version_num):


def build_sdist():
call_bash_script('{} setup.py sdist'.format(sys.executable))


def validate_release_env():
if os.system('which twine') != 0:
sys.exit("Please get twine via 'pip install twine'")
if os.system('which gitchangelog') != 0:
sys.exit(
"Please get twine via 'pip install gitchangelog' or 'pip install git+git://github.com/vaab/gitchangelog.git' for Python 3.7"
)
call_bash_script('uv run python setup.py sdist')


def build() -> None:
shutil.rmtree(BUILT_APPIUM_DIR_PATH, ignore_errors=True)
status, output = subprocess.getstatusoutput('{} setup.py install'.format(os.getenv('PYTHON_BIN_PATH')))
status, output = subprocess.getstatusoutput('uv run python setup.py install')
if status != 0:
sys.exit(f'Failed to build the package:\n{output}')

Expand Down Expand Up @@ -149,8 +140,6 @@ def assert_files_count_in_package() -> None:


def main():
validate_release_env()

get_current_version()
new_version = get_new_version()

Expand Down
Loading