Skip to content

Commit e151da2

Browse files
committed
2.1.0 Added human_name, refactored setuppy + more
**New features:** - Added new function `human_name` to `helpers.common` which humanises a function/class name - Converted `setuppy.py` into a python module folder at `setuppy/` - Added new distutils extras: - `extras/setuppy.txt` to cover all setuppy optional requirements - `extras/docs.txt` contains requirements for building the Sphinx documentation - `extras/dev.txt` is a meta-extra which includes all extra requirements for development via `full`, `docs` and `tests` - Created `privex.helpers.setuppy.bump` - Most notably, this module contains a function `bump_version` which uses the package `semver` to bump a version number. The version number is extracted from a python package file configured in `settings.VERSION_FILE` and after it's updated, the file containing the version is automatically updated with the new version number. - Created `privex.helpers.setuppy.commands` which contains setup.py / distutils command classes - `BumpCommand` is a command class which allows you to bump the version of a python package, including updating the file containing the version, simply by running a command such as `./setup.py bump --minor` - `ExtrasCommand` is a command class which helps with managing your package's `extra_require` by offering these features: - With no arguments, `./setup.py extras` would output a list of all requirements listed for each extra in your `extras_require` - With the `--save=somefile.txt` argument, the requirements can be outputted into a file - With the `--install` argument, the requirements will be installed with `pip` using the python version which is running setup.py - With the `--extra=myextra` argument, only requirements for that individual extra will be listed/saved/installed - Added unit tests for `human_name` in `tests/test_general.py` - Created `tests/test_net.py` for network related unit tests **General changes / improvements:** - Added `__all__` to some modules, to reduce un-necessary objects being imported when you do wildcard imports such as `from privex.helpers import *` - Moved `EXTRAS_FOLDER` into helpers.settings for consistency and easier changing - Moved the various requirements.txt / extras related functions from `setuppy.py` into `helpers.setuppy.common` - Moved network related tests from `test_general.py` into the new `test_net.py` - The `setup.py` used for privex-helpers itself now has the commands `bump` and `extras` available, which uses the new command classes from `privex.helpers.setuppy.commands` - The file `privex/helpers/__init__.py` now imports `privex.loghelper` inside of a try/except block, so if for some strange reason `privex-loghelper` isn't installed or is broken, then it will fallback to standard `logging.getLogger` instead of just breaking - Fixed various issues with PyDoc blocks in several files, such as `cache.KeyManager` and `crypto.RedisCache` - Travis-CI now uses `pip install -U '.[dev]'` instead of installing the requirements file `docs/requirements.txt` and package - ReadTheDocs now uses `pip install -U '.[dev]'` instead of installing the requirements file `docs/requirements.txt` - Possibly other small fixes / changes **Documentation related:** - Listed some of the new `setuppy` functionality in the overview in README.md - Updated the `docs/requirements.txt` file to include all important requirements - Updated the `module.rst` autosummary template to include attributes (if possible) - Updated the `class.rst` autosummary template so inherited attributes / methods are ignored (generated unit test class docs were often really spammy) - Added detailed documentation for the `privex.helpers.setuppy` module - Added an autosummary block for `privex.helpers.settings` so that it can correctly show the settings in the navigation - Fixed up several module/class rst files with `:noindex:` and other minor fixes to reduce the amount of warnings when building the docs - Re-organised the navigation tree for some modules to make it easier to use **Melded commits from develop branch** - fix __all__ on dynamically loaded functions - forgot to include extras/tests.txt in dev.txt
1 parent 598584a commit e151da2

92 files changed

Lines changed: 1700 additions & 207 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.readthedocs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ formats: all
1313
# Install package + docs requirements
1414
python:
1515
version: 3.7
16-
install:
17-
- requirements: docs/requirements.txt
18-
- method: setuptools
19-
path: .
16+
pip_install: true
17+
extra_requirements:
18+
- dev
19+

