-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
general: migrate to src/ package structure, update CI configs
- Loading branch information
Showing
33 changed files
with
124 additions
and
42 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
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,24 +1,40 @@ | ||
#!/bin/bash -eu | ||
#!/bin/bash | ||
set -eu | ||
|
||
cd "$(dirname "$0")" | ||
cd .. | ||
cd .. # git root | ||
|
||
if ! command -v sudo; then | ||
# CI or Docker sometimes don't have it, so useful to have a dummy | ||
# CI or Docker sometimes doesn't have it, so useful to have a dummy | ||
function sudo { | ||
"$@" | ||
} | ||
fi | ||
|
||
if [ -n "${CI-}" ]; then | ||
# install OS specific stuff here | ||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
case "$OSTYPE" in | ||
darwin*) | ||
# macos | ||
: | ||
else | ||
;; | ||
cygwin* | msys* | win*) | ||
# windows | ||
: | ||
fi | ||
;; | ||
*) | ||
# must be linux? | ||
: | ||
;; | ||
esac | ||
fi | ||
|
||
|
||
PY_BIN="python3" | ||
# some systems might have python pointing to python3 | ||
if ! command -v python3 &> /dev/null; then | ||
PY_BIN="python" | ||
fi | ||
|
||
pip3 install --user tox | ||
tox | ||
"$PY_BIN" -m pip install --user tox | ||
"$PY_BIN" -m tox --parallel --parallel-live "$@" |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# this is a hack to monkey patch pytest so it handles tests inside namespace packages without __init__.py properly | ||
# without it, pytest can't discover the package root for some reason | ||
# also see https://github.com/karlicoss/pytest_namespace_pkgs for more | ||
|
||
import pathlib | ||
from typing import Optional | ||
|
||
import _pytest.main | ||
import _pytest.pathlib | ||
|
||
# we consider all dirs in repo/ to be namespace packages | ||
root_dir = pathlib.Path(__file__).absolute().parent.resolve() / 'src' | ||
assert root_dir.exists(), root_dir | ||
|
||
# TODO assert it contains package name?? maybe get it via setuptools.. | ||
|
||
namespace_pkg_dirs = [str(d) for d in root_dir.iterdir() if d.is_dir()] | ||
|
||
# resolve_package_path is called from _pytest.pathlib.import_path | ||
# takes a full abs path to the test file and needs to return the path to the 'root' package on the filesystem | ||
resolve_pkg_path_orig = _pytest.pathlib.resolve_package_path | ||
def resolve_package_path(path: pathlib.Path) -> Optional[pathlib.Path]: | ||
result = path # search from the test file upwards | ||
for parent in result.parents: | ||
if str(parent) in namespace_pkg_dirs: | ||
return parent | ||
raise RuntimeError("Couldn't determine path for ", path) | ||
_pytest.pathlib.resolve_package_path = resolve_package_path | ||
|
||
|
||
# without patching, the orig function returns just a package name for some reason | ||
# (I think it's used as a sort of fallback) | ||
# so we need to point it at the absolute path properly | ||
# not sure what are the consequences.. maybe it wouldn't be able to run against installed packages? not sure.. | ||
search_pypath_orig = _pytest.main.search_pypath | ||
def search_pypath(module_name: str) -> str: | ||
return str(root_dir) | ||
_pytest.main.search_pypath = search_pypath |
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 |
---|---|---|
|
@@ -4,10 +4,9 @@ | |
|
||
|
||
def main(): | ||
pkg = 'orgparse' | ||
subpkgs = find_namespace_packages('.', include=(pkg + '.*',)) | ||
pkgs = find_namespace_packages('src') | ||
pkg = min(pkgs) | ||
|
||
import orgparse | ||
setup( | ||
name=pkg, | ||
use_scm_version={ | ||
|
@@ -18,22 +17,24 @@ def main(): | |
|
||
zip_safe=False, | ||
|
||
packages=[pkg, *subpkgs], | ||
packages=pkgs, | ||
package_dir={'': 'src'}, | ||
package_data={ | ||
pkg: ['py.typed'], # todo need the rest as well?? | ||
'orgparse.tests.data': ['*.org'], | ||
}, | ||
|
||
author=orgparse.__author__, | ||
author='Takafumi Arakaki, Dmitrii Gerasimov', | ||
author_email='[email protected]', | ||
maintainer='Dima Gerasimov (@karlicoss)', | ||
maintainer_email='[email protected]', | ||
|
||
url='https://github.com/karlicoss/orgparse', | ||
license=orgparse.__license__, | ||
license='BSD License', | ||
|
||
description='orgparse - Emacs org-mode parser in Python', | ||
long_description=orgparse.__doc__, | ||
# TODO add it back later, perhaps via ast? | ||
# long_description=orgparse.__doc__, | ||
|
||
keywords='org org-mode emacs', | ||
classifiers=[ | ||
|
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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