diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/python-package.yml similarity index 100% rename from .github/workflows/pythonpackage.yml rename to .github/workflows/python-package.yml diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 000000000..c8b26769e --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,34 @@ +name: Publish Package + +on: + release: + types: [created] + +jobs: + publish: + runs-on: ubuntu-latest + name: "Publish library" + steps: + - name: Check out + uses: actions/checkout@v3 + with: + token: "${{ secrets.GITHUB_TOKEN }}" + fetch-depth: 0 + + - name: Setup Python Env + uses: actions/setup-python@v3 + with: + python-version: '3.9' + + - name: Install dependencies + run: | + pip install poetry + poetry version $(dunamai from any --no-metadata --style pep440) + poetry install + + - name: Build package + run: poetry build + + - name: Release to PyPI + run: | + poetry publish -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} || echo 'Version exists' \ No newline at end of file diff --git a/README.rst b/README.rst index 74e970b77..f0dfba9bd 100644 --- a/README.rst +++ b/README.rst @@ -10,8 +10,8 @@ The ReactiveX for Python (RxPY) :target: https://coveralls.io/github/ReactiveX/RxPY :alt: Coverage Status -.. image:: https://img.shields.io/pypi/v/rx.svg - :target: https://pypi.python.org/pypi/Rx +.. image:: https://img.shields.io/pypi/v/reactivex.svg + :target: https://pypi.org/project/reactivex/ :alt: PyPY Package Version .. image:: https://img.shields.io/readthedocs/rxpy.svg @@ -22,13 +22,14 @@ The ReactiveX for Python (RxPY) *A library for composing asynchronous and event-based programs using observable collections and query operator functions in Python* -ReactiveX for Python (RxPY) v4.0 --------------------------------- +ReactiveX for Python v4 +----------------------- -For v3.X please go to the `v3 branch `_. +For v3.X please go to the `v3 branch +`_. -RxPY v4.x runs on `Python `_ 3.7 or above. To install -RxPY: +ReactiveX for Python v4.x runs on `Python `_ 3.7 or above. To +install: .. code:: console @@ -46,10 +47,10 @@ streams using Schedulers. .. code:: python - import reactivex + import reactivex as rx from reactivex import operators as ops - source = reactivex.of("Alpha", "Beta", "Gamma", "Delta", "Epsilon") + source = rx.of("Alpha", "Beta", "Gamma", "Delta", "Epsilon") composed = source.pipe( ops.map(lambda s: len(s)), @@ -63,7 +64,7 @@ Learning ReactiveX Read the `documentation `_ to learn -the principles of RxPY and get the complete reference of the available +the principles of ReactiveX and get the complete reference of the available operators. If you need to migrate code from RxPY v1.x, read the `migration @@ -98,8 +99,8 @@ over `1300 passing unit-tests `_. Rx is mostly a direct port of RxJS, but also borrows a bit from Rx.NET and RxJava in terms of threading and blocking operators. -RxPY follows `PEP 8 `_, so all -function and method names are lowercase with words separated by underscores as +ReactiveX for Python follows `PEP 8 `_, so +all function and method names are lowercase with words separated by underscores as necessary to improve readability. Thus .NET code such as: @@ -115,7 +116,42 @@ need to be written with an ``_`` in Python: group = source.pipe(ops.group_by(lambda i: i % 3)) -With RxPY you should use `named keyword arguments -`_ instead of positional arguments when -an operator has multiple optional arguments. RxPY will not try to detect which -arguments you are giving to the operator (or not). +With ReactiveX for Python you should use `named keyword arguments +`_ instead of positional arguments when an +operator has multiple optional arguments. RxPY will not try to detect which arguments +you are giving to the operator (or not). + +Development +----------- + +This project is managed using `Poetry `_. Code is formatted +using `Black `_, `isort +`_. Code is statically type checked using `pyright +`_ and `mypy `_. + +If you want to take advantage of the default VSCode integration, then +first configure Poetry to make its virtual environment in the +repository: + +.. code:: console + + poetry config virtualenvs.in-project true + +After cloning the repository, activate the tooling: + +.. code:: console + + poetry install + poetry run pre-commit install + +Run unit tests: + +.. code:: console + + poetry run pytest + +Run code checks (manually): + +.. code:: console + + poetry run pre-commit run --all-files diff --git a/docs/migration.rst b/docs/migration.rst index d2be4b9e7..aa7750d54 100644 --- a/docs/migration.rst +++ b/docs/migration.rst @@ -3,7 +3,7 @@ Migration v4 ============ -ReactiveX for Python v4 is an evolution of RxPY v3 to modenize it to +ReactiveX for Python v4 is an evolution of RxPY v3 to modernize it to current Python standards: - Project main module renamed from ``rx`` to ``reactivex``. This is done diff --git a/poetry.lock b/poetry.lock index 783e69bc5..07b094258 100644 --- a/poetry.lock +++ b/poetry.lock @@ -144,6 +144,18 @@ category = "dev" optional = false python-versions = "*" +[[package]] +name = "dunamai" +version = "1.9.0" +description = "Dynamic version generation" +category = "dev" +optional = false +python-versions = ">=3.5,<4.0" + +[package.dependencies] +importlib-metadata = {version = ">=1.6.0", markers = "python_version < \"3.8\""} +packaging = ">=20.9" + [[package]] name = "execnet" version = "1.9.0" @@ -574,7 +586,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest- [metadata] lock-version = "1.1" python-versions = ">= 3.7, < 3.11" -content-hash = "af631dfae0ca793809672d35ec560db5a3a94e6cfbcb478f2b3bd9f75f12aeb5" +content-hash = "8958e5eaed6c6921a8962625ef6e57537908d0377e5d7146f7eadb9230f55cf7" [metadata.files] atomicwrites = [ @@ -687,6 +699,10 @@ distlib = [ docopt = [ {file = "docopt-0.6.2.tar.gz", hash = "sha256:49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491"}, ] +dunamai = [ + {file = "dunamai-1.9.0-py3-none-any.whl", hash = "sha256:89213a9c1176313cdfda7091a15c6d94be8c17b25e57a8c1e2ecf10d902b25d2"}, + {file = "dunamai-1.9.0.tar.gz", hash = "sha256:284dc9acbd3d6b749440332e46164f64b207c56eaf4af412d856cf9f08978932"}, +] execnet = [ {file = "execnet-1.9.0-py2.py3-none-any.whl", hash = "sha256:a295f7cc774947aac58dde7fdc85f4aa00c42adf5d8f5468fc630c1acf30a142"}, {file = "execnet-1.9.0.tar.gz", hash = "sha256:8f694f3ba9cc92cab508b152dcfe322153975c29bda272e2fd7f3f00f36e47c5"}, diff --git a/pyproject.toml b/pyproject.toml index ac4129348..9739ee765 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] -name = "reactivex" -version = "4.0.0a4" # Make sure the version here is the same as in _version.py +name = "ReactiveX" +version = "0.0.0" description = "ReactiveX (Rx) for Python" readme = "README.rst" authors = ["Dag Brattli "] @@ -43,6 +43,7 @@ flake8 = "^4.0.1" coveralls = "^3.3.1" pre-commit = "^2.17.0" autoflake = "^1.4" +dunamai = "^1.9.0" [tool.black] line-length = 88 diff --git a/reactivex/_version.py b/reactivex/_version.py index e8e0f0bbf..de785a4ad 100644 --- a/reactivex/_version.py +++ b/reactivex/_version.py @@ -1,2 +1 @@ -# Please make sure the version here remains the same as in pyproject.toml -__version__ = "4.0.0a4" +__version__ = "$(dunamai from any)"