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

Update default python version #751

Merged
merged 23 commits into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fa49f4f
set default Python version to 3.7
gronke Mar 21, 2020
74146ef
describe how to install libioc from Makefile for other Python versions
gronke Mar 21, 2020
9b0ebcc
Rename Iocage Handbook to Ioc Handbook in README
gronke Mar 21, 2020
7613cae
detect latest available Python 3 version as default in Makefile
gronke Apr 13, 2020
e1efe34
install dev-dependencies with selected Python version
gronke Apr 13, 2020
0b6a71d
update Python dependencies to latest freebsd_sysctl and jail
gronke Apr 13, 2020
4f55423
accept PYTHON_VERSION env variable in Makefile
gronke Apr 13, 2020
28e715c
update Travis Python version to 3.7
gronke Apr 13, 2020
c6620cc
fall back to TRAVIS_PYTHON_VERSION in Makefile
gronke Apr 13, 2020
02b3780
respect TRAVIS_PYTHON_VERSION in install travis make task
gronke Apr 13, 2020
0771520
print mypy version in make check task
gronke Apr 13, 2020
820afc7
run FreeBSD 12.1 on Cirrus CI
gronke Apr 13, 2020
9e05bcf
explicitly type fcntl.ioctl function
gronke Apr 13, 2020
2906aa4
update py-jail dependency to 0.0.11
gronke Apr 13, 2020
b5a7243
disable ZFS mnttab_cache
gronke Apr 20, 2020
e37489e
chore: look for mountpoint, not dataset name in tests
gronke Apr 20, 2020
71f058e
suppress pkg warnings with IGNORE_OSVERSION=yes on host pkg update
gronke Apr 20, 2020
a1ec49a
chore: print system info and config in Cirrus CI install task
gronke Apr 20, 2020
eba2847
tests: skip VNET tests when if_epair is not loaded
gronke Apr 20, 2020
aa39e1a
document what the Make string replacement expression does
igalic Apr 7, 2020
71690e9
update python version in .travis and setup.cfg
igalic Apr 12, 2020
2c95e2b
we don't need cython to build, but we do need setuptools!
igalic Apr 7, 2020
77f7229
update FreeBSD release on cirrus ci as well!
igalic Apr 6, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
task:
freebsd_instance:
matrix:
#image: freebsd-11-2-release-amd64
image: freebsd-12-0-release-amd64
image: freebsd-12-1-release-amd64
pip_cache:
folder: ~/.cache/pip
fingerprint_script: cat requirements*
Expand All @@ -15,6 +14,11 @@ task:
zpool create -m "/.ioc-test-`uname -r`" "ioc-test-`uname -r`" "/pools/ioc-test-`uname -r`.img"
zfs set compression=lz4 "ioc-test-`uname -r`"
install_script:
- uname -a
- uname -KU
- kldstat
- sysrc -a
- sysctl -a
- mount -t fdescfs null /dev/fd
- pkg install -y git
- make install-dev
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: python
python:
- "3.6"
- "3.7"
sudo: false
env:
- MYPYPATH="$TRAVIS_BUILD_DIR/.travis/mypy-stubs"
Expand Down
7 changes: 6 additions & 1 deletion .travis/mypy-stubs/libzfs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ class ZFS:
pools: Generator[ZFSPool, None, None] = ...
snapshots: Generator[ZFSSnapshot, None, None] = ...
__pyx_vtable__ = ... # type: Any
def __init__(self, history: bool=True, history_prefix: str='') -> None: ...
def __init__(
self,
history: bool=True,
history_prefix: str='',
mnttab_cache: bool=True
) -> None: ...
def create(
self,
name: str,
Expand Down
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ JAIL_NIC?=vtnet0
JAIL_IP?=172.16.0
JAIL_NET?=16
MYPYPATH = $(shell pwd)/.travis/mypy-stubs
PYTHON ?= python3.6

PYTHON_VERSION ?= $(TRAVIS_PYTHON_VERSION)
SELECTED_PYTHON_VERSION != if [ "$(PYTHON_VERSION)" != "" ]; then echo $(PYTHON_VERSION); else pkg info -g 'python3*' | cut -d'-' -f1 | sed 's/^python//' | sort -n | tail -n1 | sed -r 's/^([0-9])([0-9]+)/\1.\2/'; fi
PYTHON ?= python${SELECTED_PYTHON_VERSION}
# turn python3.7 -> 3.7 -> 37
pyver= ${PYTHON:S/^python//:S/.//:C/\([0-9]+\)/\1/}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given that we already have LATEST_PYTHON_VERSION we can use this directly here


.if $(pyver) < 35
Expand All @@ -19,20 +22,21 @@ install-python-requirements:
install-python-requirements-dev: install-python-requirements
$(PYTHON) -m pip install -Ur requirements-dev.txt
install-deps:
pkg install -q -y libucl py$(pyver)-ucl py$(pyver)-cython rsync python$(pyver) py$(pyver)-libzfs
pkg install -q -y libucl py$(pyver)-ucl py$(pyver)-setuptools rsync python$(pyver) py$(pyver)-libzfs
install-deps-dev: install-deps
if [ "`uname`" = "FreeBSD" ]; then pkg install -y gmake py36-sqlite3; fi
if [ "`uname`" = "FreeBSD" ]; then pkg install -y gmake py$(pyver)-sqlite3; fi
install-dev: install-deps-dev install-python-requirements-dev
$(PYTHON) -m pip install -e .
install-travis:
python3.6 -m pip install -IU flake8-mutable flake8-docstrings flake8-builtins flake8-mypy bandit==1.5.1 bandit-high-entropy-string
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
flake8 --exclude=".travis,.eggs,__init__.py,docs,tests" --ignore=E203,E252,W391,D107,A001,A002,A003,A004,D412,D413,T499
bandit --skip B404,B110 --exclude tests/ -r .
test:
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ cd libioc
make install
```

At the current time libiocage is not packaged or available in FreeBSD ports.
The default Python version is 3.7. If you intend to run libioc from another version, please specify it during the installation:

```sh
make PYTHON=python3.8 install
```

At the current time libioc is not packaged or available in FreeBSD ports.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not entirely true…
https://www.freshports.org/devel/py-libioc it just… still doesn't have all the right dependencies…

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, let's tackle this at a different time. Would you open an Issue as a reminder? 💜


## Documentation

- Iocage Handbook: https://bsdci.github.io/handbook
- Ioc Handbook: https://bsdci.github.io/handbook
- Reference Documentation: https://bsdci.github.io/libioc
- Gitter Chat: https://gitter.im/libioc/community

Expand Down
3 changes: 2 additions & 1 deletion libioc/Pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ def _update_host_repo(self, release_major_version: int) -> None:
logger=self.logger,
env=dict(
ABI=self.__get_abi_string(release_major_version),
SIGNATURE_TYPE="fingerprints"
SIGNATURE_TYPE="fingerprints",
IGNORE_OSVERSION="yes"
)
)

Expand Down
6 changes: 5 additions & 1 deletion libioc/ZFS.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,11 @@ def get_zfs(
history_prefix: str="<iocage>"
) -> ZFS:
"""Get an instance of iocages enhanced ZFS class."""
zfs = ZFS(history=history, history_prefix=history_prefix)
zfs = ZFS(
history=history,
history_prefix=history_prefix,
mnttab_cache=False
)
zfs.logger = libioc.helpers_object.init_logger(zfs, logger)
return zfs

Expand Down
7 changes: 6 additions & 1 deletion libioc/helpers_ioctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ def get_sockio_ioctl(nic_name: str, ioctl: SOCKIO_IOCTLS) -> bytes:
"""Query a sockio ioctl for a given NIC."""
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0) as sock:
ifconf = struct.pack('256s', nic_name.encode("UTF-8")[:15])
return bytes(fcntl.ioctl(sock.fileno(), ioctl.value, ifconf))
return bytes(fcntl.ioctl(
sock.fileno(),
int(ioctl.value),
bytes(ifconf),
True
))


def get_interface_ip4_address(nic_name: str) -> ipaddress.IPv4Address:
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
gitpython
freebsd_sysctl==0.0.6
jail==0.0.8
freebsd_sysctl==0.0.7
jail==0.0.11
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description-file = README.md

[mypy]
python_version = 3.6
python_version = 3.7
# override flake8-mypy defaults, since we provide (missing) types
platform='freebsd'

Expand Down
20 changes: 10 additions & 10 deletions tests/test_Jail.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_can_be_started(
assert existing_jail.running is True

stdout = subprocess.check_output(
[f"/sbin/mount | grep {existing_jail.root_dataset.name}"],
[f"/sbin/mount | grep {existing_jail.root_dataset.mountpoint}"],
shell=True
).decode("utf-8")

Expand All @@ -104,15 +104,15 @@ def test_can_mount_devfs(

existing_jail.start()
stdout = subprocess.check_output(
[f"/sbin/mount | grep {existing_jail.root_dataset.name}"],
[f"/sbin/mount | grep {existing_jail.root_dataset.mountpoint}"],
shell=True
).decode("utf-8")
assert "/dev" in stdout
assert "/dev/fd" not in stdout

existing_jail.stop()
stdout = subprocess.check_output(
[f"/sbin/mount | grep {existing_jail.root_dataset.name}"],
[f"/sbin/mount | grep {existing_jail.root_dataset.mountpoint}"],
shell=True
).decode("utf-8")
assert "/dev" not in stdout
Expand All @@ -128,15 +128,15 @@ def test_can_mount_fdescfs(

existing_jail.start()
stdout = subprocess.check_output(
[f"/sbin/mount | grep {existing_jail.root_dataset.name}"],
[f"/sbin/mount | grep {existing_jail.root_dataset.mountpoint}"],
shell=True
).decode("utf-8")
assert "/dev/fd" in stdout
assert "/dev (" not in stdout

existing_jail.stop()
stdout = subprocess.check_output(
[f"/sbin/mount | grep {existing_jail.root_dataset.name}"],
[f"/sbin/mount | grep {existing_jail.root_dataset.mountpoint}"],
shell=True
).decode("utf-8")
assert "/dev/fd" not in stdout
Expand All @@ -152,15 +152,15 @@ def test_can_mount_devfs_and_fdescfs(

existing_jail.start()
stdout = subprocess.check_output(
[f"/sbin/mount | grep {existing_jail.root_dataset.name}"],
[f"/sbin/mount | grep {existing_jail.root_dataset.mountpoint}"],
shell=True
).decode("utf-8")
assert "/dev (" in stdout
assert "/dev/fd" in stdout

existing_jail.stop()
stdout = subprocess.check_output(
[f"/sbin/mount | grep {existing_jail.root_dataset.name}"],
[f"/sbin/mount | grep {existing_jail.root_dataset.mountpoint}"],
shell=True
).decode("utf-8")
assert "/dev (" not in stdout
Expand Down Expand Up @@ -242,9 +242,9 @@ def test_can_be_started(
existing_jail.start()
assert existing_jail.running is True

root_path = existing_jail.root_dataset.name
root_path = existing_jail.root_dataset.mountpoint
stdout = subprocess.check_output(
[f"/sbin/mount | grep {existing_jail.root_dataset.name}"],
[f"/sbin/mount | grep {existing_jail.root_dataset.mountpoint}"],
shell=True
).decode("utf-8")
assert "launch-scripts in stdout"
Expand All @@ -268,7 +268,7 @@ def test_can_be_stopped(
[f"/usr/sbin/jls", "-j", existing_jail.identifier]
).decode("utf-8")

root_path = existing_jail.root_dataset.name
root_path = existing_jail.root_dataset.mountpoint
stdout = subprocess.check_output(
[f"/sbin/mount | grep {root_path}"],
shell=True
Expand Down
16 changes: 16 additions & 0 deletions tests/test_VNET.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
"""Unit tests for VNET."""
import pytest
import json
import os
import subprocess
Expand All @@ -31,6 +32,21 @@

import libioc.Jail


def is_epair_enabled() -> bool:
proc = subprocess.Popen(
["/sbin/kldstat", "-n", "if_epair"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL
)
proc.communicate()
return (proc.returncode == 0)


@pytest.mark.skipif(
(is_epair_enabled() is False),
reason="if_epair is not loaded"
)
class TestVNET(object):
"""Run tests for VNET networking."""

Expand Down