Skip to content

Commit 2014343

Browse files
committed
Merge branch 'release/v1.2.1b1'
2 parents 1790c08 + 0206f63 commit 2014343

File tree

6 files changed

+54
-13
lines changed

6 files changed

+54
-13
lines changed

BUILD.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
1-
# Building
1+
# How to build and upload to PyPI
2+
3+
## Build
24

35
```
4-
python setup.py sdist
5-
python setup.py bdist_wheel
6+
python -m build
7+
twine check dist/*
68
```
79

8-
# Uploading
10+
## Upload
11+
12+
### 1. Configuring the API token
13+
14+
Generate an API token at https://pypi.org/manage/account/ and then save the following to `$HOME/.pypirc`:
15+
16+
[distutils]
17+
index-servers =
18+
py3createtorrent
19+
20+
[py3createtorrent]
21+
repository = https://upload.pypi.org/legacy/
22+
username = __token__
23+
password = <INSERT API TOKEN HERE>
24+
25+
### 2. Executing the upload
926

1027
```
11-
twine upload --skip-existing dist/*
28+
twine upload --skip-existing --repository py3createtorrent dist/*
1229
twine upload --skip-existing --repository testpypi dist/*
1330
```
1431

15-
# Testing
32+
## Test `pip install`
1633

1734
```sh
1835
pip install py3createtorrent
1936
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple py3createtorrent
20-
```
37+
```

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ faker = "*"
1515
pydocstyle = "*"
1616
pylint = "*"
1717
pyright = "~=1.1.339"
18+
build = "*"
1819

1920
[packages]
2021
"bencode.py" = "~=4.0"

docs/source/changelog.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Changelog
22
=========
33

4+
Version 1.2.0b1 (beta)
5+
----------------------
6+
7+
*Release date: 2024/02/13*
8+
9+
* Attempt to fix the UnicodeEncodeErrors (or similar) that occur when printing files/paths with rare characters that are not
10+
compatible with the console's codec. See `#33 <https://github.com/rsnitsch/py3createtorrent/issues/33>`_.
11+
412
Version 1.2.0
513
-------------
614

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
# The short X.Y version.
5151
version = '1.2'
5252
# The full version, including alpha/beta/rc tags.
53-
release = '1.2.0'
53+
release = '1.2.1b1'
5454

5555
# The language for content autogenerated by Sphinx. Refer to documentation
5656
# for a list of supported languages.

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def get_version(rel_path):
5252
"Programming Language :: Python :: 3.8",
5353
"Programming Language :: Python :: 3.9",
5454
"Programming Language :: Python :: 3.10",
55+
"Programming Language :: Python :: 3.11",
56+
"Programming Language :: Python :: 3.12",
5557
"Programming Language :: Python :: 3 :: Only",
5658
],
5759
# This field adds keywords for your project which will appear on the

src/py3createtorrent.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
# Do not touch anything below this line unless you know what you're doing!
4646

47-
__version__ = "1.2.0"
47+
__version__ = "1.2.1b1"
4848

4949
# Note:
5050
# Kilobyte = kB = 1000 Bytes
@@ -114,6 +114,17 @@ def load_config(self) -> None:
114114
"(must be true/false)" % self.best_trackers_url)
115115

116116

117+
def clean_str_for_console(path: str) -> str:
118+
"""
119+
Returns the string for printing to the console.
120+
121+
Non-printable characters are replaced by a backslashed escape sequence like \\xhh, \\uxxxx or \\Uxxxxxxxx.
122+
"""
123+
encoding = sys.stdout.encoding
124+
errors = "backslashreplace"
125+
return path.encode(encoding, errors).decode(encoding, errors)
126+
127+
117128
def printv(*args: Any, **kwargs: Any) -> None:
118129
"""If VERBOSE is True, act as an alias for print. Else do nothing."""
119130
if VERBOSE:
@@ -247,7 +258,7 @@ def calculate_sha1_hash_for_piece(i: int, piece_data: bytes) -> None:
247258
if include_md5:
248259
md5 = hashlib.md5()
249260

250-
printv("Processing file '%s'... " % os.path.relpath(path, directory), end="")
261+
printv("Processing file '%s'... " % clean_str_for_console(os.path.relpath(path, directory)), end="")
251262

252263
with open(path, "rb") as fh:
253264
while True:
@@ -377,13 +388,15 @@ def _get_files_in_directory(
377388
path = os.path.join(directory, node)
378389

379390
if os.path.normcase(path) in excluded_paths:
380-
printv("Skipping '%s' due to explicit exclusion." % os.path.relpath(path, relative_to))
391+
printv("Skipping '%s' due to explicit exclusion." %
392+
clean_str_for_console(os.path.relpath(path, relative_to)))
381393
continue
382394

383395
regexp_match = False
384396
for regexp in excluded_regexps:
385397
if regexp.search(path):
386-
printv("Skipping '%s' due to pattern exclusion." % os.path.relpath(path, relative_to))
398+
printv("Skipping '%s' due to pattern exclusion." %
399+
clean_str_for_console(os.path.relpath(path, relative_to)))
387400
regexp_match = True
388401
break
389402
if regexp_match:
@@ -392,7 +405,7 @@ def _get_files_in_directory(
392405
if os.path.normcase(os.path.realpath(path)) in processed_paths:
393406
print(
394407
"Warning: skipping symlink '%s', because it's target "
395-
"has already been processed." % path,
408+
"has already been processed." % clean_str_for_console(path),
396409
file=sys.stderr,
397410
)
398411
continue

0 commit comments

Comments
 (0)