Skip to content

Commit 3e4ea99

Browse files
authored
Finish a demo, pyrlconetest and add github action auto package and publish (#3)
* CI: add mac test * 1 * just test * test * test * test * CI: widows test * test temp add rclone * win fix * mac linux permissions * test * 2 * 3 * 4 * 5 * 6 * 7 * 8 * finish all ci test * prepare package and publish * before package test add permission * package and upload pyrclonetest * fix: before build pre insatll all dependencies * fix: fix publich process * add dependencies * trigger publish only at release * Squashed commit of the following: commit b2a0fa9 Author: KEN <40203972+MrLYG@users.noreply.github.com> Date: Wed Jun 28 21:02:16 2023 -0700 Add ci pytest (#2) * CI: add mac test * 1 * just test * test * test * test * CI: widows test * test temp add rclone * win fix * mac linux permissions * test * 2 * 3 * 4 * 5 * 6 * 7 * 8 * finish all ci test commit 1dc861f Merge: 4a6bb7b b7be00a Author: KEN <40203972+MrLYG@users.noreply.github.com> Date: Wed Jun 28 17:31:33 2023 -0700 Merge pull request #1 from MrLYG/ci add github action and change the path of installing rclone binary file.
1 parent b2a0fa9 commit 3e4ea99

8 files changed

Lines changed: 101 additions & 35 deletions

File tree

.github/workflows/_linux_test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ jobs:
1616
- name: package install
1717
run: |
1818
mv linux/rclone pyrclone/rclone
19+
- name: Update permissions
20+
run: |
21+
sudo chmod 755 pyrclone/rclone
1922
- name: Install dependencies
2023
run: |
2124
pip install . -v
2225
pip install pytest
23-
- name: Update permissions
24-
run: |
25-
sudo chmod 755 /opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/pyrclone/rclone
2626
- name: Test with pytest
2727
run: |
2828
make test

.github/workflows/_mac_test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ jobs:
1616
- name: package install
1717
run: |
1818
mv mac/rclone pyrclone/rclone
19+
- name: Update permissions
20+
run: |
21+
sudo chmod 755 pyrclone/rclone
1922
- name: Install dependencies
2023
run: |
2124
pip install . -v
2225
pip install pytest
23-
- name: Update permissions
24-
run: |
25-
sudo chmod 755 /Users/runner/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/pyrclone/rclone
2626
- name: Test with pytest
2727
run: |
2828
make test
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Build and Publish Packages
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
10+
11+
jobs:
12+
build_and_publish_ubuntu:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: Set up Python 3.10
17+
uses: actions/setup-python@v3
18+
with:
19+
python-version: '3.10'
20+
- name: Dependencies
21+
run: |
22+
pip install wheel twine
23+
- name: Add Rclone Binary File
24+
run: |
25+
mv linux/rclone pyrclone/rclone
26+
- name: Update Permissions
27+
run: |
28+
sudo chmod 755 pyrclone/rclone
29+
- name: Build And Package for Linux
30+
run: |
31+
make publish OS="manylinux1_x86_64"
32+
env:
33+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
34+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
35+
36+
37+
build_and_publish_windows:
38+
runs-on: windows-latest
39+
steps:
40+
- uses: actions/checkout@v3
41+
- name: Set up Python 3.10
42+
uses: actions/setup-python@v3
43+
with:
44+
python-version: '3.10'
45+
- name: Dependencies
46+
run: |
47+
pip install wheel twine
48+
- name: Add Rclone Binary File
49+
run: |
50+
move win/rclone.exe pyrclone/rclone.exe
51+
- name: Build And Package for Windows
52+
run: |
53+
make publish OS="win_amd64"
54+
env:
55+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
56+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
57+
58+
build_and_publish_mac:
59+
runs-on: macos-latest
60+
steps:
61+
- uses: actions/checkout@v3
62+
- name: Set up Python 3.10
63+
uses: actions/setup-python@v3
64+
with:
65+
python-version: '3.10'
66+
- name: Dependencies
67+
run: |
68+
pip install wheel twine
69+
- name: Add Rclone Binary File
70+
run: |
71+
mv mac/rclone pyrclone/rclone
72+
- name: Update Permissions
73+
run: |
74+
sudo chmod 755 pyrclone/rclone
75+
- name: Build And Package for Mac
76+
run: |
77+
make publish OS="macosx_10_9_x86_64"
78+
env:
79+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
80+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
81+

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
global-exclude win
2+
global-exclude mac
3+
global-exclude linux

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
test:
33
pytest ./tests
44

5+
# python setup.py sdist bdist_wheel --plat-name=$(OS) win_amd64 manylinux1_x86_64 macosx_10_9_x86_64
56
package:
6-
python setup.py sdist bdist_wheel --plat-name=$(OS)
7+
python setup.py bdist_wheel --plat-name $(OS)
78

89
publish: package
9-
twine upload
10+
twine upload dist/*.whl --verbose

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ No need to install rclone separately as it is already included in this package.
55

66
## Install
77
```python
8-
pip install pyrclone
8+
pip install pyrclonetest
99
```
1010

1111
## Usage
@@ -90,7 +90,7 @@ darwin(mac): amd64, x86_64
9090
## Developer guide
9191

9292
```bash
93-
$ pip install .[dev]
93+
$ pip install wheel twine pytest
9494
$ make test
9595
```
9696

setup.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,6 @@
22
import os
33

44

5-
# PROJECT_NAME = 'pyrclone'
6-
# if os.name == 'nt': # Windows
7-
# rclone_binary = (f'{PROJECT_NAME}', ['win/rclone.exe'])
8-
# elif os.name == 'posix': # Unix-like
9-
# if os.uname().sysname == 'Linux':
10-
# rclone_binary = (f'{PROJECT_NAME}', ['linux/rclone'])
11-
# elif os.uname().sysname == 'Darwin':
12-
# rclone_binary = (f'{PROJECT_NAME}', ['mac/rclone'])
13-
# else:
14-
# raise NotImplementedError('Unsupported OS')
15-
16-
17-
PROJECT_NAME = 'pyrclone'
185
if os.name == 'nt': # Windows
196
rclone_binary = ['rclone.exe']
207
elif os.name == 'posix': # Unix-like
@@ -26,18 +13,17 @@
2613
raise NotImplementedError('Unsupported OS')
2714

2815
setuptools.setup(
29-
name="pyrclone",
30-
version="0.0.1",
16+
name="pyrclonetest",
17+
version="0.0.7",
3118
author="Yuangang Li",
3219
author_email="yuangangli@outlook.com",
3320
description="A package that provides a wrapper for RClone",
3421
long_description=open('README.md').read(),
3522
long_description_content_type="text/markdown",
3623
url="https://github.com/MrLYG/python-rclone.git",
37-
packages=setuptools.find_packages(),
24+
packages=setuptools.find_packages(exclude=('mac', 'win', 'linux')),
3825
include_package_data=True,
3926
package_data={
40-
# If any package contains *.bin files, include them:
4127
'pyrclone': rclone_binary,
4228
},
4329
classifiers=[

tests/wrapper_test.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
import os
55
import logging
66
import json
7-
8-
import pkg_resources
9-
from pyrclone.rclone_wrapper import RCloneWrapper
107
import shutil
8+
from pyrclone.rclone_wrapper import RCloneWrapper
9+
1110

1211
logging.basicConfig(
1312
level=logging.INFO,
@@ -83,7 +82,6 @@ def test_rclone_sync(tmp_path: Path):
8382
Parameters:
8483
tmp_path (Path): Temporary path to use for the test
8584
"""
86-
8785
local_path = tmp_path.joinpath("local_path")
8886
local_path.mkdir()
8987
dest_path = tmp_path.joinpath("destination")
@@ -109,10 +107,7 @@ def test_rclone_sync(tmp_path: Path):
109107

110108

111109
if __name__ == "__main__":
112-
data_path = pkg_resources.resource_filename('pyrclone', '*/rlcone.exe')
113-
print(data_path)
114-
print(data_path)
115-
tmp_path = Path("C:\\tmp\\rclone_test")
110+
tmp_path = Path("/tmp/pyrclone_test")
116111
# test rclone sync on local
117112
shutil.rmtree(tmp_path, ignore_errors=True)
118113
tmp_path.mkdir(exist_ok=True)

0 commit comments

Comments
 (0)