Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep-Alive #764

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
5 changes: 4 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ task:
freebsd_instance:
matrix:
image: freebsd-12-1-release-amd64
image: freebsd-13-0-release-amd64
pip_cache:
folder: ~/.cache/pip
fingerprint_script: cat requirements*
Expand All @@ -21,6 +22,8 @@ task:
- sysctl -a
- mount -t fdescfs null /dev/fd
- pkg install -y python3
- make install-dev
- python3 -m ensurepip
- python3 -m pip install -U setuptools
- make install
test_script:
- env ZPOOL="ioc-test-`uname -r`" make test
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include requirements.txt
include LICENSE.txt
include *.md
include Makefile
include *.py
recursive-include libioc *.py
include libioc/VERSION
26 changes: 4 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,10 @@ pyver= ${PYTHON:S/^python//:S/.//:C/\([0-9]+\)/\1/}
. error "libioc cannot run with a Python version < 3.5"
.endif

install: install-deps install-python-requirements
$(PYTHON) -m pip install -U .
install-python-requirements:
$(PYTHON) -m ensurepip
$(PYTHON) -m pip install -Ur requirements.txt
install-python-requirements-dev: install-python-requirements
$(PYTHON) -m pip install -Ur requirements-dev.txt
install-deps:
pkg install -q -y libucl rsync git py$(pyver)-ucl py$(pyver)-libzfs
install-deps-dev: install-deps
if [ "`uname`" = "FreeBSD" ]; then pkg install -y gmake py$(pyver)-setuptools py$(pyver)-sqlite3; fi
install-dev: install-deps-dev install-python-requirements-dev
$(PYTHON) -m pip install -e .
install:
$(PYTHON) setup.py install
install-travis:
python$(TRAVIS_PYTHON_VERSION) -m pip install -IU flake8-mutable flake8-docstrings flake8-builtins flake8-mypy bandit==1.5.1 bandit-high-entropy-string
uninstall:
$(PYTHON) -m pip uninstall -y ioc
@if [ -f /usr/local/etc/rc.d/ioc ]; then \
rm /usr/local/etc/rc.d/ioc; \
fi
check:
flake8 --version
mypy --version
Expand All @@ -47,11 +31,9 @@ docs:
help:
@echo " install"
@echo " Installs libioc"
@echo " uninstall"
@echo " Removes libioc"
@echo " test"
@echo " Run unit tests with pytest"
@echo " check"
@echo " Run static linters & other static analysis tests"
@echo " install-dev"
@echo " Install dependencies needed to run `check`"
@echo " docs"
@echo " Generate documentation"
5 changes: 4 additions & 1 deletion libioc/Jail.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,14 +763,17 @@ def _start_dependant_jails(
yield jailDependantsStartEvent.skip("No dependant jails")
return

def _sort(x: JailResource) -> int:
return int(x.config["priority"])

dependant_jails = sorted(
libioc.Jails.JailsGenerator(
filters=_depends,
host=self.host,
logger=self.logger,
zfs=self.zfs
),
key=lambda x: x.config["priority"]
key=_sort
)

for dependant_jail in dependant_jails:
Expand Down
13 changes: 6 additions & 7 deletions libioc/ResourceUpdater.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,14 +589,13 @@ def _get_release_trunk_file_url(
filename: str
) -> str:

if release.name == "11.0-RELEASE":
release_name = "11.0.1"
else:
fragments = release.name.split("-", maxsplit=1)
release_name = f"{fragments[0]}.0"
fragments = release.name.split("-", maxsplit=1)
release_name = f"{fragments[0]}"

base_url = "https://cgit.freebsd.org/src/plain/"
query_string = f"?h=releng/{release_name}"

base_url = "https://svn.freebsd.org/base/release"
return f"{base_url}/{release_name}/{filename}"
return f"{base_url}{filename}{query_string}"

@property
def _base_release_symlink_location(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion libioc/ZFS.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def clone_dataset(
except libzfs.ZFSException as e:
snapshot_error = e

if delete_snapshot is True:
if (delete_snapshot is True) and (snapshot_error is not None):
snapshot.delete(recursive=True)

if snapshot_error is not None:
Expand Down
2 changes: 1 addition & 1 deletion libioc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class _IocModule(sys.modules["libioc"].__class__):
]

def __getattribute__(self, key: str) -> typing.Any:
if key == "VERSION":
if (key == "VERSION") or (key == "__version__"):
return _get_version()
if key.startswith("_") is True:
return super().__getattribute__(key)
Expand Down
3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

44 changes: 43 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
[metadata]
description-file = README.md
name = libioc
version = attr: libioc.__version__
description = A Python library to manage jails with ioc{age,cell}.
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/bsdci/libioc
author = Stefan Grönke
author_email = [email protected]
python_requires = >=3.6
platforms =
FreeBSD
license = BSD 2-Clause License
keywords =
FreeBSD
jail
iocage
iocell
classifiers =
License :: OSI Approved :: BSD 2-Clause License
Operating System :: POSIX :: BSD :: FreeBSD
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Typing :: Typed

[options]
zip_safe = False
include_package_data = True
packages = find:
install_requires =
gitpython
freebsd_sysctl==0.0.7
jail==0.0.14
tests_require =
pytest-runner
pytest
pytest-cov
pytest-pep8

[options.package_data]
* = VERSION

[mypy]
python_version = 3.7
Expand Down Expand Up @@ -41,6 +82,7 @@ disallow_untyped_defs=True
addopts = -v -x -rs --ignore=setup.py --pep8 --cov-report term-missing --no-cov-on-fail --cov=libioc libioc tests
pep8maxlinelength = 80
pep8ignore = * ALL

[aliases]
test=pytest

Expand Down
59 changes: 2 additions & 57 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,60 +23,5 @@
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
"""Installs libioc using setuptools."""
import sys
import typing
from setuptools import find_packages, setup
try:
from pip._internal.req import parse_requirements
except ModuleNotFoundError:
from pip.req import parse_requirements

try:
import setuptools_scm.integration
setuptools_scm.integration.find_files = lambda _: []
except ImportError:
pass


def _resolve_requirement(req: typing.Any) -> str:
if req.__class__.__name__ == "ParsedRequirement":
return str(req.requirement)
else:
return f"{req.name}{req.specifier}"


def _read_requirements(
filename: str="requirements.txt"
) -> typing.Dict[str, typing.List[str]]:
reqs = list(parse_requirements(filename, session="libioc"))
return dict(
install_requires=[_resolve_requirement(req) for req in reqs]
)


ioc_requirements = _read_requirements("requirements.txt")

if sys.version_info < (3, 6):
exit("Only Python 3.6 and higher is supported.")

with open("libioc/VERSION", "r") as f:
version = f.read().split()[0]

setup(
name='libioc',
license='BSD',
version=version,
description='A Python library to manage jails with ioc{age,cell}',
keywords='FreeBSD jail ioc',
author='ioc Contributors',
author_email='[email protected]',
url='https://github.com/bsdci/libioc',
python_requires='>=3.6',
packages=find_packages(include=["libioc", "libioc.*"]),
package_data={'': ['VERSION']},
include_package_data=True,
install_requires=ioc_requirements["install_requires"],
# setup_requires=['pytest-runner'],
tests_require=['pytest', 'pytest-cov', 'pytest-pep8']
)

from setuptools import setup
setup()