.travis.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ services:
33
- redis-server
44
language: python
55
cache: pip
6-
env:
7-
- CODECOV_TOKEN="e309d317-ca30-4c79-a01c-f4dc7c60e471"
86
python:
97
- "3.6"
108
- "3.7"
@@ -16,8 +14,7 @@ before_install:
1614
- sudo apt-get update -qy
1715
- sudo apt-get install -qy iputils-ping
1816
install:
19-
- pip install -U -r docs/requirements.txt
20-
- pip install -U .
17+
- pip install -U '.[dev]'
2118
script: pytest --cov=./privex -v
2219
after_success:
2320
- codecov

README.md

Lines changed: 82 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pipenv install privex-helpers # If you use pipenv (and you should!)
4141
pip3 install privex-helpers # Otherwise, standard pip installation
4242

4343
# If you're using privex-helpers in a project, then you may want to install with the "full" extras
44-
# which installs all optional requirements (other than Django), so you can use **everything** in privex-helpers
44+
# which installs all optional requirements (other than Django/tests), so you can use **everything** in privex-helpers
4545
pipenv install 'privex-helpers[full]' # If you use pipenv (and you should!)
4646
pip3 install 'privex-helpers[full]' # Otherwise, standard pip installation
4747
```
@@ -89,6 +89,8 @@ and may not work if you're reading this README.md elsewhere.
8989
6.1 [Modules with dependencies](#modules-with-dependencies)
9090

9191
6.2 [Using Setuptools Extras](#using-setuptools-extras)
92+
93+
6.3 [Installing extras when using the cloned repository](#installing-extras-when-using-the-cloned-repository)
9294

9395
7. [Unit Tests](#unit-tests)
9496
8. [Contributing](#contributing)
@@ -174,6 +176,16 @@ This is not an exhaustive list, and may sometimes be a little outdated. To see e
174176

175177
- `setuppy` - a module with various functions to help with making python packages or dealing with
176178
requirements.txt files
179+
- `common.extras_require` - A helper function which allows you to generate an `extras_require` setting in
180+
setup.py simply by passing a list of extras names, e.g. `extras_require=extras_require(['cache', 'net']),`
181+
- `bump.bump_version` - Bumps a certain part of a package's semver version number and updates the file containing
182+
the version
183+
- `commands.BumpCommand` - A setup.py command class, which allows you to use `bump.bump_version` within
184+
your package, just by typing a command such as `./setup.py bump --minor` (bumps your package's minor 0.x.0
185+
version and updates the file which contains the version)
186+
- `commands.ExtrasCommand` - Exposes various functionality for managing `extras_require` in your package,
187+
including easily generating/saving requirements.txt files for your extras, installing the requirements,
188+
and outputting a list of extras.
177189

178190
- `decorators` - various decorators to simplify your code
179191
- `retry_on_err` - automatically re-run a function/method when exceptions are thrown, with a variety of
@@ -357,16 +369,32 @@ As of version 2.0.0 - Privex Helpers now supports **Setuptools Extras**, allowin
357369
to specify extra dependencies related to privex-helpers in your requirements.txt, or when running
358370
**pip3 install**.
359371

360-
```
361-
# full: Install all extra dependencies if they aren't already installed
362-
# NOTE: Excludes the `django` extras, because Django + sub-deps weighs ~30-50mb - plus you'd normally only
363-
# be using the `django` module in a Django project, where you'd have the deps installed anyway...
364-
#
365-
# crypto: Install dependencies related to the `crypto` module
366-
# cache: Install dependencies related to the `cache` module
367-
# django: Install dependencies related to the `django` module
368-
# net: Install dependencies related to the `net` module
372+
**What is each extra for?**
373+
374+
Extras designed for using the `privex-helpers` package in a project/package:
375+
376+
- **full** - A meta-extra which includes most other extras required for full functionality of the library.
377+
- It does **NOT** include the `django` extra, because the `Django` package and it's sub-dependencies results in
378+
a good 30-50mb of packages being installed, and those who would use the `django` module probably already
379+
have `Django` installed...
380+
- It does **NOT** include the `docs` or `tests` extras, as those two are only required for building the
381+
documentation, or running the unit tests.
382+
- **crypto** - Install dependencies required to use the `crypto` module
383+
- **cache** - Install optional dependencies to enable all cache backends in `cache`
384+
- **django** - Install dependencies related to the `django` module (including `Django` itself)
385+
- **net** - Install optional dependencies to enable full functionality of the `net` module
386+
- **setuppy** - Install optional dependencies to enable full functionality of the `setuppy` modules
387+
388+
Extras designed for use when developing, testing, documenting, or building `privex-helpers`:
389+
390+
- **dev** - Includes everything required for development and related activities with `privex-helper`.
391+
Generally includes ALL extras, unlike `full` this includes `django`, `docs` and `tests`
392+
- **docs** - This extra is not required for privex-helpers modules. It contains requirements for building the docs.
393+
- **tests** - Not required for privex-helpers module usage. Contains requirements for running the unit tests.
369394

395+
**Using the extras with pip install**
396+
397+
```
370398
# Example: Install privex-helpers AND all optional dependencies (excluding django), for full functionality
371399
pip3 install 'privex-helpers[full]'
372400
@@ -391,8 +419,45 @@ redis>=3.3.8
391419
cryptography>=2.8
392420
```
393421

422+
### Installing extras when using the cloned repository
423+
424+
First, it's recommended to install the requirements in `extras/setuppy.txt` to ensure setup.py functions fully.
425+
426+
```bash
427+
pip3 install -r extras/setuppy.txt
428+
```
429+
430+
As of privex-helpers 2.1.0, you can use the handy setup.py `extras` command to install individual extras requirements,
431+
or all extra requirements painlessly:
432+
433+
```bash
434+
# Install ALL extras requirements (including Django and unit testing related)
435+
./setup.py extras -i
436+
437+
# Install an individual extras requirements, for example 'cache' or 'net'
438+
./setup.py extras -i -e cache
439+
```
440+
441+
If you just want to install the `privex-helpers` package from source, then you can use pip to install
442+
the current folder, and specify the extras you want:
443+
444+
```bash
445+
# Standard "full" install, excluding Django and development packages for docs/testing
446+
pip3 install '.[full]'
447+
# Full development installation, includes everything in 'full', with the addition of the django, docs, and tests extras
448+
pip3 install '.[dev]'
449+
```
450+
394451
### Modules with dependencies
395452

453+
If you're using `privex-helpers` within a normal project (not a package), then it's recommended to simply
454+
install `privex-helpers[full]` which includes all main dependencies for full functionality.
455+
456+
If you're using it inside of a package, then you should only require the extras that are critical to your package
457+
functioning. Anything non-essential should be placed in the `extras_require` of your setup.py to avoid
458+
un-necessary packages being installed on your users.
459+
460+
396461
**Modules which require a dependency to use them**
397462

398463
- `crypto` - This module won't work at all without the `cryptography` library (or `privex-helpers[crypto]`)
@@ -401,10 +466,16 @@ cryptography>=2.8
401466

402467
**Dynamic modules which simply enable additional features if you install certain packages**
403468

469+
- `setuppy` - The `common` sub-module should generally work without any dependencies, but to be able to use all
470+
functionality of this module such as the `bump` and `commands` sub-modules, you'll need to install with the
471+
`setuppy` extra, e.g. `privex-helpers[setuppy]`
404472
- `net` - Some functions are dependent on `dnspython` (or `privex-helpers[net]`), but the majority of the module
405473
is dependency-free
406474
- `cache` - The cache layer works just fine without any dependencies. If you're using `privex-helper` within a project,
407475
then you may want to install `redis` (or `privex-helpers[cache]`) to make the Redis cache adapter available.
476+
- `plugin` - While this module isn't very often used within other projects/packages, it does expose some
477+
Redis singleton management functions (and possibly others at the time of writing). If you plan on using
478+
this module, we recommend using `privex-helpers[full]` for the best experience.
408479

409480

410481
# Unit Tests
@@ -468,4 +539,4 @@ If you'd rather read the whole legal text, it should be included as `privex_cont
468539

