Skip to content

Commit

Permalink
Merge pull request #2655 from Uninett/modernize-nav-packaging
Browse files Browse the repository at this point in the history
Modernize nav packaging
  • Loading branch information
hmpf authored Sep 6, 2023
2 parents ed47517 + 3d9e2fe commit 7adced3
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 50 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ RUN apt-get update \

RUN adduser --system --group --no-create-home --home=/source --shell=/bin/bash nav

RUN pip3 install --upgrade 'setuptools<60' wheel && \
pip3 install --upgrade 'pip<22' pip-tools
RUN pip3 install --upgrade 'setuptools>=61' wheel && \
pip3 install --upgrade 'pip<=23.1.0' pip-tools build

#################################################################################
### COPYing the requirements file to pip-install Python requirements may bust ###
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: dummy clean bigclean doc .FORCE
.PHONY: dummy clean distclean testclean doc .FORCE

dummy:
@echo "'make' is no longer used for deployment. See 'doc/intro/install.rst'"
Expand All @@ -9,6 +9,10 @@ clean:
-find . -name "*.egg-info" -print0 | xargs -0 rm -rf
-find . -name ".*.sw?" -print0 | xargs -0 rm -rf

distclean:
-rm -rf build
-rm -rf dist

testclean: clean
-rm core
-rm *.stats
Expand Down
37 changes: 37 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
[build-system]
requires = ["setuptools>=61.0", "wheel", "setuptools_scm[toml]>=6.2", "libsass"]
build-backend = "setuptools.build_meta"

[project]
name = "nav"
description = "Network Administration Visualized - A comprehensive, free Network Management System"
authors = [{name="Sikt - Norwegian agency for shared services in education and research", email="[email protected]"}]
readme = "README.rst"
requires-python = ">=3.7"
license = {text = "GPLv3"}
keywords = ["nms", "snmp"]
classifiers = [
"Development Status :: 6 - Mature",
"Topic :: System :: Networking :: Monitoring",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
]
dynamic = ["version"]
dependencies = [
"pydantic >= 2.0",
]


[project.urls]
Homepage = "https://nav.uninett.no/"

[tool.setuptools]
include-package-data = true
zip-safe = false
platforms = ["any"]

[tool.setuptools_scm]

[tool.setuptools.packages.find]
where = ["python"]


[tool.black]
skip-string-normalization=true
line-length = 88
Expand Down
41 changes: 2 additions & 39 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
import os
from glob import glob
from setuptools import setup, find_packages
from distutils.command.build import build

TOP_SRCDIR = os.path.abspath(os.path.dirname(__file__))


def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()


def etc_files():
return [
(d, [os.path.join(d, f) for f in files]) for d, folders, files in os.walk('etc')
]
from setuptools import setup
from setuptools.command.build import build


def find_scripts():
Expand All @@ -29,36 +16,12 @@ def find_scripts():

setup(
setup_requires=['libsass', 'setuptools_scm'],
python_requires=">=3.7",
use_scm_version=True,
name="nav",
author="Uninett AS",
author_email="[email protected]",
description=(
"Network Administration Visualized - A comprehensive, free "
"Network Management System"
),
license="GPLv3",
keywords="nms snmp",
url="https://nav.uninett.no/",
long_description=read('README.rst'),
classifiers=[
"Development Status :: 6 - Mature",
"Topic :: System :: Networking :: Monitoring",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
],
scripts=list(find_scripts()),
package_dir={'': 'python'},
packages=find_packages('python'),
include_package_data=True,
package_data={'': ['static', 'sql', 'templates', 'etc'],},
data_files=etc_files(),
sass_manifests={
'nav.web': {
'sass_path': 'sass',
'css_path': 'static/css',
'strip_extension': True,
},
},
zip_safe=False,
)
4 changes: 2 additions & 2 deletions tools/docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ if [[ ! -f "/source/setup.py" ]]; then
fi

cd /source
sudo -u nav python3 setup.py build
python3 setup.py develop
sudo -u nav python3 -m build
pip install -e .
sudo -u nav python3 setup.py build_sass

if [[ ! -f "/etc/nav/nav.conf" ]]; then
Expand Down
8 changes: 4 additions & 4 deletions tools/docker/doc-watch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
#
cd /source
# Build once first
sudo -u nav python3 setup.py build # ensure build data and .eggs aren't stored as root
python3 setup.py develop
sudo -u nav python3 setup.py build_sphinx
sudo -u nav python3 -m build # ensure build data and .eggs aren't stored as root
pip install -e .
sudo -u nav sphinx-build doc/ doc/_build
# Then re-build on any changes to the doc directory
while inotifywait -e modify -e move -e create -e delete -r --exclude \# /source/doc /source/NOTES.rst
do
sudo -u nav python3 setup.py build_sphinx
sudo -u nav sphinx-build doc/ doc/_build
done
14 changes: 12 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,17 @@ setenv =
PYTHONFAULTHANDLER=1
django32: DJANGO_VER=32
django40: DJANGO_VER=40
passenv = GITHUB_ACTIONS GITHUB_RUN_ID USER PGHOST PGPORT PGDATABASE PGUSER PGPASSWORD WORKSPACE DISPLAY
passenv =
GITHUB_ACTIONS
GITHUB_RUN_ID
USER
PGHOST
PGPORT
PGDATABASE
PGUSER
PGPASSWORD
WORKSPACE
DISPLAY
allowlist_externals =
sh
sed
Expand Down Expand Up @@ -115,7 +125,7 @@ commands_pre =
pip-compile --resolver=backtracking --output-file {envdir}/requirements.txt doc/requirements.txt
pip-sync {envdir}/requirements.txt
commands =
python setup.py build_sphinx
sphinx-build doc/ doc/_build/
sh -c "cd doc; python -c 'import conf; print(conf.version)' > {toxinidir}/reports/doc_version"

# The flake8 setup should mirror the setup in pre-commit
Expand Down

0 comments on commit 7adced3

Please sign in to comment.