-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Fix #453 pkcli.ci finds pyproject.toml or setup.py - Partial #451 emptied pytest_plugin - Converted README.md (from rst)
- Loading branch information
Showing
9 changed files
with
85 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
### Pykern | ||
|
||
Pykern is an application support framework to simplify and to speed | ||
development of Python programs and servers. | ||
|
||
Pykern defines policies, which make it easy to eliminate boiler-plate. | ||
|
||
For more info, [read the API Docs](http://pykern.readthedocs.org). |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
# -*- coding: utf-8 -*- | ||
"""pykern package | ||
:copyright: Copyright (c) 2018 RadiaSoft LLC. All Rights Reserved. | ||
:license: http://www.apache.org/licenses/LICENSE-2.0.html | ||
""" | ||
from __future__ import absolute_import, division, print_function | ||
import pkg_resources | ||
import importlib.metadata | ||
|
||
try: | ||
__version__ = importlib.metadata.version("pykern") | ||
except importlib.metadata.PackageNotFoundError: | ||
# We only have a version once the package is installed. | ||
__version__ = pkg_resources.get_distribution("pykern").version | ||
except pkg_resources.DistributionNotFound: | ||
pass |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,112 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
"""PyTest plugin to setup pkconfig and add pkunit fixtures | ||
"""REMOVED | ||
This plugin will only be "active" if the setup.py in the package | ||
imports `pykern.pksetup`. It also calls `pykern.pkconfig.append_load_path`, | ||
which modifies global state. | ||
Left for backward compatibility | ||
:copyright: Copyright (c) 2016 RadiaSoft LLC. All Rights Reserved. | ||
:copyright: Copyright (c) 2016-2024 RadiaSoft LLC. All Rights Reserved. | ||
:license: http://www.apache.org/licenses/LICENSE-2.0.html | ||
""" | ||
from __future__ import absolute_import, division, print_function | ||
import os | ||
|
||
import pytest | ||
|
||
# Do not import anything from pykern here | ||
|
||
#: Is py.test being run in a package with a setup.py that imports pksetup | ||
_uses_pykern = False | ||
|
||
#: Initialized below | ||
_no_recurse = None | ||
|
||
|
||
@pytest.hookimpl(tryfirst=True) | ||
def pytest_ignore_collect(path, config): | ||
"""Ignore _work and _data directories""" | ||
if not _uses_pykern: | ||
return False | ||
global _no_recurse | ||
if not _no_recurse: | ||
import re | ||
|
||
_no_recurse = re.compile(r"(_work|_data)$") | ||
return bool(_no_recurse.search(str(path))) | ||
|
||
|
||
@pytest.hookimpl(tryfirst=True) | ||
def pytest_runtest_protocol(item, *args, **kwargs): | ||
"""Make sure work directory is empty for a module. | ||
If `item` is in a module not seen before, it removes | ||
the `pkunit.work_dir`. | ||
Args: | ||
item (Item): pytest test item (case) | ||
Returns: | ||
None: always so that the next hook runs the item. | ||
""" | ||
if not _uses_pykern: | ||
return | ||
from pykern import pkunit | ||
|
||
# Seems to be the only way to get the module under test | ||
m = item._request.module | ||
is_new = m != pkunit.module_under_test | ||
pkunit.module_under_test = m | ||
if is_new: | ||
from pykern import pkio | ||
|
||
pkio.unchecked_remove(pkunit.work_dir()) | ||
|
||
|
||
def _setup_py_parser(): | ||
"""Look for setup.py and set `_uses_pykern` | ||
Returns: | ||
str: root dir containing setup.py or None | ||
""" | ||
global _uses_pykern | ||
import py.path | ||
|
||
prev_p = None | ||
p = py.path.local() | ||
while True: | ||
prev_p = p | ||
s = p.join("setup.py") | ||
if s.check(file=True): | ||
break | ||
p = py.path.local(p.dirname) | ||
if prev_p == p or len(str(prev_p)) <= len(str(p)): | ||
return None | ||
_uses_pykern = _setup_py_contains_pykern(s) | ||
if _uses_pykern: | ||
return p | ||
return None | ||
|
||
|
||
def _setup_py_contains_pykern(setup_py): | ||
"""Parses setup.py to see if it imports pykern | ||
This is hacky, but good enough because pykern and | ||
pksetup are unique names. If someone comments out with | ||
a multiline string, it's not super dangerous. | ||
Args: | ||
setup_py (py.path): setup.py file name | ||
Returns: | ||
bool: True if setup.py imports pykern and pksetup | ||
""" | ||
import re | ||
|
||
with open(str(setup_py)) as f: | ||
return bool( | ||
re.search( | ||
r"^\s*(from|import)\s+pykern\b.*\bpksetup\b", | ||
f.read(), | ||
flags=re.MULTILINE, | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
[build-system] | ||
requires = ["chronver", "setuptools>=66"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
authors = [ | ||
{ name = "RadiaSoft LLC", email = "pip@pykern.org" }, | ||
] | ||
classifiers = [ | ||
"Development Status :: 5 - Production/Stable", | ||
"Environment :: Console", | ||
"Intended Audience :: Developers", | ||
"Intended Audience :: Science/Research", | ||
"License :: OSI Approved :: Apache Software License", | ||
"Natural Language :: English", | ||
"Programming Language :: Python", | ||
"Topic :: Software Development :: Libraries :: Application Frameworks", | ||
"Topic :: Utilities", | ||
] | ||
dependencies = [ | ||
"argh>=0.26", | ||
"black~=22.12", | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
"future>=0.14", | ||
"github3.py>=1.1", | ||
"importlib-metadata>=0.12", | ||
"jinja2>=2.7", | ||
"openpyxl>=3.0.9", | ||
"packaging>=21.0", | ||
"pandas>=1.3.2", | ||
"path.py>=7.7.1", | ||
"pluggy>=0.12.0", | ||
"psutil>=5.0", | ||
"py-cpuinfo>=0.2", | ||
"py>=1.4", | ||
"pytest>=2.7", | ||
"python-dateutil>=2.4.2", | ||
"pytz>=2015.4", | ||
"requests>=2.18", | ||
"ruamel.yaml>=0.16.0", | ||
"setuptools>=66", | ||
"six>=1.9", | ||
"Sphinx>=1.3.5", | ||
"tornado", | ||
"tox>=1.9", | ||
"twine>=1.9", | ||
"urllib3", | ||
"XlsxWriter>=3.0.3", | ||
] | ||
description = "Python application support library" | ||
dynamic = ["version"] | ||
name = "pykern" | ||
readme = "README.md" | ||
|
||
[project.scripts] | ||
pykern = "pykern.pykern_console:main" | ||
|
||
[project.urls] | ||
Homepage = "http://pykern.org" |
This is the old version of black, and sirepo PRs are now failing