Skip to content

Commit

Permalink
Merge branch 'release/v1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rsnitsch committed Jan 2, 2024
2 parents 414cc0b + 8f11110 commit 1790c08
Show file tree
Hide file tree
Showing 20 changed files with 1,029 additions and 1,189 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
51 changes: 51 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Lint

on:
push:
branches:
- develop
pull_request:

jobs:
pyright:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]
fail-fast: false
steps:
- name: Checkout code
uses: actions/[email protected]

- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install pipenv
run: python3 -m pip install --upgrade pipenv wheel --break-system-packages

- name: Install Deps from Pipfile
run: pipenv install --dev

- name: Add Virtualenv to Path for Pyright to use
run: echo "$(pipenv --venv)/bin" >> $GITHUB_PATH

- name: Run pyright (Linux)
uses: jakebailey/[email protected]
with:
python-version: ${{ matrix.python-version }}
python-platform: Linux
no-comments: true
warnings: true

- name: Run pyright (Windows)
uses: jakebailey/[email protected]
# run anyway
if: success() || failure()
with:
version: ${{ env.PYRIGHT_VERSION }}
python-version: ${{ matrix.python-version }}
python-platform: Windows
no-comments: true
warnings: true
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"microsoft.python",
"eeyore.yapf",
"ms-python.mypy-type-checker",
"swyddfa.esbonio"
]
}
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"esbonio.sphinx.confDir": "",
"python.formatting.provider": "none",
"[python]": {
"editor.formatOnSaveMode": "file",
"editor.formatOnSave": true,
"editor.defaultFormatter": "eeyore.yapf"
},
"mypy-type-checker.args": [
"--follow-imports=silent",
"--ignore-missing-imports",
"--show-column-numbers",
"--no-pretty",
"--strict"
]
}
5 changes: 3 additions & 2 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Robert Nitsch
Charlie Unfricht
Robert Nitsch @rsnitsch
Charlie Unfricht @cpurules
@ToasterUwU
6 changes: 6 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# Building

```
python setup.py sdist
python setup.py bdist_wheel
```

# Uploading

```
twine upload --skip-existing dist/*
twine upload --skip-existing --repository testpypi dist/*
```

# Testing

```sh
pip install py3createtorrent
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple py3createtorrent
```
4 changes: 2 additions & 2 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Expand All @@ -8,5 +8,5 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
9 changes: 6 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
sphinx = "~=3.1"
mypy = "~=0.782"
yapf = "~=0.30"
sphinx = "~=7.2"
mypy = "~=1.8"
yapf = "~=0.40"
twine = "*"
matplotlib = "*"
pandas = "*"
torf-cli = {file = "https://github.com/rndusr/torf-cli/archive/refs/heads/master.zip"}
faker = "*"
pydocstyle = "*"
pylint = "*"
pyright = "~=1.1.339"

[packages]
"bencode.py" = "~=4.0"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ from [ngosang/trackerslist](https://github.com/ngosang/trackerslist). Example:

Multiple trackers can also be specified manually by using `-t` multiple times, for example:

py3createtorrent -t udp://tracker.opentrackr.org:1337/announce -t udp://tracker.coppersurfer.tk:6969/announce file_or_folder
py3createtorrent -t udp://tracker.opentrackr.org:1337/announce -t udp://tracker.cyberia.is:6969/announce file_or_folder

Install
-------
Expand Down
15 changes: 11 additions & 4 deletions benchmark/create_random_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,30 @@ def main():
parser.add_argument(
"size",
type=parse_size,
help="size in KiB/MiB/GiB, specify unit with a single suffix letter K/M/G, for example 256k for 256 KiB")
help="size in KiB/MiB/GiB, specify unit with a single suffix letter K/M/G, for example 256k for 256 KiB",
)
parser.add_argument("--seed", type=int, default=0, help="Set seed for the random number generator.")
parser.add_argument("--overwrite", action="store_true", help="Overwrite existing file.")

args = parser.parse_args()

if os.path.isfile(args.path) and not args.overwrite:
if os.path.getsize(args.path) != args.size:
print("ERROR: Destination file already exists BUT DOES NOT HAVE THE CORRECT SIZE", file=sys.stderr)
print(
"ERROR: Destination file already exists BUT DOES NOT HAVE THE CORRECT SIZE",
file=sys.stderr,
)
else:
print("WARNING: Destination file already exists (already has the requested size)", file=sys.stderr)
print(
"WARNING: Destination file already exists (already has the requested size)",
file=sys.stderr,
)
print("Not doing anything. Use --overwrite option to force overwriting the existing file.")
sys.exit(1)

random.seed(args.seed)
create_random_file(args.path, args.size)


if __name__ == '__main__':
if __name__ == "__main__":
main()
12 changes: 8 additions & 4 deletions benchmark/create_random_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import random
from pathlib import Path

from create_random_file import parse_size, create_random_file
from create_random_file import create_random_file, parse_size
from faker import Faker


