rsrc


Namersrc JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/lycantropos/rsrc/
SummaryResources management (files/directories/etc.).
upload_time2020-10-26 11:51:18
maintainer
docs_urlNone
authorAzat Ibrakov
requires_python>=3.5.3
license
keywords
VCS
bugtrack_url
requirements memoir reprit
Travis-CI
coveralls test coverage No coveralls.
            rsrc
====

[![](https://travis-ci.com/lycantropos/rsrc.svg?branch=master)](https://travis-ci.com/lycantropos/rsrc "Travis CI")
[![](https://dev.azure.com/lycantropos/rsrc/_apis/build/status/lycantropos.rsrc?branchName=master)](https://dev.azure.com/lycantropos/rsrc/_build/latest?definitionId=4&branchName=master "Azure Pipelines")
[![](https://codecov.io/gh/lycantropos/rsrc/branch/master/graph/badge.svg)](https://codecov.io/gh/lycantropos/rsrc "Codecov")
[![](https://img.shields.io/github/license/lycantropos/rsrc.svg)](https://github.com/lycantropos/rsrc/blob/master/LICENSE "License")
[![](https://badge.fury.io/py/rsrc.svg)](https://badge.fury.io/py/rsrc "PyPI")

In what follows
- `python` is an alias for `python3.5` or any later
version (`python3.6` and so on),
- `pypy` is an alias for `pypy3.5` or any later
version (`pypy3.6` and so on).

Installation
------------

Install the latest `pip` & `setuptools` packages versions:
- with `CPython`
  ```bash
  python -m pip install --upgrade pip setuptools
  ```
- with `PyPy`
  ```bash
  pypy -m pip install --upgrade pip setuptools
  ```

### User

Download and install the latest stable version from `PyPI` repository:
- with `CPython`
  ```bash
  python -m pip install --upgrade rsrc
  ```
- with `PyPy`
  ```bash
  pypy -m pip install --upgrade rsrc
  ```

### Developer

Download the latest version from `GitHub` repository
```bash
git clone https://github.com/lycantropos/rsrc.git
cd rsrc
```

Install dependencies:
- with `CPython`
  ```bash
  python -m pip install --force-reinstall -r requirements.txt
  ```
- with `PyPy`
  ```bash
  pypy -m pip install --force-reinstall -r requirements.txt
  ```

Install:
- with `CPython`
  ```bash
  python setup.py install
  ```
- with `PyPy`
  ```bash
  pypy setup.py install
  ```

Usage
-----

The main idea is to use `setuptools` feature 
called ["Dynamic Discovery of Services and Plugins"](https://setuptools.readthedocs.io/en/latest/setuptools.html#dynamic-discovery-of-services-and-plugins).

Assuming we have a package `rsrc_ftp` with structure

    |_ rsrc_ftp.py
    |_ setup.py

which adds support for URLs with `ftp` scheme

`rsrc_ftp.py`
```python
from rsrc.models import Resource

def deserialize(string: str) -> Resource:
    ...
```

to make it available for `rsrc` package 
we should register its entry point 
(`rsrc_ftp::deserialize` function in our case)

`setup.py`
```python
from setuptools import setup

from rsrc import plugins

plugins_entry_points = [
    plugins.to_entry_point(id_=plugins.to_id('ftp'),
                           module_name='rsrc_ftp',
                           function_name='deserialize'),
]
setup(name='rsrc_ftp',
      py_modules=['rsrc_ftp'],
      entry_points={plugins.__name__: plugins_entry_points},
      install_requires=['rsrc'])
```

After that the installation of `rsrc_ftp` package 
will register `rsrc_ftp::deserialize` function in `rsrc` package 
as an entry point for resources with `ftp` scheme

```python
>>> from rsrc.base import deserialize
>>> ftp_resource = deserialize('ftp://path/to/resource')
>>> ftp_resource.url
URL('ftp', 'path', '/to/resource', '', '', '')
```

Plugins
-------

- [`rsrc_local`](https://pypi.org/project/rsrc_local) -- adds support for local/local network resources.
- [`rsrc_web`](https://pypi.org/project/rsrc_web) -- adds support for web resources (both `http` & `https` schemes).

Development
-----------

### Bumping version

#### Preparation

Install
[bump2version](https://github.com/c4urself/bump2version#installation).

#### Pre-release

Choose which version number category to bump following [semver
specification](http://semver.org/).

Test bumping version
```bash
bump2version --dry-run --verbose $CATEGORY
```

where `$CATEGORY` is the target version number category name, possible
values are `patch`/`minor`/`major`.

Bump version
```bash
bump2version --verbose $CATEGORY
```

This will set version to `major.minor.patch-alpha`. 

#### Release

Test bumping version
```bash
bump2version --dry-run --verbose release
```

Bump version
```bash
bump2version --verbose release
```

This will set version to `major.minor.patch`.

#### Notes

To avoid inconsistency between branches and pull requests,
bumping version should be merged into `master` branch 
as separate pull request.

### Running tests

Install dependencies:
- with `CPython`
  ```bash
  python -m pip install --force-reinstall -r requirements-tests.txt
  ```
- with `PyPy`
  ```bash
  pypy -m pip install --force-reinstall -r requirements-tests.txt
  ```

Plain
```bash
pytest
```

Inside `Docker` container:
- with `CPython`
  ```bash
  docker-compose --file docker-compose.cpython.yml up
  ```
- with `PyPy`
  ```bash
  docker-compose --file docker-compose.pypy.yml up
  ```

`Bash` script (e.g. can be used in `Git` hooks):
- with `CPython`
  ```bash
  ./run-tests.sh
  ```
  or
  ```bash
  ./run-tests.sh cpython
  ```

- with `PyPy`
  ```bash
  ./run-tests.sh pypy
  ```

`PowerShell` script (e.g. can be used in `Git` hooks):
- with `CPython`
  ```powershell
  .\run-tests.ps1
  ```
  or
  ```powershell
  .\run-tests.ps1 cpython
  ```
- with `PyPy`
  ```powershell
  .\run-tests.ps1 pypy
  ```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/lycantropos/rsrc/",
    "name": "rsrc",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5.3",
    "maintainer_email": "",
    "keywords": "",
    "author": "Azat Ibrakov",
    "author_email": "azatibrakov@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c3/1a/13dba27b96a2d6e95a454f1053d980e50513bb8283f6f449712a3b3d9635/rsrc-0.1.3.tar.gz",
    "platform": "",
    "description": "rsrc\n====\n\n[![](https://travis-ci.com/lycantropos/rsrc.svg?branch=master)](https://travis-ci.com/lycantropos/rsrc \"Travis CI\")\n[![](https://dev.azure.com/lycantropos/rsrc/_apis/build/status/lycantropos.rsrc?branchName=master)](https://dev.azure.com/lycantropos/rsrc/_build/latest?definitionId=4&branchName=master \"Azure Pipelines\")\n[![](https://codecov.io/gh/lycantropos/rsrc/branch/master/graph/badge.svg)](https://codecov.io/gh/lycantropos/rsrc \"Codecov\")\n[![](https://img.shields.io/github/license/lycantropos/rsrc.svg)](https://github.com/lycantropos/rsrc/blob/master/LICENSE \"License\")\n[![](https://badge.fury.io/py/rsrc.svg)](https://badge.fury.io/py/rsrc \"PyPI\")\n\nIn what follows\n- `python` is an alias for `python3.5` or any later\nversion (`python3.6` and so on),\n- `pypy` is an alias for `pypy3.5` or any later\nversion (`pypy3.6` and so on).\n\nInstallation\n------------\n\nInstall the latest `pip` & `setuptools` packages versions:\n- with `CPython`\n  ```bash\n  python -m pip install --upgrade pip setuptools\n  ```\n- with `PyPy`\n  ```bash\n  pypy -m pip install --upgrade pip setuptools\n  ```\n\n### User\n\nDownload and install the latest stable version from `PyPI` repository:\n- with `CPython`\n  ```bash\n  python -m pip install --upgrade rsrc\n  ```\n- with `PyPy`\n  ```bash\n  pypy -m pip install --upgrade rsrc\n  ```\n\n### Developer\n\nDownload the latest version from `GitHub` repository\n```bash\ngit clone https://github.com/lycantropos/rsrc.git\ncd rsrc\n```\n\nInstall dependencies:\n- with `CPython`\n  ```bash\n  python -m pip install --force-reinstall -r requirements.txt\n  ```\n- with `PyPy`\n  ```bash\n  pypy -m pip install --force-reinstall -r requirements.txt\n  ```\n\nInstall:\n- with `CPython`\n  ```bash\n  python setup.py install\n  ```\n- with `PyPy`\n  ```bash\n  pypy setup.py install\n  ```\n\nUsage\n-----\n\nThe main idea is to use `setuptools` feature \ncalled [\"Dynamic Discovery of Services and Plugins\"](https://setuptools.readthedocs.io/en/latest/setuptools.html#dynamic-discovery-of-services-and-plugins).\n\nAssuming we have a package `rsrc_ftp` with structure\n\n    |_ rsrc_ftp.py\n    |_ setup.py\n\nwhich adds support for URLs with `ftp` scheme\n\n`rsrc_ftp.py`\n```python\nfrom rsrc.models import Resource\n\ndef deserialize(string: str) -> Resource:\n    ...\n```\n\nto make it available for `rsrc` package \nwe should register its entry point \n(`rsrc_ftp::deserialize` function in our case)\n\n`setup.py`\n```python\nfrom setuptools import setup\n\nfrom rsrc import plugins\n\nplugins_entry_points = [\n    plugins.to_entry_point(id_=plugins.to_id('ftp'),\n                           module_name='rsrc_ftp',\n                           function_name='deserialize'),\n]\nsetup(name='rsrc_ftp',\n      py_modules=['rsrc_ftp'],\n      entry_points={plugins.__name__: plugins_entry_points},\n      install_requires=['rsrc'])\n```\n\nAfter that the installation of `rsrc_ftp` package \nwill register `rsrc_ftp::deserialize` function in `rsrc` package \nas an entry point for resources with `ftp` scheme\n\n```python\n>>> from rsrc.base import deserialize\n>>> ftp_resource = deserialize('ftp://path/to/resource')\n>>> ftp_resource.url\nURL('ftp', 'path', '/to/resource', '', '', '')\n```\n\nPlugins\n-------\n\n- [`rsrc_local`](https://pypi.org/project/rsrc_local) -- adds support for local/local network resources.\n- [`rsrc_web`](https://pypi.org/project/rsrc_web) -- adds support for web resources (both `http` & `https` schemes).\n\nDevelopment\n-----------\n\n### Bumping version\n\n#### Preparation\n\nInstall\n[bump2version](https://github.com/c4urself/bump2version#installation).\n\n#### Pre-release\n\nChoose which version number category to bump following [semver\nspecification](http://semver.org/).\n\nTest bumping version\n```bash\nbump2version --dry-run --verbose $CATEGORY\n```\n\nwhere `$CATEGORY` is the target version number category name, possible\nvalues are `patch`/`minor`/`major`.\n\nBump version\n```bash\nbump2version --verbose $CATEGORY\n```\n\nThis will set version to `major.minor.patch-alpha`. \n\n#### Release\n\nTest bumping version\n```bash\nbump2version --dry-run --verbose release\n```\n\nBump version\n```bash\nbump2version --verbose release\n```\n\nThis will set version to `major.minor.patch`.\n\n#### Notes\n\nTo avoid inconsistency between branches and pull requests,\nbumping version should be merged into `master` branch \nas separate pull request.\n\n### Running tests\n\nInstall dependencies:\n- with `CPython`\n  ```bash\n  python -m pip install --force-reinstall -r requirements-tests.txt\n  ```\n- with `PyPy`\n  ```bash\n  pypy -m pip install --force-reinstall -r requirements-tests.txt\n  ```\n\nPlain\n```bash\npytest\n```\n\nInside `Docker` container:\n- with `CPython`\n  ```bash\n  docker-compose --file docker-compose.cpython.yml up\n  ```\n- with `PyPy`\n  ```bash\n  docker-compose --file docker-compose.pypy.yml up\n  ```\n\n`Bash` script (e.g. can be used in `Git` hooks):\n- with `CPython`\n  ```bash\n  ./run-tests.sh\n  ```\n  or\n  ```bash\n  ./run-tests.sh cpython\n  ```\n\n- with `PyPy`\n  ```bash\n  ./run-tests.sh pypy\n  ```\n\n`PowerShell` script (e.g. can be used in `Git` hooks):\n- with `CPython`\n  ```powershell\n  .\\run-tests.ps1\n  ```\n  or\n  ```powershell\n  .\\run-tests.ps1 cpython\n  ```\n- with `PyPy`\n  ```powershell\n  .\\run-tests.ps1 pypy\n  ```\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Resources management (files/directories/etc.).",
    "version": "0.1.3",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ddbddbf959fd955653902548e73cfbf965f18f2bb195eb0aac6fce1c18c78e6e",
                "md5": "3a98ef867e97fc850a28af79dc5b901a",
                "sha256": "388d8c66b418fac33d19eb610bf40e5b49628b4af87a870b872f8507b4b9897a"
            },
            "downloads": -1,
            "filename": "rsrc-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3a98ef867e97fc850a28af79dc5b901a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5.3",
            "size": 7048,
            "upload_time": "2020-10-26T11:51:17",
            "upload_time_iso_8601": "2020-10-26T11:51:17.081025Z",
            "url": "https://files.pythonhosted.org/packages/dd/bd/dbf959fd955653902548e73cfbf965f18f2bb195eb0aac6fce1c18c78e6e/rsrc-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c31a13dba27b96a2d6e95a454f1053d980e50513bb8283f6f449712a3b3d9635",
                "md5": "595c45b464f80fd57ff07f7cce8eb165",
                "sha256": "bba4e58b4947db30cd5c6ac8f888f84d9deb1e1b8889c0d1b040f51d5b89996b"
            },
            "downloads": -1,
            "filename": "rsrc-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "595c45b464f80fd57ff07f7cce8eb165",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5.3",
            "size": 5891,
            "upload_time": "2020-10-26T11:51:18",
            "upload_time_iso_8601": "2020-10-26T11:51:18.226097Z",
            "url": "https://files.pythonhosted.org/packages/c3/1a/13dba27b96a2d6e95a454f1053d980e50513bb8283f6f449712a3b3d9635/rsrc-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-10-26 11:51:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "lycantropos",
    "github_project": "rsrc",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "memoir",
            "specs": [
                [
                    ">=",
                    "0.0.3"
                ]
            ]
        },
        {
            "name": "reprit",
            "specs": [
                [
                    ">=",
                    "0.3.0"
                ]
            ]
        }
    ],
    "lcname": "rsrc"
}
        
Elapsed time: 0.05842s