Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove tests from wheel distribution #655

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
3 changes: 1 addition & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ build/
htmlcov/
icloudpd.egg-info
cron_script.sh
Photos/
.vscode
**/__pycache__
.pytest_cache/
Expand All @@ -13,7 +12,7 @@ Photos/
.coverage
.coverage.*
.git
tests/fixtures/**
tests/
.venv
venv
create/
10 changes: 5 additions & 5 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Retrieve version and Changelog
id: get_version
run: |
echo icloudpd_version=$(cat setup.py | grep version= | cut -d'"' -f 2) >> $GITHUB_OUTPUT
echo icloudpd_version=$(cat pyproject.toml | grep version= | cut -d'"' -f 2) >> $GITHUB_OUTPUT
echo 'icloudpd_changelog<<EOF' >> $GITHUB_OUTPUT
scripts/extract_releasenotes CHANGELOG.md >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -52,9 +52,9 @@ jobs:
run: python.exe -m pip install -r requirements-pip.txt
if: ${{ matrix.os == 'windows-latest' }}

- name: Install dependencies
- name: Install Dev dependencies
run: |
scripts/install_deps
pip install -e .[dev]

- name: Build Python (Linux)
run: |
Expand Down Expand Up @@ -141,9 +141,9 @@ jobs:
with:
python-version: 3.11

- name: Install dependencies
- name: Install Dev dependencies
run: |
scripts/install_deps
pip install -e .[dev]

- name: Download artifacts
uses: actions/download-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Retrieve version and Changelog
id: get_version
run: |
echo icloudpd_version=$(cat setup.py | grep version= | cut -d'"' -f 2) >> $GITHUB_OUTPUT
echo icloudpd_version=$(cat pyproject.toml | grep version= | cut -d'"' -f 2) >> $GITHUB_OUTPUT
echo 'icloudpd_changelog<<EOF' >> $GITHUB_OUTPUT
scripts/extract_releasenotes CHANGELOG.md >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/quality-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
- name: Install Test dependencies
run: |
scripts/install_deps
pip install -e .[test]

- name: Lint
run: |
Expand All @@ -45,7 +45,7 @@ jobs:
- name: Retrieve version and Changelog
id: get_version
run: |
echo icloudpd_version=$(cat setup.py | grep version= | cut -d'"' -f 2) >> $GITHUB_OUTPUT
echo icloudpd_version=$(cat pyproject.toml | grep version= | cut -d'"' -f 2) >> $GITHUB_OUTPUT
echo 'icloudpd_changelog<<EOF' >> $GITHUB_OUTPUT
scripts/extract_releasenotes CHANGELOG.md >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -78,9 +78,9 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
- name: Install Dev dependencies
run: |
scripts/install_deps
pip install -e .[dev]

- name: Build Python (Linux)
run: |
Expand Down
4 changes: 0 additions & 4 deletions .pytest.ini

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ When testing a bugfix it is important to test the faulty behavior and also the e
## How to release

We have github actions taking care for building, testing, and releasing software. Building and testing are happenning automatically on git pushed, pull requests, and merges. For releases the following steps are manual:
- Bump version in setup.py, all .md files, and all source files
- Bump version in all files, including all source files
- Update CHANGELOG.md with date of the release
- Update CHANGELOG.md with release changes if they were not added with commits
- Commit & push/merge changes
Expand Down
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ RUN set -xe \
&& apk update \
&& apk add git curl binutils gcc libc-dev libffi-dev cargo zlib-dev openssl-dev

COPY . .
COPY pyproject.toml .
COPY src src

RUN pip3 install -r requirements-pip.txt -r requirements.txt -r requirements-dev.txt
RUN pip3 install -e .[dev]

RUN pyinstaller -y --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata exec.py
RUN pyinstaller -y --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata src/starters/exec.py

FROM alpine:3.17 as runtime

Expand Down
83 changes: 83 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
[build-system]
requires = [
"setuptools>=68.0.0,<69",
"wheel>=0.40.0,<0.41",
]
build-backend = "setuptools.build_meta"

[project]
version="1.14.2"
name = "icloudpd"
description = "icloudpd is a command-line tool to download photos and videos from iCloud."
readme = "README_PYPI.md"
requires-python = ">=3.7,<3.12"
keywords = ["icloud", "photo"]
license = {file="LICENSE.md"}
authors=[
{name = "The iCloud Photo Downloader Authors"}
]
classifiers = [
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
]
dependencies = [
"requests>=2.28.2,<3",
"schema>=0.7.5,<0.8",
"click>=8.1.3,<9",
"python-dateutil>=2.8.2,<3",
"tqdm>=4.64.1,<5",
"piexif>=1.1.3,<2",
"urllib3>=1.26.14,<2",
# from pyicloud_ipd
"six>=1.16.0,<2",
"tzlocal>=4.2,<5",
"pytz>=2022.7.1,<2023",
"certifi>=2022.12.7,<2023",
"future>=0.18.3,<0.19",
"keyring>=23.13.1,<24",
"keyrings-alt>=4.2.0,<5"
]

[project.optional-dependencies]
dev = [
"twine>=4.0.0,<5",
"pyinstaller>=5.7.0,<6",
"wheel>=0.40.0,<0.41"
]
test = [
"pytest>=7.2.1,<8",
"mock>=5.0.1,<6",
"freezegun>=1.2.2,<2",
"vcrpy>=4.2.1,<5",
"pytest-cov>=4.0.0,<5",
"pylint>=2.15.10,<3",
"coveralls>=3.3.1,<4",
"autopep8>=2.0.1,<3",
"pytest-timeout>=2.1.0,<3",
"pytest-xdist>=3.1.0,<4"
]

[project.urls]
Homepage="https://github.com/icloud-photos-downloader/icloud_photos_downloader"

[project.scripts]
icloudpd = "icloudpd.base:main"
icloud = "pyicloud_ipd.cmdline:main"

[tool.pytest.ini_options]
log_format = "%(levelname)-8s %(message)s"
log_date_format = "%Y-%m-%d %H:%M:%S"
timeout = 300
testpaths = [
"tests"
]
pythonpath = [
"src"
]

[tool.setuptools.packages.find]
where = ["src"] # list of folders that contain the packages (["."] by default)
exclude = ["starters"]
4 changes: 0 additions & 4 deletions requirements-dev.txt

This file was deleted.

10 changes: 0 additions & 10 deletions requirements-test.txt

This file was deleted.

15 changes: 0 additions & 15 deletions requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -euo pipefail

mkdir -p dist
rm -fr dist/*
python3 setup.py bdist_wheel --universal
python3 -m pip wheel . -w dist --no-deps --no-build-isolation
6 changes: 3 additions & 3 deletions scripts/build_bin_linux
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ set -euo pipefail
# expects dist to have comipled binary versions
# required param: version

pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloudpd.py icloud.py --name icloudpd-$1-linux-$2
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloud.py --name icloud-$1-linux-$2
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile exec.py --name icloudpd-ex-$1-linux-$2
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloudpd.py src/starters/icloud.py --name icloudpd-$1-linux-$2
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloud.py --name icloud-$1-linux-$2
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/exec.py --name icloudpd-ex-$1-linux-$2
4 changes: 2 additions & 2 deletions scripts/build_bin_macos
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ set -euo pipefail
# expects dist to have comipled binary versions
# required param: version

pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloudpd.py icloud.py --name icloudpd-$1-macos-$2
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile exec.py --name icloudpd-ex-$1-macos-$2
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloudpd.py src/starters/icloud.py --name icloudpd-$1-macos-$2
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/exec.py --name icloudpd-ex-$1-macos-$2
6 changes: 3 additions & 3 deletions scripts/build_bin_windows
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ set -euo pipefail
# expects python with installed dependencies
# required param: version

pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloudpd.py icloud.py --name icloudpd-$1-windows-$2
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile icloud.py --name icloud-$1-windows-$2
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile exec.py --name icloudpd-ex-$1-windows-$2
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloudpd.py src/starters/icloud.py --name icloudpd-$1-windows-$2
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloud.py --name icloud-$1-windows-$2
pyinstaller --collect-all keyrings.alt --hidden-import pkgutil --collect-all tzdata --onefile src/starters/exec.py --name icloudpd-ex-$1-windows-$2
2 changes: 1 addition & 1 deletion scripts/build_docker
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ realpath() {
CURRENT_DIR=$(dirname "$0")
ROOT_DIR="$(realpath $(dirname "$0")/..)"

ICLOUDPD_VERSION="$(cat "$ROOT_DIR/setup.py" | grep version= | cut -d'"' -f 2)"
ICLOUDPD_VERSION="$(cat "$ROOT_DIR/pyproject.toml" | grep version= | cut -d'"' -f 2)"
echo "Current icloudpd version: ${ICLOUDPD_VERSION}"

docker build \
Expand Down
3 changes: 2 additions & 1 deletion scripts/install_deps
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# this is used to setup development env (all required dependencies for all cases)
set -euo pipefail
python3 -m pip install -r requirements-pip.txt
pip3 install -r requirements.txt -r requirements-test.txt -r requirements-dev.txt
pip3 install -e .[test,dev]
5 changes: 2 additions & 3 deletions scripts/lint
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash
# (There are some small differences between Python 2 and 3)
set -euo pipefail
echo "Running pylint for Python 3..."
python3 -m pylint icloudpd/
echo "Running pylint..."
python3 -m pylint src/icloudpd
2 changes: 1 addition & 1 deletion scripts/release_docker
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ROOT_DIR="$(realpath $(dirname "$0")/..)"

$CURRENT_DIR/build_docker

ICLOUDPD_VERSION="$(cat "$ROOT_DIR/setup.py" | grep version= | cut -d'"' -f 2)"
ICLOUDPD_VERSION="$(cat "$ROOT_DIR/pyproject.toml" | grep version= | cut -d'"' -f 2)"
echo "Pushing Docker images for icloudpd version: ${ICLOUDPD_VERSION}"

set +x
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

34 changes: 0 additions & 34 deletions setup.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 7 additions & 3 deletions icloudpd/base.py → src/icloudpd/base.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import itertools
import subprocess
import json
from typing import Callable, TypeVar
import urllib
import click

Expand Down Expand Up @@ -276,7 +277,7 @@ def main(
print('--auto-delete and --delete-after-download are mutually exclusive')
sys.exit(2)

if watch_with_interval and (list_albums or only_print_filenames):
if watch_with_interval and (list_albums or only_print_filenames): # pragma: no cover
print('--watch_with_interval is not compatible with --list_albums, --only_print_filenames')
sys.exit(2)

Expand Down Expand Up @@ -554,8 +555,11 @@ def delete_photo(logger, icloud, photo):
url, data=post_data, headers={
"Content-type": "application/json"})

RetrierT = TypeVar('RetrierT')

def retrier(func, error_handler):
def retrier(
func: Callable[[], RetrierT],
error_handler: Callable[[Exception, int], None]) -> RetrierT:
"""Run main func and retry helper if receive session error"""
attempts = 0
while True:
Expand Down Expand Up @@ -799,7 +803,7 @@ def delete_cmd():
if auto_delete:
autodelete_photos(icloud, folder_structure, directory)

if watch_interval:
if watch_interval: # pragma: no cover
logger.info(f"Waiting for {watch_interval} sec...")
interval = range(1, watch_interval)
for _ in interval if skip_bar else tqdm(
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added src/starters/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading