Skip to content

Commit a6931cf

Browse files
committed
Rename package: pep567 -> contextvars.
1 parent 5d08024 commit a6931cf

File tree

4 files changed

+45
-16
lines changed

4 files changed

+45
-16
lines changed

README.rst

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ module (see PEP 567) for Python 3.6.
1212
asyncio event loop with PEP 567 support yet. Stay tuned for updates.
1313

1414

15+
Original "contextvars" Package
16+
==============================
17+
18+
This package replaces the old "contextvars" PyPI package which
19+
repository is available `here <https://github.com/gawen/contextvars>`_.
20+
21+
1522
Documentation
1623
=============
1724

@@ -20,33 +27,55 @@ https://docs.python.org/3.7/library/contextvars.html
2027

2128

2229
`PEP 567 <https://www.python.org/dev/peps/pep-0567/>`_ also provides
23-
a comprehensive overview of the API and explains the design choices.
30+
a comprehensive overview of the API and explains all design choices.
2431

2532

2633
Installation
2734
============
2835

2936
.. code-block:: bash
3037
31-
$ pip install pep567
38+
$ pip install contextvars
3239
3340
3441
Usage
3542
=====
3643

3744
.. code-block:: python
3845
39-
try:
40-
# Python 3.7
41-
import contextvars
42-
except ImportError:
43-
# Python <= 3.6
44-
import pep567 as contextvars
46+
import contextvars
4547
4648
my_var = contextvars.ContextVar('my_var')
49+
4750
# ...
4851
4952
53+
Listing as a Dependency
54+
=======================
55+
56+
The good news is that the standard library always takes the
57+
precedence over site packages, so even if a local ``contextvars``
58+
module is installed, the one from the standard library will be used.
59+
Therefore you can simply list "contextvars" in your
60+
``requirements.txt`` or ``setup.py`` files.
61+
62+
Another option is to use `"platform specific dependencies"
63+
<http://setuptools.readthedocs.io/en/latest/setuptools.html\
64+
#declaring-platform-specific-dependencies>`_ setuptools feature:
65+
66+
.. code-block:: python
67+
68+
import setuptools
69+
70+
setuptools.setup(
71+
name="Project",
72+
...
73+
install_requires=[
74+
'contextvars;python_version<"3.7"'
75+
]
76+
)
77+
78+
5079
License
5180
=======
5281

pep567/__init__.py renamed to contextvars/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ContextMeta(type(collections.abc.Mapping)):
4444

4545
def __new__(mcls, names, bases, dct):
4646
cls = super().__new__(mcls, names, bases, dct)
47-
if cls.__module__ != 'pep567' or cls.__name__ != 'Context':
47+
if cls.__module__ != 'contextvars' or cls.__name__ != 'Context':
4848
raise TypeError("type 'Context' is not an acceptable base type")
4949
return cls
5050

@@ -96,7 +96,7 @@ class ContextVarMeta(type):
9696

9797
def __new__(mcls, names, bases, dct):
9898
cls = super().__new__(mcls, names, bases, dct)
99-
if cls.__module__ != 'pep567' or cls.__name__ != 'ContextVar':
99+
if cls.__module__ != 'contextvars' or cls.__name__ != 'ContextVar':
100100
raise TypeError("type 'ContextVar' is not an acceptable base type")
101101
return cls
102102

@@ -176,7 +176,7 @@ class TokenMeta(type):
176176

177177
def __new__(mcls, names, bases, dct):
178178
cls = super().__new__(mcls, names, bases, dct)
179-
if cls.__module__ != 'pep567' or cls.__name__ != 'Token':
179+
if cls.__module__ != 'contextvars' or cls.__name__ != 'Token':
180180
raise TypeError("type 'Token' is not an acceptable base type")
181181
return cls
182182

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88

99
setuptools.setup(
10-
name='pep567',
11-
version="0.1.0",
10+
name='contextvars',
11+
version="2.0",
1212
description='PEP 567 Backport',
1313
long_description=readme,
1414
author='MagicStack Inc',
1515
author_email='[email protected]',
16-
packages=['pep567'],
17-
provides=['pep567'],
16+
packages=['contextvars'],
17+
provides=['contextvars'],
1818
license='Apache License, Version 2.0',
1919
classifiers=[
2020
'Development Status :: 3 - Alpha',

tests/test_basics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import time
1010
import unittest
1111

12-
import pep567 as contextvars
12+
import contextvars
1313

1414

1515
def isolated_context(func):

0 commit comments

Comments
 (0)