WIP: Fix project layout

pull/20/head
JensDiemer 2020-11-13 21:52:19 +01:00
rodzic 9c058a03d4
commit 83ba4da9a9
21 zmienionych plików z 120 dodań i 117 usunięć

Wyświetl plik

@ -21,7 +21,6 @@ jobs:
- name: 'Install package'
run: |
cd src
make install-poetry
source $HOME/.poetry/env
poetry lock

73
.gitignore vendored
Wyświetl plik

@ -1,5 +1,72 @@
.*
!.github
!.editorconfig
!.flake8
!.gitignore
!.travis.yml
!.isort.cfg
!/.travis.yml
!/.style.yapf
!.coveralls.yml
# for django-dbbackup
/backups/
!/backups/.gitkeep
# from test projects:
/static/
/media/
*.sqlite3
# Django
secret.txt
# Coverage HTML Report files:
htmlcov
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.tox
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
db.sqlite3
coverage_html/
coverage.xml
*,cover
# Translations
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/

Wyświetl plik

@ -61,8 +61,8 @@ Read [[https://github.com/jedie/PyInventory/tree/master/deployment#readme|/deplo
{{{
~$ git clone https://github.com/jedie/PyInventory.git
~$ cd PyInventory/src/
~/PyInventory/src$ make
~$ cd PyInventory/
~/PyInventory$ make
help List all commands
install-poetry install or update poetry
install install PyInventory via poetry
@ -92,20 +92,20 @@ dbrestore Restore a database backup
{{{
# install or update Poetry:
~/PyInventory/src$ make install-poetry
~/PyInventory$ make install-poetry
# install PyInventory via poetry:
~/PyInventory/src$ make install
~/PyInventory$ make install
...
# Collectstatic + makemigration + migrate:
~/PyInventory/src$ make manage-update
~/PyInventory$ make manage-update
# Create a django super user:
~/PyInventory/src$ ./manage.sh createsuperuser
~/PyInventory$ ./manage.sh createsuperuser
# start local dev. web server:
~/PyInventory/src$ make run-dev-server
~/PyInventory$ make run-dev-server
}}}
The web page is available via: {{{http://127.0.0.1:8000/}}}

Wyświetl plik

@ -69,22 +69,22 @@ Plan:
any many more... ;)
------------
git branches
------------
-----------------
Project structure
-----------------
Currently we have two main branches:
There are two main directories:
+-------------------+----------------------------------------------------------------+
| git branch | description |
+===================+================================================================+
| **`master`_** | The main PyInventory source code |
+-------------------+----------------------------------------------------------------+
| **`deployment`_** | separate project to deploy PyInventory for production use case |
+-------------------+----------------------------------------------------------------+
+---------------------+--------------------------------------------+
| directory | description |
+=====================+============================================+
| **`/src/`_** | The main PyInventory source code |
+---------------------+--------------------------------------------+
| **`/deployment/`_** | deploy PyInventory for production use case |
+---------------------+--------------------------------------------+
.. _master: https://github.com/jedie/PyInventory/tree/master
.. _deployment: https://github.com/jedie/PyInventory/tree/deployment
.. _/src/: https://github.com/jedie/PyInventory/tree/master/src
.. _/deployment/: https://github.com/jedie/PyInventory/tree/master/deployment
-------
install
@ -96,9 +96,9 @@ There exists two kind of installation/usage:
* production use with docker-compose
This README (in git **master** branch) contains only the information about local develompment installation.
This README contains only the information about local development installation.
Read `deployment README <https://github.com/jedie/PyInventory/tree/deployment#readme>`_ for instruction to install PyInventory on a root server.
Read `/deployment/README <https://github.com/jedie/PyInventory/tree/master/deployment#readme>`_ for instruction to install PyInventory on a root server.
prepare
=======
@ -106,7 +106,7 @@ prepare
::
~$ git clone https://github.com/jedie/PyInventory.git
~$ cd PyInventory
~$ cd PyInventory/
~/PyInventory$ make
help List all commands
install-poetry install or update poetry
@ -214,7 +214,9 @@ Nothing, yet ;)
history
-------
* `compare v0.4.2...master <https://github.com/jedie/PyInventory/compare/v0.4.2...master>`_ **dev**
* `compare v0.4.2...master <https://github.com/jedie/PyInventory/compare/v0.4.2...master>`_ **dev**
* Merge seperate git branches into one: "/src/" and "/development/" `#19 <https://github.com/jedie/PyInventory/issues/19>`_
* tbc
@ -315,4 +317,4 @@ donation
------------
``Note: this file is generated from README.creole 2020-11-13 09:09:36 with "python-creole"``
``Note: this file is generated from README.creole 2020-11-13 21:51:42 with "python-creole"``

Wyświetl plik

@ -5,6 +5,7 @@ import os as __os
from inventory_project.settings.base import * # noqa
HOSTNAME = __os.environ['HOSTNAME']

Wyświetl plik

@ -1,11 +1,20 @@
#!/usr/bin/env python3
import os
import sys
from pathlib import Path
BASE_PATH = Path(__file__).parent
def main():
assert 'DJANGO_SETTINGS_MODULE' in os.environ, 'No "DJANGO_SETTINGS_MODULE" in environment!'
# Change to /src/ and add it to sys.path
src_path = Path(BASE_PATH, 'src').resolve()
assert src_path.is_dir(), f'Path not exists: {src_path}'
sys.path.insert(0, str(src_path))
try:
from django.core.management import execute_from_command_line
except ImportError as exc:

Wyświetl plik

Wyświetl plik

@ -4,8 +4,8 @@ version = "0.4.2"
description = "Web based management to catalog things including state and location etc. using Python/Django."
authors = ["JensDiemer <git@jensdiemer.de>"]
packages = [
{ include = "inventory" },
{ include = "inventory_project" },
{ include = "inventory", from = "src" },
{ include = "inventory_project", from = "src" },
]
keywords=['inventory','django']
classifiers = [
@ -26,10 +26,10 @@ classifiers = [
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
"Operating System :: OS Independent",
]
include = ['../AUTHORS', '../LICENSE', '../README.creole']
include = ['AUTHORS', 'LICENSE', 'README.creole']
# Will be generated from README.creole with: 'poetry run update_rst_readme'
readme='../README.rst'
readme='README.rst'
[tool.poetry.dependencies]
python = ">=3.7,<4.0.0"

Wyświetl plik

@ -4,9 +4,7 @@
[pytest]
DJANGO_SETTINGS_MODULE=inventory_project.settings.tests
testpaths =
inventory/tests/
inventory_project/tests/
testpaths = src
# http://doc.pytest.org/en/latest/customize.html#confval-norecursedirs
norecursedirs = .* .git __pycache__ coverage* dist

72
src/.gitignore vendored
Wyświetl plik

@ -1,72 +0,0 @@
.*
!.flake8
!.gitignore
!.isort.cfg
!/.travis.yml
!/.style.yapf
!.coveralls.yml
# for django-dbbackup
/backups/
!/backups/.gitkeep
# from test projects:
/static/
/media/
*.sqlite3
# Django
secret.txt
# Coverage HTML Report files:
htmlcov
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.tox
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
db.sqlite3
coverage_html/
coverage.xml
*,cover
# Translations
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/

Wyświetl plik

@ -8,7 +8,7 @@ from poetry_publish.utils.subprocess_utils import verbose_check_call
import inventory
PACKAGE_ROOT = Path(inventory.__file__).parent.parent
PACKAGE_ROOT = Path(inventory.__file__).parent.parent.parent
def update_readme():

Wyświetl plik

@ -8,8 +8,9 @@ from pathlib import Path as __Path
from django.utils.translation import ugettext_lazy as _
# Build paths inside the project:
BASE_PATH = __Path(__file__).resolve().parent.parent.parent
# Build paths relative to the current working directory:
BASE_PATH = __Path().cwd().resolve()
print(f'BASE_PATH:{BASE_PATH}')
# SECURITY WARNING: don't run with debug turned on in production!

Wyświetl plik

@ -7,7 +7,6 @@
"""
import sys as __sys
from pathlib import Path as __Path
from inventory_project.settings.base import * # noqa
@ -31,8 +30,7 @@ ALLOWED_HOSTS = INTERNAL_IPS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': str(__Path(BASE_PATH.parent, 'PyInventory-database.sqlite3')),
# 'NAME': ':memory:'
'NAME': str(BASE_PATH / 'PyInventory-database.sqlite3'),
# https://docs.djangoproject.com/en/dev/ref/databases/#database-is-locked-errors
'timeout': 30,
}

Wyświetl plik

@ -5,7 +5,7 @@ from pathlib import Path
import inventory
BASE_PATH = Path(inventory.__file__).parent.parent
BASE_PATH = Path(inventory.__file__).parent.parent.parent
def test_lint():

Wyświetl plik

@ -8,7 +8,7 @@ from creole.setup_utils import update_rst_readme
import inventory
PACKAGE_ROOT = Path(inventory.__file__).parent.parent
PACKAGE_ROOT = Path(inventory.__file__).parent.parent.parent
def assert_file_contains_string(file_path, string):