Skip to content

Commit c1f6dcf

Browse files
committed
Initial commit
0 parents  commit c1f6dcf

15 files changed

Lines changed: 508 additions & 0 deletions

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = tab
6+
indent_size = 4
7+
insert_final_newline = true
8+
end_of_line = lf
9+
10+
[*.{yml,yaml}]
11+
indent_style = space
12+
indent_size = 2

.github/.templateMarker

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
KOLANICH/python_project_boilerplate.py

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
allow:
8+
- dependency-type: "all"

.github/workflows/CI.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [master]
5+
pull_request:
6+
branches: [master]
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-22.04
11+
steps:
12+
- name: typical python workflow
13+
uses: KOLANICH-GHActions/typical-python-workflow@master
14+
with:
15+
github_token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
__pycache__
2+
*.pyc
3+
*.pyo
4+
/*.egg-info
5+
/build
6+
/dist
7+
/.eggs
8+
*.sqlite3
9+
*.sqlite
10+
/.mypy_cache
11+
*.py,cover
12+
/.coverage
13+
/rspec.xml
14+
/monkeytype.sqlite3
15+
/*.srctrldb
16+
/*.srctrlbm
17+
/*.srctrlprj

.gitlab-ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#image: pypy:latest
2+
image: registry.gitlab.com/kolanich-subgroups/docker-images/fixed_python:latest
3+
stages:
4+
- dependencies
5+
- build
6+
- test
7+
- trigger
8+
9+
variables:
10+
DOCKER_DRIVER: overlay2
11+
SAST_ANALYZER_IMAGE_TAG: latest
12+
SAST_DISABLE_DIND: "true"
13+
14+
include:
15+
- template: SAST.gitlab-ci.yml
16+
#- template: DAST.gitlab-ci.yml
17+
#- template: License-Management.gitlab-ci.yml
18+
#- template: Container-Scanning.gitlab-ci.yml
19+
#- template: Dependency-Scanning.gitlab-ci.yml
20+
- template: Code-Quality.gitlab-ci.yml
21+
22+
23+
build:
24+
tags:
25+
- shared
26+
stage: build
27+
variables:
28+
GIT_DEPTH: "1"
29+
PYTHONUSERBASE: ${CI_PROJECT_DIR}/python_user_packages
30+
31+
before_script:
32+
- export PYTHON_MODULES_DIR=${PYTHONUSERBASE}/lib/python3.8
33+
- export EXECUTABLE_DEPENDENCIES_DIR=${PYTHONUSERBASE}/bin
34+
- export PATH="$PATH:$EXECUTABLE_DEPENDENCIES_DIR" # don't move into `variables` any of them, it is unordered
35+
- mkdir ./wheels
36+
37+
script:
38+
- python3 ./setup.py bdist_wheel
39+
- mv ./dist/*.whl ./wheels/FHS-0.CI_python-py3-none-any.whl
40+
- pip3 install --upgrade --pre --user ./wheels/FHS-0.CI_python-py3-none-any.whl
41+
- coverage run --source=FHS --branch -m pytest --junitxml=./rspec.xml ./tests/tests.py
42+
- coverage report -m
43+
- coverage xml
44+
45+
coverage: /^TOTAL\s+.+?(\d{1,3}%)$/
46+
47+
artifacts:
48+
paths:
49+
- wheels
50+
reports:
51+
junit: ./rspec.xml
52+
cobertura: ./coverage.xml
53+

Code_Of_Conduct.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
No codes of conduct!

FHS/GNUDirs.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import typing
2+
from pathlib import Path
3+
from functools import lru_cache
4+
5+
# from TargetTriple import TargetTriple
6+
7+
from . import StandardizedDirProto
8+
9+
10+
class GNUDirs_:
11+
"""The way to pass the info about the dirs to the build system"""
12+
13+
prefix = None
14+
bin = None
15+
sbin = None
16+
libexec = None
17+
etc = None
18+
var = None
19+
run = None
20+
lib = None
21+
include = None
22+
share = None
23+
info = None
24+
locale = None
25+
com = None
26+
doc = None
27+
man = None
28+
29+
@classmethod
30+
def toGnuArgs(cls) -> typing.Mapping[str, Path]:
31+
return {
32+
"prefix": cls.prefix,
33+
#"exec_prefix" : cls.prefix,
34+
"bindir": cls.bin,
35+
"datarootdir": cls.share,
36+
"datadir": cls.share, # datarootdir
37+
"sharedstatedir": cls.com,
38+
"includedir": cls.include,
39+
"infodir": cls.info,
40+
"libdir": cls.lib,
41+
"libexecdir": cls.libexec,
42+
"localedir": cls.locale,
43+
"localstatedir": cls.var,
44+
"sbindir": cls.sbin,
45+
"sysconfdir": cls.etc,
46+
"mandir": cls.man,
47+
}
48+
49+
50+
@lru_cache(maxsize=None, typed=True)
51+
def getGNUDirs(prefix: Path, triple: "TargetTriple" = None) -> GNUDirs_:
52+
pfx = Path(prefix)
53+
54+
class GNUDirs(GNUDirs_):
55+
prefix = pfx
56+
bin = pfx / "bin"
57+
sbin = pfx / "sbin"
58+
libexec = pfx / "libexec"
59+
etc = pfx / "etc"
60+
var = pfx / "var"
61+
com = pfx / "com"
62+
run = var / "run"
63+
lib = (pfx / "lib") if triple is None else (pfx / "lib" / str(triple))
64+
include = pfx / "include"
65+
share = pfx / "share"
66+
info = share / "info"
67+
locale = share / "locale"
68+
doc = share / "doc"
69+
man = share / "man"
70+
71+
return GNUDirs

FHS/__init__.py

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
from pathlib import Path
2+
3+
4+
class StandardizedDirProtoMeta(type):
5+
def __new__(cls, className, parents, attrs, *args, **kwargs):
6+
attrsNew = type(attrs)()
7+
for k, v in attrs.items():
8+
if k[0] == "_":
9+
continue
10+
11+
if isinstance(v, str):
12+
attrsNew[k] = v
13+
elif v is None:
14+
attrsNew[k] = k
15+
elif issubclass(v, StandardizedDirProto):
16+
attrsNew[k] = v
17+
return super().__new__(cls, className, parents, {"delayed": attrsNew}, *args, **kwargs)
18+
19+
20+
class StandardizedDirProto(metaclass=StandardizedDirProtoMeta):
21+
pass
22+
23+
24+
class StandardizedDirMeta(type):
25+
def __new__(cls, className, parents, attrs, *args, **kwargs):
26+
if "ROOT" in attrs:
27+
attrsNew = type(attrs)()
28+
root = attrs["ROOT"]
29+
attrsNew["__slots__"] = ()
30+
attrsNew["__root__"] = root
31+
attrsNew["__fspath__"] = attrsNew["__str__"] = lambda self: str(self.__root__)
32+
attrsNew["__truediv__"] = lambda self, other: self.__root__ / other
33+
attrsNew["__repr__"] = lambda self: repr(self.__root__)
34+
attrsNew["__eq__"] = lambda self, other: self.__root__ == other
35+
attrsNew["__ne__"] = lambda self, other: self.__root__ != other
36+
attrsNew["__hash__"] = lambda self: hash(self.__root__)
37+
38+
attrs = type(attrs)(attrs)
39+
del attrs["ROOT"]
40+
41+
delayedAssignRoot = []
42+
for k, v in attrs.items():
43+
if k[0] == "_":
44+
continue
45+
46+
if isinstance(v, str):
47+
attrsNew[k] = root / v
48+
elif v is None:
49+
attrsNew[k] = root / k
50+
elif isinstance(v, type) and issubclass(v, StandardizedDirProto):
51+
v.delayed["ROOT"] = root / v.__name__
52+
attrsNew[k] = cls(v.__class__.__name__, parents, v.delayed, *args, **kwargs)
53+
54+
res = super().__new__(cls, className, parents, attrsNew, *args, **kwargs)()
55+
return res
56+
else:
57+
return super().__new__(cls, className, parents, attrs, *args, **kwargs)
58+
59+
60+
class StandardizedDir(metaclass=StandardizedDirMeta):
61+
def __getattr__(self, k):
62+
return getattr(self.__root__, k)
63+
64+
65+
class FHS(StandardizedDir):
66+
ROOT = Path("/")
67+
68+
boot = "boot"
69+
dev = "dev"
70+
71+
class etc(StandardizedDirProto):
72+
sgml = "sgml"
73+
X11 = "X11"
74+
xml = "xml"
75+
opt = "opt"
76+
77+
home = "home"
78+
media = "media"
79+
mnt = "mnt"
80+
81+
opt = "opt"
82+
proc = "proc"
83+
root = "root"
84+
run = "run"
85+
srv = "srv"
86+
sys = "sys"
87+
tmp = "tmp"
88+
89+
bin = "bin"
90+
lib = "lib"
91+
lib32 = "lib32"
92+
lib64 = "lib64"
93+
94+
class usr(StandardizedDirProto):
95+
bin = "bin"
96+
lib = "lib"
97+
libexec = "libexec"
98+
lib32 = "lib32"
99+
lib64 = "lib64"
100+
sbin = "sbin"
101+
102+
include = "include"
103+
src = "src"
104+
X11R6 = "X11R6"
105+
106+
class share(StandardizedDirProto):
107+
man = "man"
108+
109+
class misc(StandardizedDirProto):
110+
ascii = "ascii"
111+
termcap = "termcap"
112+
termcapDB = "termcap.db"
113+
114+
class color(StandardizedDirProto):
115+
icc = "icc"
116+
117+
class dict(StandardizedDirProto):
118+
words = "words"
119+
120+
doc = "doc"
121+
games = "games"
122+
info = "info"
123+
locale = "locale"
124+
nls = "nls"
125+
ppd = "ppd"
126+
127+
class sgml(StandardizedDirProto):
128+
docbook = "docbook"
129+
tei = "tei"
130+
html = "html"
131+
mathml = "mathml"
132+
133+
class xml(StandardizedDirProto):
134+
docbook = "docbook"
135+
xhtml = "xhtml"
136+
mathml = "mathml"
137+
138+
terminfo = "terminfo"
139+
tmactroff = "tmactroff"
140+
zoneinfo = "zoneinfo"
141+
142+
class local(StandardizedDirProto):
143+
bin = "bin"
144+
etc = "etc"
145+
games = "games"
146+
include = "include"
147+
lib = "lib"
148+
libexec = "libexec"
149+
man = "man"
150+
sbin = "sbin"
151+
share = "share"
152+
src = "src"
153+
154+
class var(StandardizedDirProto):
155+
class cache(StandardizedDirProto):
156+
fonts = "fonts"
157+
man = "man"
158+
www = "www"
159+
160+
class lib(StandardizedDirProto):
161+
misc = "misc"
162+
color = "color"
163+
hwclock = "hwclock"
164+
xdm = "xdm"
165+
166+
lock = "lock"
167+
168+
class log(StandardizedDirProto):
169+
last = "last"
170+
messages = "messages"
171+
wtmp = "wtmp"
172+
173+
mail = "mail"
174+
opt = "opt"
175+
176+
class spool(StandardizedDirProto):
177+
mail = "mail"
178+
179+
class lpd(StandardizedDirProto):
180+
printer = "printer"
181+
182+
mqueue = "mqueue"
183+
news = "news"
184+
rwho = "rwho"
185+
uucp = "uucp"
186+
187+
account = "account"
188+
crash = "crash"
189+
games = "games"
190+
mail = "mail"
191+
yp = "yp"
192+
193+
194+
class Common:
195+
OpenCL = FHS.etc / "OpenCL"
196+
OpenCLVendors = OpenCL / "vendors"
197+
applications = FHS.usr.share / "applications"
198+
icons = FHS.usr.share / "icons"
199+
pkgConfig = FHS.usr.lib / "pkgconfig"
200+
aclocal = FHS.usr.share / "aclocal"
201+
mime = FHS.usr.share / "mime"
202+
systemdDir = FHS.usr / "systemd"
203+
systemdUnitsDir = systemdDir / "system"

FHS/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)