From ce45da763e9d04c00b7efe3d99c5dea6b99d586e Mon Sep 17 00:00:00 2001 From: MusicalNinjaDad <102677655+MusicalNinjaDad@users.noreply.github.com> Date: Mon, 13 May 2024 21:35:01 +0200 Subject: [PATCH] Revert PRs #21, #22 (#23) This reverts commits c13288399ede2089f45f9d807f2ffede8f21aaa3 869663aa6641d3b88b0382a0985af7ac22e6c132 --- .devcontainer/devcontainer.json | 1 - .github/workflows/deploy-rust.yml | 1 - .github/workflows/python.yml | 2 +- CHANGELOG.md | 5 -- Cargo.toml | 2 +- __pyversion__ | 2 +- {fizzbuzz-rust => fizzbuzz}/Cargo.toml | 0 .../benches/bench_fizzbuzz.rs | 0 .../benches/results.md | 0 {fizzbuzz-rust => fizzbuzz}/src/lib.rs | 0 .../tests/test_numbertypes.rs | 0 {fizzbuzz-rust => fizzbuzz}/tests/test_vec.rs | 0 fizzbuzzo3/Cargo.toml | 2 +- .../fizzbuzzpy/__init__.py | 0 .../fizzbuzzpy/fizzbuzzer.py | 0 {tests => fizzbuzzpy/tests}/perf_results.md | 0 {tests => fizzbuzzpy/tests}/perftest.py | 4 +- .../tests}/test_fizzbuzzo3.py | 3 +- .../tests}/test_fizzbuzzpy.py | 2 +- pyproject.toml | 13 ++-- python/fizzbuzz/__init__.py | 0 python/fizzbuzz/fizzbuzzo3/__init__.pyi | 38 ---------- python/fizzbuzz/fizzbuzzo3/repl_notes.txt | 71 ------------------- 23 files changed, 15 insertions(+), 131 deletions(-) rename {fizzbuzz-rust => fizzbuzz}/Cargo.toml (100%) rename {fizzbuzz-rust => fizzbuzz}/benches/bench_fizzbuzz.rs (100%) rename {fizzbuzz-rust => fizzbuzz}/benches/results.md (100%) rename {fizzbuzz-rust => fizzbuzz}/src/lib.rs (100%) rename {fizzbuzz-rust => fizzbuzz}/tests/test_numbertypes.rs (100%) rename {fizzbuzz-rust => fizzbuzz}/tests/test_vec.rs (100%) rename {python/fizzbuzz => fizzbuzzpy}/fizzbuzzpy/__init__.py (100%) rename {python/fizzbuzz => fizzbuzzpy}/fizzbuzzpy/fizzbuzzer.py (100%) rename {tests => fizzbuzzpy/tests}/perf_results.md (100%) rename {tests => fizzbuzzpy/tests}/perftest.py (90%) rename {tests => fizzbuzzpy/tests}/test_fizzbuzzo3.py (97%) rename {tests => fizzbuzzpy/tests}/test_fizzbuzzpy.py (96%) delete mode 100644 python/fizzbuzz/__init__.py delete mode 100644 python/fizzbuzz/fizzbuzzo3/__init__.pyi delete mode 100644 python/fizzbuzz/fizzbuzzo3/repl_notes.txt diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index db953c1..2056121 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,5 +1,4 @@ { - // "image": "ghcr.io/musicalninjas/pyo3-devcontainer:latest", // untested with mac, expect issues due to x_64 rust installation "build": { "dockerfile": "Dockerfile", "args": { diff --git a/.github/workflows/deploy-rust.yml b/.github/workflows/deploy-rust.yml index 2a1927b..43cdcf2 100644 --- a/.github/workflows/deploy-rust.yml +++ b/.github/workflows/deploy-rust.yml @@ -1,4 +1,3 @@ -name: Deploy Rust concurrency: ADO-Cargo on: diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index b72e4ee..5cce806 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -39,7 +39,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install -e .[test] + python -m pip install -e .[dev] python -m pip install pytest-cov - name: Test with pytest run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 3af014f..1703437 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,5 @@ # FizzBuzz Changelog -## Python 2.0.0 - -- **Breaking:** Changed top level module name to `fizzbuzz`. Use `from fizzbuzz.fizzbuzzo3 import fizzbuzz` -for rust implementation or `from fizzbuzz.fizzbuzzpy import fizzbuzz` for python implementation (slower). - ## Rust 2.1.0 & Python 1.3.0 - Process `Vec`s / `list`s with more than 300k elements in parallel diff --git a/Cargo.toml b/Cargo.toml index b9dce7b..2632a29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [workspace] members = [ - "fizzbuzz-rust", + "fizzbuzz", "fizzbuzzo3" ] diff --git a/__pyversion__ b/__pyversion__ index 359a5b9..589268e 100644 --- a/__pyversion__ +++ b/__pyversion__ @@ -1 +1 @@ -2.0.0 \ No newline at end of file +1.3.0 \ No newline at end of file diff --git a/fizzbuzz-rust/Cargo.toml b/fizzbuzz/Cargo.toml similarity index 100% rename from fizzbuzz-rust/Cargo.toml rename to fizzbuzz/Cargo.toml diff --git a/fizzbuzz-rust/benches/bench_fizzbuzz.rs b/fizzbuzz/benches/bench_fizzbuzz.rs similarity index 100% rename from fizzbuzz-rust/benches/bench_fizzbuzz.rs rename to fizzbuzz/benches/bench_fizzbuzz.rs diff --git a/fizzbuzz-rust/benches/results.md b/fizzbuzz/benches/results.md similarity index 100% rename from fizzbuzz-rust/benches/results.md rename to fizzbuzz/benches/results.md diff --git a/fizzbuzz-rust/src/lib.rs b/fizzbuzz/src/lib.rs similarity index 100% rename from fizzbuzz-rust/src/lib.rs rename to fizzbuzz/src/lib.rs diff --git a/fizzbuzz-rust/tests/test_numbertypes.rs b/fizzbuzz/tests/test_numbertypes.rs similarity index 100% rename from fizzbuzz-rust/tests/test_numbertypes.rs rename to fizzbuzz/tests/test_numbertypes.rs diff --git a/fizzbuzz-rust/tests/test_vec.rs b/fizzbuzz/tests/test_vec.rs similarity index 100% rename from fizzbuzz-rust/tests/test_vec.rs rename to fizzbuzz/tests/test_vec.rs diff --git a/fizzbuzzo3/Cargo.toml b/fizzbuzzo3/Cargo.toml index 9186a22..6a32229 100644 --- a/fizzbuzzo3/Cargo.toml +++ b/fizzbuzzo3/Cargo.toml @@ -10,6 +10,6 @@ crate-type = ["cdylib"] # cdylib required for python import, rlib required for [dependencies] pyo3 = { git = "https://github.com/MusicalNinjaDad/pyo3.git", branch = "pyo3-testing" } -fizzbuzz = { path = "../fizzbuzz-rust" } +fizzbuzz = { path = "../fizzbuzz" } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/python/fizzbuzz/fizzbuzzpy/__init__.py b/fizzbuzzpy/fizzbuzzpy/__init__.py similarity index 100% rename from python/fizzbuzz/fizzbuzzpy/__init__.py rename to fizzbuzzpy/fizzbuzzpy/__init__.py diff --git a/python/fizzbuzz/fizzbuzzpy/fizzbuzzer.py b/fizzbuzzpy/fizzbuzzpy/fizzbuzzer.py similarity index 100% rename from python/fizzbuzz/fizzbuzzpy/fizzbuzzer.py rename to fizzbuzzpy/fizzbuzzpy/fizzbuzzer.py diff --git a/tests/perf_results.md b/fizzbuzzpy/tests/perf_results.md similarity index 100% rename from tests/perf_results.md rename to fizzbuzzpy/tests/perf_results.md diff --git a/tests/perftest.py b/fizzbuzzpy/tests/perftest.py similarity index 90% rename from tests/perftest.py rename to fizzbuzzpy/tests/perftest.py index 208257c..ff25568 100644 --- a/tests/perftest.py +++ b/fizzbuzzpy/tests/perftest.py @@ -1,8 +1,8 @@ # ruff: noqa import timeit -from fizzbuzz.fizzbuzzo3 import fizzbuzz as fbo3 -from fizzbuzz.fizzbuzzpy import fizzbuzz as fbpy +from fizzbuzzo3 import fizzbuzz as fbo3 +from fizzbuzzpy import fizzbuzz as fbpy REPEAT = 1 diff --git a/tests/test_fizzbuzzo3.py b/fizzbuzzpy/tests/test_fizzbuzzo3.py similarity index 97% rename from tests/test_fizzbuzzo3.py rename to fizzbuzzpy/tests/test_fizzbuzzo3.py index 80c5572..a2cb30e 100644 --- a/tests/test_fizzbuzzo3.py +++ b/fizzbuzzpy/tests/test_fizzbuzzo3.py @@ -1,5 +1,6 @@ import pytest -from fizzbuzz.fizzbuzzo3 import fizzbuzz + +from fizzbuzzo3 import fizzbuzz def test_lazy(): diff --git a/tests/test_fizzbuzzpy.py b/fizzbuzzpy/tests/test_fizzbuzzpy.py similarity index 96% rename from tests/test_fizzbuzzpy.py rename to fizzbuzzpy/tests/test_fizzbuzzpy.py index fd002e2..2df06e8 100644 --- a/tests/test_fizzbuzzpy.py +++ b/fizzbuzzpy/tests/test_fizzbuzzpy.py @@ -1,4 +1,4 @@ -from fizzbuzz.fizzbuzzpy import fizzbuzz +from fizzbuzzpy import fizzbuzz def test_lazy(): diff --git a/pyproject.toml b/pyproject.toml index 201c712..6dbe7f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,14 +30,14 @@ Issues = "https://github.com/MusicalNinjaDad/fizzbuzz/issues" version = { file = "__pyversion__" } [tool.setuptools.packages.find] -where = ["python"] +where = ["fizzbuzzpy"] [[tool.setuptools-rust.ext-modules]] # Private Rust extension module to be nested into the Python package -target = "fizzbuzz.fizzbuzzo3" # The last part of the name (e.g. "_lib") has to match lib.name in Cargo.toml, +target = "fizzbuzzo3" # The last part of the name (e.g. "_lib") has to match lib.name in Cargo.toml, # but you can add a prefix to nest it inside of a Python package. -path = "fizzbuzzo3/Cargo.toml" -binding = "PyO3" +path = "fizzbuzzo3/Cargo.toml" # Default value, can be omitted +binding = "PyO3" # Default value, can be omitted features = ["pyo3/extension-module"] [tool.cibuildwheel] @@ -72,13 +72,12 @@ xfail_strict = true addopts = [ "--doctest-modules", "--doctest-mdcodeblocks", - "--doctest-glob=*.md", - "--doctest-glob=*.pyi", + "--doctest-glob='*.md'", ] [tool.coverage.run] branch = true -omit = ["test_*", "tests/*"] +omit = ["test_*"] dynamic_context = "test_function" [tool.ruff] diff --git a/python/fizzbuzz/__init__.py b/python/fizzbuzz/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/python/fizzbuzz/fizzbuzzo3/__init__.pyi b/python/fizzbuzz/fizzbuzzo3/__init__.pyi deleted file mode 100644 index 15a702e..0000000 --- a/python/fizzbuzz/fizzbuzzo3/__init__.pyi +++ /dev/null @@ -1,38 +0,0 @@ -# ruff: noqa: PYI021 -def fizzbuzz(n: int | list[int]) -> str: - """ - Compute the fizzbuzz answer for `n` using a highly efficient algorithm written in rust. - - The correct fizzbuzz answer is the original number, unless divisible by 3 or 5. - For numbers divisible by 3, the correct answer is 'fizz'. - For numbers divisible by 5, the correct answer is 'buzz'. - For numbers divisible by both 3 & 5, the correct answer is 'fizzbuzz'. - - **Note:** Passing a `list` of values to fizzbuzz is more efficient than making multiple calls. - Larger lists will be processed in parallel on multiple cpu cores. - - Arguments: - n: either `int` the single number to fizzbuzz or `list[int]` a list of numbers to fizzbuzz. - - Returns: - A string representing the fizzbuzz result. If `n` is an integer, the string contains the fizzbuzz - answer for that number. If `n` is a list of integers, the string contains the fizzbuzz answers for each number, - separated by commas and spaces (`, `). - - Examples: - Using a single value: - ``` - >>> from fizzbuzz.fizzbuzzo3 import fizzbuzz - >>> fizzbuzz(1) - '1' - >>> fizzbuzz(5) - 'buzz' - ``` - - Using a list: - ``` - >>> from fizzbuzz.fizzbuzzo3 import fizzbuzz - >>> fizzbuzz([1, 5]) - '1, buzz' - ``` - """ diff --git a/python/fizzbuzz/fizzbuzzo3/repl_notes.txt b/python/fizzbuzz/fizzbuzzo3/repl_notes.txt deleted file mode 100644 index d5f3ecf..0000000 --- a/python/fizzbuzz/fizzbuzzo3/repl_notes.txt +++ /dev/null @@ -1,71 +0,0 @@ -Python 3.12.3 (main, Apr 17 2024, 00:00:00) [GCC 14.0.1 20240411 (Red Hat 14.0.1-0)] on linux -Type "help", "copyright", "credits" or "license" for more information. ->>> import fizzbuzz.fizzbuzzo3 as fb -Traceback (most recent call last): - File "", line 1, in -ModuleNotFoundError: No module named 'fizzbuzz.fizzbuzzo3' ->>> import fizzbuzz.fizzbuzzpy.fizzbuzzo3 as fb -Traceback (most recent call last): - File "", line 1, in -ModuleNotFoundError: No module named 'fizzbuzz.fizzbuzzpy' ->>> import fizzbuzzpy.fizzbuzzo3 as fb ->>> fb.fizzbuzz.__doc__ ->>> fb.fizzbuzz - ->>> dict(fb.fizzbuzz) -Traceback (most recent call last): - File "", line 1, in -TypeError: 'builtin_function_or_method' object is not iterable ->>> fb.fizzbuzz.__dict__ -Traceback (most recent call last): - File "", line 1, in -AttributeError: 'builtin_function_or_method' object has no attribute '__dict__'. Did you mean: '__dir__'? ->>> fb.fizzbuzz.__dir__ - ->>> fb.fizzbuzz.__dir__() -['__repr__', '__hash__', '__call__', '__getattribute__', '__lt__', '__le__', '__eq__', '__ne__', '__gt__', '__ge__', '__reduce__', '__module__', '__doc__', '__name__', '__qualname__', '__self__', '__text_signature__', '__new__', '__str__', '__setattr__', '__delattr__', '__init__', '__reduce_ex__', '__getstate__', '__subclasshook__', '__init_subclass__', '__format__', '__sizeof__', '__dir__', '__class__'] ->>> fb.fizzbuzz.__text_signature__() -Traceback (most recent call last): - File "", line 1, in -TypeError: 'str' object is not callable ->>> fb.fizzbuzz.__text_signature__ -'(num)' ->>> fb._dir__() -Traceback (most recent call last): - File "", line 1, in -AttributeError: module 'fizzbuzzpy.fizzbuzzo3' has no attribute '_dir__' ->>> import ast ->>> dir(fb) -['__all__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'fizzbuzz'] ->>> type(fb.fizzbuzz) - ->>> type(type(fb.fizzbuzz)) - ->>> type(fb.fizzbuzz) == builtin_function_or_method -Traceback (most recent call last): - File "", line 1, in -NameError: name 'builtin_function_or_method' is not defined ->>> type(fb.fizzbuzz) == type('builtin_function_or_method') -False ->>> type(fb.fizzbuzz) == 'builtin_function_or_method' -False ->>> isinstance(fb.fizzbuzz, builtin_function_or_method) -Traceback (most recent call last): - File "", line 1, in -NameError: name 'builtin_function_or_method' is not defined ->>> import types.builtin_function_or_method -Traceback (most recent call last): - File "", line 1, in -ModuleNotFoundError: No module named 'types.builtin_function_or_method'; 'types' is not a package ->>> import types ->>> isinstance(fb.fizzbuzz, types.builtin_function_or_method) -Traceback (most recent call last): - File "", line 1, in -AttributeError: module 'types' has no attribute 'builtin_function_or_method' ->>> isinstance(fb.fizzbuzz, types.BuiltinFunctionType) -True ->>> import types.BuiltinFunctionType as builtin -Traceback (most recent call last): - File "", line 1, in -ModuleNotFoundError: No module named 'types.BuiltinFunctionType'; 'types' is not a package ->>> \ No newline at end of file