Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
KOLANICH committed Feb 6, 2023
0 parents commit c1f6dcf
Show file tree
Hide file tree
Showing 15 changed files with 508 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
indent_style = tab
indent_size = 4
insert_final_newline = true
end_of_line = lf

[*.{yml,yaml}]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions .github/.templateMarker
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
KOLANICH/python_project_boilerplate.py
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
allow:
- dependency-type: "all"
15 changes: 15 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: typical python workflow
uses: KOLANICH-GHActions/typical-python-workflow@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
__pycache__
*.pyc
*.pyo
/*.egg-info
/build
/dist
/.eggs
*.sqlite3
*.sqlite
/.mypy_cache
*.py,cover
/.coverage
/rspec.xml
/monkeytype.sqlite3
/*.srctrldb
/*.srctrlbm
/*.srctrlprj
53 changes: 53 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#image: pypy:latest
image: registry.gitlab.com/kolanich-subgroups/docker-images/fixed_python:latest
stages:
- dependencies
- build
- test
- trigger

variables:
DOCKER_DRIVER: overlay2
SAST_ANALYZER_IMAGE_TAG: latest
SAST_DISABLE_DIND: "true"

include:
- template: SAST.gitlab-ci.yml
#- template: DAST.gitlab-ci.yml
#- template: License-Management.gitlab-ci.yml
#- template: Container-Scanning.gitlab-ci.yml
#- template: Dependency-Scanning.gitlab-ci.yml
- template: Code-Quality.gitlab-ci.yml


build:
tags:
- shared
stage: build
variables:
GIT_DEPTH: "1"
PYTHONUSERBASE: ${CI_PROJECT_DIR}/python_user_packages

before_script:
- export PYTHON_MODULES_DIR=${PYTHONUSERBASE}/lib/python3.8
- export EXECUTABLE_DEPENDENCIES_DIR=${PYTHONUSERBASE}/bin
- export PATH="$PATH:$EXECUTABLE_DEPENDENCIES_DIR" # don't move into `variables` any of them, it is unordered
- mkdir ./wheels

script:
- python3 ./setup.py bdist_wheel
- mv ./dist/*.whl ./wheels/FHS-0.CI_python-py3-none-any.whl
- pip3 install --upgrade --pre --user ./wheels/FHS-0.CI_python-py3-none-any.whl
- coverage run --source=FHS --branch -m pytest --junitxml=./rspec.xml ./tests/tests.py
- coverage report -m
- coverage xml

coverage: /^TOTAL\s+.+?(\d{1,3}%)$/

artifacts:
paths:
- wheels
reports:
junit: ./rspec.xml
cobertura: ./coverage.xml

1 change: 1 addition & 0 deletions Code_Of_Conduct.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No codes of conduct!
71 changes: 71 additions & 0 deletions FHS/GNUDirs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import typing
from pathlib import Path
from functools import lru_cache

# from TargetTriple import TargetTriple

from . import StandardizedDirProto


class GNUDirs_:
"""The way to pass the info about the dirs to the build system"""

prefix = None
bin = None
sbin = None
libexec = None
etc = None
var = None
run = None
lib = None
include = None
share = None
info = None
locale = None
com = None
doc = None
man = None

@classmethod
def toGnuArgs(cls) -> typing.Mapping[str, Path]:
return {
"prefix": cls.prefix,
#"exec_prefix" : cls.prefix,
"bindir": cls.bin,
"datarootdir": cls.share,
"datadir": cls.share, # datarootdir
"sharedstatedir": cls.com,
"includedir": cls.include,
"infodir": cls.info,
"libdir": cls.lib,
"libexecdir": cls.libexec,
"localedir": cls.locale,
"localstatedir": cls.var,
"sbindir": cls.sbin,
"sysconfdir": cls.etc,
"mandir": cls.man,
}


@lru_cache(maxsize=None, typed=True)
def getGNUDirs(prefix: Path, triple: "TargetTriple" = None) -> GNUDirs_:
pfx = Path(prefix)

class GNUDirs(GNUDirs_):
prefix = pfx
bin = pfx / "bin"
sbin = pfx / "sbin"
libexec = pfx / "libexec"
etc = pfx / "etc"
var = pfx / "var"
com = pfx / "com"
run = var / "run"
lib = (pfx / "lib") if triple is None else (pfx / "lib" / str(triple))
include = pfx / "include"
share = pfx / "share"
info = share / "info"
locale = share / "locale"
doc = share / "doc"
man = share / "man"

return GNUDirs
203 changes: 203 additions & 0 deletions FHS/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
from pathlib import Path


class StandardizedDirProtoMeta(type):
def __new__(cls, className, parents, attrs, *args, **kwargs):
attrsNew = type(attrs)()
for k, v in attrs.items():
if k[0] == "_":
continue

if isinstance(v, str):
attrsNew[k] = v
elif v is None:
attrsNew[k] = k
elif issubclass(v, StandardizedDirProto):
attrsNew[k] = v
return super().__new__(cls, className, parents, {"delayed": attrsNew}, *args, **kwargs)


class StandardizedDirProto(metaclass=StandardizedDirProtoMeta):
pass


class StandardizedDirMeta(type):
def __new__(cls, className, parents, attrs, *args, **kwargs):
if "ROOT" in attrs:
attrsNew = type(attrs)()
root = attrs["ROOT"]
attrsNew["__slots__"] = ()
attrsNew["__root__"] = root
attrsNew["__fspath__"] = attrsNew["__str__"] = lambda self: str(self.__root__)
attrsNew["__truediv__"] = lambda self, other: self.__root__ / other
attrsNew["__repr__"] = lambda self: repr(self.__root__)
attrsNew["__eq__"] = lambda self, other: self.__root__ == other
attrsNew["__ne__"] = lambda self, other: self.__root__ != other
attrsNew["__hash__"] = lambda self: hash(self.__root__)

attrs = type(attrs)(attrs)
del attrs["ROOT"]

delayedAssignRoot = []
for k, v in attrs.items():
if k[0] == "_":
continue

if isinstance(v, str):
attrsNew[k] = root / v
elif v is None:
attrsNew[k] = root / k
elif isinstance(v, type) and issubclass(v, StandardizedDirProto):
v.delayed["ROOT"] = root / v.__name__
attrsNew[k] = cls(v.__class__.__name__, parents, v.delayed, *args, **kwargs)

res = super().__new__(cls, className, parents, attrsNew, *args, **kwargs)()
return res
else:
return super().__new__(cls, className, parents, attrs, *args, **kwargs)


class StandardizedDir(metaclass=StandardizedDirMeta):
def __getattr__(self, k):
return getattr(self.__root__, k)


class FHS(StandardizedDir):
ROOT = Path("/")

boot = "boot"
dev = "dev"

class etc(StandardizedDirProto):
sgml = "sgml"
X11 = "X11"
xml = "xml"
opt = "opt"

home = "home"
media = "media"
mnt = "mnt"

opt = "opt"
proc = "proc"
root = "root"
run = "run"
srv = "srv"
sys = "sys"
tmp = "tmp"

bin = "bin"
lib = "lib"
lib32 = "lib32"
lib64 = "lib64"

class usr(StandardizedDirProto):
bin = "bin"
lib = "lib"
libexec = "libexec"
lib32 = "lib32"
lib64 = "lib64"
sbin = "sbin"

include = "include"
src = "src"
X11R6 = "X11R6"

class share(StandardizedDirProto):
man = "man"

class misc(StandardizedDirProto):
ascii = "ascii"
termcap = "termcap"
termcapDB = "termcap.db"

class color(StandardizedDirProto):
icc = "icc"

class dict(StandardizedDirProto):
words = "words"

doc = "doc"
games = "games"
info = "info"
locale = "locale"
nls = "nls"
ppd = "ppd"

class sgml(StandardizedDirProto):
docbook = "docbook"
tei = "tei"
html = "html"
mathml = "mathml"

class xml(StandardizedDirProto):
docbook = "docbook"
xhtml = "xhtml"
mathml = "mathml"

terminfo = "terminfo"
tmactroff = "tmactroff"
zoneinfo = "zoneinfo"

class local(StandardizedDirProto):
bin = "bin"
etc = "etc"
games = "games"
include = "include"
lib = "lib"
libexec = "libexec"
man = "man"
sbin = "sbin"
share = "share"
src = "src"

class var(StandardizedDirProto):
class cache(StandardizedDirProto):
fonts = "fonts"
man = "man"
www = "www"

class lib(StandardizedDirProto):
misc = "misc"
color = "color"
hwclock = "hwclock"
xdm = "xdm"

lock = "lock"

class log(StandardizedDirProto):
last = "last"
messages = "messages"
wtmp = "wtmp"

mail = "mail"
opt = "opt"

class spool(StandardizedDirProto):
mail = "mail"

class lpd(StandardizedDirProto):
printer = "printer"

mqueue = "mqueue"
news = "news"
rwho = "rwho"
uucp = "uucp"

account = "account"
crash = "crash"
games = "games"
mail = "mail"
yp = "yp"


class Common:
OpenCL = FHS.etc / "OpenCL"
OpenCLVendors = OpenCL / "vendors"
applications = FHS.usr.share / "applications"
icons = FHS.usr.share / "icons"
pkgConfig = FHS.usr.lib / "pkgconfig"
aclocal = FHS.usr.share / "aclocal"
mime = FHS.usr.share / "mime"
systemdDir = FHS.usr / "systemd"
systemdUnitsDir = systemdDir / "system"
Empty file added FHS/py.typed
Empty file.
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include UNLICENSE
include *.md
include tests
include .editorconfig
Loading

0 comments on commit c1f6dcf

Please sign in to comment.