469540
**If this project has helped you, consider [grabbing a VPS or Dedicated Server from Privex](https://www.privex.io).**
470541

471-
**Prices start at as little as US$8/mo (we take cryptocurrency!)**
542+
**Prices start at as little as US$8/mo (we take cryptocurrency!)**

docs/requirements.txt

Lines changed: 0 additions & 19 deletions
This file was deleted.

docs/source/_templates/autosummary/class.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ Methods
1616
.. autosummary::
1717
:toctree: {{ name | lower }}
1818
{% for item in methods %}
19-
~{{ name }}.{{ item }}
19+
{%- if item not in inherited_members %}
20+
~{{ name }}.{{ item }}
21+
{%- endif %}
2022
{%- endfor %}
2123
{% endif %}
2224
{% endblock %}
@@ -31,7 +33,9 @@ Attributes
3133
.. autosummary::
3234
:toctree: {{ name | lower }}
3335
{% for item in attributes %}
34-
~{{ name }}.{{ item }}
36+
{%- if item not in inherited_members %}
37+
~{{ name }}.{{ item }}
38+
{%- endif %}
3539
{%- endfor %}
3640
{% endif %}
3741
{% endblock %}

docs/source/_templates/autosummary/module.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
.. automodule:: {{ fullname }}
44

5+
6+
{% block attributes %}
7+
{% if attributes %}
8+
.. rubric:: Attributes
9+
10+
.. autosummary::
11+
:toctree: {{ name | lower }}
12+
{% for item in attributes %}
13+
~{{ name }}.{{ item }}
14+
{%- endfor %}
15+
{% endif %}
16+
{% endblock %}
517
{% block functions %}
618
{% if functions %}
719
.. rubric:: Functions

docs/source/conf.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616

1717
import os
1818
import sys
19+
from os.path import dirname, abspath
20+
1921
import sphinx_rtd_theme
2022

2123
# Add base directory of the project to the path
22-
sys.path.insert(0, os.path.abspath('../..'))
24+
BASE_DIR = dirname(dirname(dirname(abspath(__file__))))
25+
26+
sys.path.insert(0, BASE_DIR)
2327

2428
# -- Project information -----------------------------------------------------
2529

@@ -180,5 +184,6 @@
180184
'python': ('https://docs.python.org/3.6', None),
181185
'cryptography': ('https://cryptography.io/en/latest/', None),
182186
'django': ('http://django.readthedocs.org/en/latest/', None),
187+
'semver': ('https://python-semver.readthedocs.io/en/latest/', None),
183188
}
184189

docs/source/helpers/cache/privex.helpers.cache.CacheAdapter.CacheAdapter.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ CacheAdapter
44
.. currentmodule:: privex.helpers.cache.CacheAdapter
55

66
.. autoclass:: CacheAdapter
7-
7+
:noindex:
88

99
.. automethod:: __init__
10+
:noindex:
1011

1112

1213
.. rubric:: Methods
@@ -25,4 +26,3 @@ CacheAdapter
2526

2627

2728

28-

docs/source/helpers/cache/privex.helpers.cache.MemoryCache.MemoryCache.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ MemoryCache
44
.. currentmodule:: privex.helpers.cache.MemoryCache
55

66
.. autoclass:: MemoryCache
7-
7+
:noindex:
88

99
.. automethod:: __init__
10+
:noindex:
1011

1112

1213
.. rubric:: Methods
@@ -25,4 +26,3 @@ MemoryCache
2526

2627

2728

28-

docs/source/helpers/cache/privex.helpers.cache.RedisCache.RedisCache.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ RedisCache
44
.. currentmodule:: privex.helpers.cache.RedisCache
55

66
.. autoclass:: RedisCache
7+
:noindex:
78

89

910
.. automethod:: __init__
10-
11+
:noindex:
1112

1213
.. rubric:: Methods
1314

@@ -32,4 +33,3 @@ RedisCache
3233

3334
~RedisCache.pickle_default
3435

35-

0 commit comments

Comments
 (0)