Skip to content

Commit a8a3f37

Browse files
committed
Vendor relevant part of jaraco.docker
1 parent 7467bc5 commit a8a3f37

File tree

4 files changed

+48
-5
lines changed

4 files changed

+48
-5
lines changed

__pkginfo__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
install_requires = (repo_root / "requirements.txt").read_text(encoding="utf-8").split('\n')
3333
extras_require = {
3434
'dates': ['pytz>=2019.1'],
35-
'testing': ['pytest>=6.0.0', 'pytest-regressions>=2.0.2', 'jaraco.docker>=2.0'],
36-
'all': ['jaraco.docker>=2.0', 'pytest-regressions>=2.0.2', 'pytest>=6.0.0', 'pytz>=2019.1']
35+
'testing': ['pytest>=6.0.0', 'pytest-regressions>=2.0.2'],
36+
'all': ['pytest-regressions>=2.0.2', 'pytest>=6.0.0', 'pytz>=2019.1']
3737
}

domdf_python_tools/testing.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,26 @@
2727
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
2828
# MA 02110-1301, USA.
2929
#
30+
# is_docker based on https://github.com/jaraco/jaraco.docker
31+
# Copyright Jason R. Coombs
32+
# | Permission is hereby granted, free of charge, to any person obtaining a copy
33+
# | of this software and associated documentation files (the "Software"), to deal
34+
# | in the Software without restriction, including without limitation the rights
35+
# | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
36+
# | copies of the Software, and to permit persons to whom the Software is
37+
# | furnished to do so, subject to the following conditions:
38+
# |
39+
# | The above copyright notice and this permission notice shall be included in all
40+
# | copies or substantial portions of the Software.
41+
# |
42+
# | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
43+
# | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44+
# | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45+
# | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
46+
# | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
47+
# | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
48+
# | OR OTHER DEALINGS IN THE SOFTWARE.
49+
#
3050

3151
# stdlib
3252
import datetime
@@ -42,7 +62,6 @@
4262
# 3rd party
4363
import pytest # nodep
4464
from _pytest.mark import MarkDecorator # nodep
45-
from jaraco.docker import is_docker # type: ignore # nodep
4665
from pytest_regressions.file_regression import FileRegressionFixture # nodep
4766

4867
# this package
@@ -357,6 +376,31 @@ def only_function(reason: str = default_reason.format("Only")) -> MarkDecorator:
357376
versionadded="1.5.0",
358377
)
359378

379+
380+
def is_docker():
381+
"""
382+
Is this current environment running in docker?
383+
384+
>>> type(is_docker())
385+
<class 'bool'>
386+
387+
.. versionadded:: 0.6.0
388+
"""
389+
390+
if os.path.exists("/.dockerenv"):
391+
return True
392+
393+
cgroup = PathPlus("/proc/self/cgroup")
394+
395+
if cgroup.is_file():
396+
try:
397+
return any("docker" in line for line in cgroup.read_lines())
398+
except FileNotFoundError:
399+
return False
400+
401+
return False
402+
403+
360404
not_docker, only_docker = platform_boolean_factory(condition=is_docker(), platform="Docker", versionadded="1.5.0")
361405
not_docker.__doc__ = cast(str, not_docker.__doc__).replace("the current platform is", "running on")
362406
only_docker.__doc__ = cast(str, only_docker.__doc__).replace("the current platform is", "running on")

make_conda_recipe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
# TODO: entry_points, manifest
2828

29-
for requires in {'dates': ['pytz>=2019.1'], 'testing': ['pytest>=6.0.0', 'pytest-regressions>=2.0.2', 'jaraco.docker>=2.0'], 'all': ['jaraco.docker>=2.0', 'pytest-regressions>=2.0.2', 'pytest>=6.0.0', 'pytz>=2019.1']}.values():
29+
for requires in {'dates': ['pytz>=2019.1'], 'testing': ['pytest>=6.0.0', 'pytest-regressions>=2.0.2'], 'all': ['pytest-regressions>=2.0.2', 'pytest>=6.0.0', 'pytz>=2019.1']}.values():
3030
all_requirements += requires
3131

3232
all_requirements = {x.replace(" ", '') for x in set(all_requirements)}

repo_helper.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ extras_require:
3939
testing:
4040
- pytest>=6.0.0
4141
- pytest-regressions>=2.0.2
42-
- jaraco.docker>=2.0
4342

4443
conda_extras:
4544
- dates

0 commit comments

Comments
 (0)