Resources management (files/directories/etc.).
Project description
rsrc
In what follows
pythonis an alias forpython3.5or any later version (python3.6and so on),pypyis an alias forpypy3.5or any later version (pypy3.6and so on).
Installation
Install the latest pip & setuptools packages versions:
- with
CPythonpython -m pip install --upgrade pip setuptools
- with
PyPypypy -m pip install --upgrade pip setuptools
User
Download and install the latest stable version from PyPI repository:
- with
CPythonpython -m pip install --upgrade rsrc
- with
PyPypypy -m pip install --upgrade rsrc
Developer
Download the latest version from GitHub repository
git clone https://github.com/lycantropos/rsrc.git
cd rsrc
Install dependencies:
- with
CPythonpython -m pip install --force-reinstall -r requirements.txt
- with
PyPypypy -m pip install --force-reinstall -r requirements.txt
Install:
- with
CPythonpython setup.py install
- with
PyPypypy setup.py install
Usage
The main idea is to use setuptools feature
called "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
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
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
>>> from rsrc.base import deserialize
>>> ftp_resource = deserialize('ftp://path/to/resource')
>>> ftp_resource.url
URL('ftp', 'path', '/to/resource', '', '', '')
Plugins
rsrc_local-- adds support for local/local network resources.rsrc_web-- adds support for web resources (bothhttp&httpsschemes).
Development
Bumping version
Preparation
Install bump2version.
Pre-release
Choose which version number category to bump following semver specification.
Test bumping version
bump2version --dry-run --verbose $CATEGORY
where $CATEGORY is the target version number category name, possible
values are patch/minor/major.
Bump version
bump2version --verbose $CATEGORY
This will set version to major.minor.patch-alpha.
Release
Test bumping version
bump2version --dry-run --verbose release
Bump version
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
CPythonpython -m pip install --force-reinstall -r requirements-tests.txt
- with
PyPypypy -m pip install --force-reinstall -r requirements-tests.txt
Plain
pytest
Inside Docker container:
- with
CPythondocker-compose --file docker-compose.cpython.yml up
- with
PyPydocker-compose --file docker-compose.pypy.yml up
Bash script (e.g. can be used in Git hooks):
-
with
CPython./run-tests.sh
or
./run-tests.sh cpython -
with
PyPy./run-tests.sh pypy
PowerShell script (e.g. can be used in Git hooks):
- with
CPython.\run-tests.ps1
or.\run-tests.ps1 cpython
- with
PyPy.\run-tests.ps1 pypy
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rsrc-0.1.3.tar.gz.
File metadata
- Download URL: rsrc-0.1.3.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.5.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bba4e58b4947db30cd5c6ac8f888f84d9deb1e1b8889c0d1b040f51d5b89996b
|
|
| MD5 |
595c45b464f80fd57ff07f7cce8eb165
|
|
| BLAKE2b-256 |
c31a13dba27b96a2d6e95a454f1053d980e50513bb8283f6f449712a3b3d9635
|
File details
Details for the file rsrc-0.1.3-py3-none-any.whl.
File metadata
- Download URL: rsrc-0.1.3-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.5.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
388d8c66b418fac33d19eb610bf40e5b49628b4af87a870b872f8507b4b9897a
|
|
| MD5 |
3a98ef867e97fc850a28af79dc5b901a
|
|
| BLAKE2b-256 |
ddbddbf959fd955653902548e73cfbf965f18f2bb195eb0aac6fce1c18c78e6e
|