Expand All @@ -34,11 +34,15 @@ def main():
"min_file_size",
type=parse_size,
help=
"minimum file size in KiB/MiB/GiB, specify unit with a single suffix letter K/M/G, for example 256k for 256 KiB"
"minimum file size in KiB/MiB/GiB, specify unit with a single suffix letter K/M/G, for example 256k for 256 KiB",
)
parser.add_argument("max_file_size", type=parse_size, help="maximum file size")
parser.add_argument("--seed", type=int, default=0, help="Set seed for the random number generator.")
parser.add_argument("--no-cachedir-tag", action="store_true", help="Do not generate CACHEDIR.TAG file")
parser.add_argument(
"--no-cachedir-tag",
action="store_true",
help="Do not generate CACHEDIR.TAG file",
)

args = parser.parse_args()

Expand All @@ -61,5 +65,5 @@ def main():
create_random_file(args.path.joinpath(filename), size)


if __name__ == '__main__':
if __name__ == "__main__":
main()
32 changes: 21 additions & 11 deletions benchmark/plot_benchmark_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ def generate_plot_for_piece_size(df, piece_size):
df = df[df["parameter_piece_size"] == piece_size].copy()
df = df.drop(columns="parameter_piece_size")

TOOLS = ["py3createtorrent", "torrenttools", "torf", "mktorrent", "transmission-create"]
TOOLS = [
"py3createtorrent",
"torrenttools",
"torf",
"mktorrent",
"transmission-create",
]

for tool in TOOLS:
df.loc[df["command"].str.contains(tool), "tool"] = tool
Expand All @@ -23,26 +29,26 @@ def generate_plot_for_piece_size(df, piece_size):

fig, ax = plt.subplots(1, 1, figsize=(8, 6))

for idx, tool in enumerate(tools):
for _, tool in enumerate(tools):
mean = df.loc[df.index.get_level_values(1) == tool, "mean"]
stddev = df.loc[df.index.get_level_values(1) == tool, "stddev"]
# stddev = df.loc[df.index.get_level_values(1) == tool, "stddev"]
ax.plot(threads, mean)
#ax.errorbar(threads, mean, stddev, linestyle='None', marker='x')
# ax.errorbar(threads, mean, stddev, linestyle='None', marker='x')

fig.suptitle("Performance (lower = faster)", fontsize=20)
ax.set_title("Piece size = %d KiB" % piece_size)
ax.set_xlabel("Number of threads for hashing")
ax.set_ylabel("Time in s")
ax.set_xticks(list(range(1, max_threads + 1)))
ax.legend(tools, loc='upper right')
ax.legend(tools, loc="upper right")

fig.savefig("plot_for_piece_size_%dk.png" % piece_size, dpi=125)
plt.close(fig)


def main():
parser = argparse.ArgumentParser()
parser.add_argument("results_file", help="path to CSV file with the results", nargs='+')
parser.add_argument("results_file", help="path to CSV file with the results", nargs="+")

args = parser.parse_args()

Expand All @@ -58,20 +64,24 @@ def main():
else:
df = pd.concat([df, df_file])

if df is None:
raise Exception("No DataFrame available, cant continue")

# Normalize piece sizes
#print(df[df["command"].str.contains("torf")].head())
# print(df[df["command"].str.contains("torf")].head())
df.loc[df["command"].str.contains("torf"), "parameter_piece_size"] *= 2**10
df.loc[df["command"].str.contains("mktorrent"), "parameter_piece_size"] = 2**(df.loc[df["command"].str.contains("mktorrent"), "parameter_piece_size"] - 10)
df.loc[df["command"].str.contains("mktorrent"),
"parameter_piece_size"] = 2**(df.loc[df["command"].str.contains("mktorrent"), "parameter_piece_size"] - 10)

#print(df)
# print(df)
piece_sizes = df["parameter_piece_size"].unique()

plt.style.use('ggplot')
plt.style.use("ggplot")
for p in piece_sizes:
print("Generating plot for piece size %s" % p)
generate_plot_for_piece_size(df.copy(), p)
print()


if __name__ == '__main__':
if __name__ == "__main__":
main()
16 changes: 15 additions & 1 deletion docs/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
Changelog
=========

Version 1.2.0
-------------

*Release date: 2024/01/02*

* added: py3createtorrent **can now be used as a Python module**. This extension was contributed by `@ToasterUwu <https://github.com/ToasterUwU>`_.
* changed: the automatic piece size calculation now uses a **larger maximum piece size of 64 MiB** (previously 16 MiB was the maximum).
* changed: **switched to LGPL license** to accomodate usage as a module.
* changed: removed coppersurfer tracker from default config (tracker abbreviations) and also removed all mentions of coppersurfer in the docs. It seems
that this tracker has been taken offline a long time ago.
* internal: configured GitHub Workflows for automatic dependency updates and code checks. This was contributed by
`@ToasterUwu <https://github.com/ToasterUwU>`_.

Version 1.1.0
-------------

*Release date: 2022/03/18*

* added: **multithreading** for much faster torrent creation (about 30-40% faster). The number of threads can be controlled with the new ``--threads`` option. It defaults to using 4 threads which will be a good choice on most systems.
* added: **multithreading** for much faster torrent creation (about 30-40% faster). The number of threads can be controlled with the new ``--threads``
option. It defaults to using 4 threads which will be a good choice on most systems.
* added: ``--version`` command
* improved: formatting and content of ``--help`` output

Expand Down
Loading

0 comments on commit 1790c08

Please sign in to comment.