Skip to content

Commit

Permalink
Merge pull request #357 from phracek/get_rid_python2
Browse files Browse the repository at this point in the history
Remove python2 support
  • Loading branch information
rpitonak committed Feb 27, 2019
2 parents 4d91fea + 5b1b387 commit 458484b
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 232 deletions.
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if the problem has already been reported (or fixed in a master branch).

If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/user-cont/conu/issues/new).
Be sure to include a **descriptive title and a clear description**. Ideally, please provide:
* version of conu you are using (`rpm -q python2-conu python3-conu` or `pip freeze | grep conu`)
* version of conu you are using (`rpm -q python3-conu` or `python3 -m pip freeze | grep conu`)
* version of container runtime you are using (`rpm -qa | grep docker`)
* the command you executed, output and ideally please describe the image, container that you are trying to test

Expand Down
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ RUN ./requirements.sh && \
dnf clean all

COPY . /src
RUN pip3 install . && \
pip2 install .
RUN pip3 install .
1 change: 0 additions & 1 deletion Dockerfile.tests
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM docker.io/usercont/conu:dev

RUN dnf install -y nmap-ncat make && \
pip2 install --user -r tests/requirements.txt && \
pip3 install --user -r tests/requirements.txt

# a solution to set cgroup_manager to cgroupfs since we don't have
Expand Down
12 changes: 1 addition & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ exec-test:
cat pytest.ini
@# use it like this: `make exec-test TEST_TARGET="tests/unit/"`
PYTHONPATH=$(CURDIR) pytest-3 $(TEST_TARGET) --verbose --showlocals
PYTHONPATH=$(CURDIR) pytest-2 $(TEST_TARGET) --verbose --showlocals

check: test

Expand Down Expand Up @@ -49,7 +48,7 @@ build-test-container:
# You have to run 'sudo make install-test-requirements' prior to this.
test: build-test-container test-in-container test-doc-examples

centos-ci-test: install-test-requirements container-image build-test-container test-in-container srpm
centos-ci-test: install-test-requirements container-image build-test-container test-in-container

test-in-container:
@# use it like this: `make test-in-container TEST_TARGET=tests/integration/test_utils.py`
Expand All @@ -76,7 +75,6 @@ test-in-vm:
test-doc-examples: install
for file in $$(ls $(DOC_EXAMPLE_PATH)) ; do \
echo "Checking example file $$file" ; \
PYTHONPATH=$(CURDIR) python2 $(DOC_EXAMPLE_PATH)/$$file || exit ; \
PYTHONPATH=$(CURDIR) python3 $(DOC_EXAMPLE_PATH)/$$file || exit ; \
done

Expand All @@ -103,14 +101,6 @@ rpm-in-mock-f29: srpm
rpm-in-mock-rawhide: srpm
mock --rebuild -r fedora-rawhide-x86_64 ./*.src.rpm

rpm-in-mock-el7: srpm
mock --rebuild -r epel-7-x86_64 ./*.src.rpm

install-conu-rpm-in-centos-container: rpm-in-mock-el7
docker run -v "/var/lib/mock/epel-7-x86_64/result:/conu" -ti centos:7 bash -c " \
yum install -y /conu/python2-conu-*.el7.centos.noarch.rpm && \
python2 -c 'import conu; print conu.version'"

install-conu-rpm-in-f29-container: rpm-in-mock-f29
docker run \
-v "/var/lib/mock/fedora-29-x86_64/result:/conu" \
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and is handy when playing with containers inside your code.
It defines an API to access and manipulate containers,
images and provides more, very helpful functions.

`conu` is supported on python 3.6+ only.

![example](./docs/example.gif)

# Installation
Expand All @@ -28,7 +30,7 @@ $ pip install --user conu
If you are running Fedora, we have packaged `conu` in an RPM:

```
$ dnf install python{2,3}-conu
$ dnf install python3-conu
```

Please visit [our documentation](http://conu.readthedocs.io/en/latest/installation.html) for more info on installation.
Expand Down
3 changes: 0 additions & 3 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ Vagrant.configure(2) do |config|
sudo dnf install -y systemd-container make
sudo make install-requirements
sudo make install-test-requirements
sudo pip2 install --user -r tests/requirements.txt
sudo pip2 install --user -r requirements.txt
sudo pip2 install --user .
sudo pip3 install --user -r tests/requirements.txt
sudo pip3 install --user -r requirements.txt
sudo pip3 install --user .
Expand Down
104 changes: 0 additions & 104 deletions conu.spec
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
%global pypi_name conu

%if 0%{?rhel} && 0%{?rhel} <= 7
%bcond_with python3
%else
%bcond_without python3
%endif

Name: %{pypi_name}
Version: 0.7.0
Release: 1%{?dist}
Expand All @@ -21,77 +15,12 @@ ExcludeArch: ppc64

# for docs

%if %{with python3}
%endif

%description
`conu` is a library which makes it easy to write tests for your containers
and is handy when playing with containers inside your code.
It defines an API to access and manipulate containers,
images and provides more, very helpful functions.

%if (0%{?fedora} && 0%{?fedora} <= 29) || (0%{?rhel} && 0%{?rhel} <= 7)
%package -n python2-%{pypi_name}
Summary: %{summary}
%{?python_provide:%python_provide python2-%{pypi_name}}
BuildRequires: python2-devel
BuildRequires: python2-setuptools
%if 0%{?rhel} && 0%{?rhel} <= 7
BuildRequires: python-docker-py
BuildRequires: python-enum34
BuildRequires: python-kubernetes
Requires: python-kubernetes
Requires: python-docker-py
Requires: python-enum34
Requires: python-requests
%else
BuildRequires: python2-docker
BuildRequires: python2-enum34
BuildRequires: python2-kubernetes
Requires: python2-kubernetes
Requires: python2-docker
Requires: python2-enum34
Requires: python2-requests
%endif
%if (0%{?fedora} && 0%{?fedora} <= 27) || (0%{?rhel} && 0%{?rhel} <= 7)
BuildRequires: pyxattr
Requires: pyxattr
%else
BuildRequires: python2-pyxattr
Requires: python2-pyxattr
%endif
Requires: python2-six
# this is the only way to create containers right now
Requires: docker
%if 0%{?rhel} && 0%{?rhel} <= 7
# no s2i on centos :<
# Requires: source-to-image
Requires: acl
Requires: libselinux-utils
%else
# these are optional but still recommended
Recommends: source-to-image
Recommends: acl
Recommends: libselinux-utils
%endif

%description -n python2-%{pypi_name}
`conu` is a library which makes it easy to write tests for your containers
and is handy when playing with containers inside your code.
It defines an API to access and manipulate containers,
images and provides more, very helpful functions.

%package -n python2-%{pypi_name}-pytest
Summary: fixtures which can be utilized via pytest
%{?python_provide:%python_provide python2-%{pypi_name}-pytest}
Requires: python2-pytest
Requires: python2-%{pypi_name}

%description -n python2-%{pypi_name}-pytest
fixtures which can be utilized via pytest
%endif

%if %{with python3}
%package -n python3-%{pypi_name}
Summary: %{summary}
%{?python_provide:%python_provide python3-%{pypi_name}}
Expand Down Expand Up @@ -128,17 +57,10 @@ Requires: python3-%{pypi_name}

%description -n python3-%{pypi_name}-pytest
fixtures which can be utilized via pytest
%endif

%package -n %{pypi_name}-doc
Summary: conu documentation
%if %{with python3}
BuildRequires: python3-sphinx
%else
%if (0%{?fedora} && 0%{?fedora} <= 29) || (0%{?rhel} && 0%{?rhel} <= 7)
BuildRequires: python2-sphinx
%endif # if fedora
%endif # if python3

%description -n %{pypi_name}-doc
Documentation for conu.
Expand All @@ -149,41 +71,16 @@ Documentation for conu.
rm -rf %{pypi_name}.egg-info

%build
%if (0%{?fedora} && 0%{?fedora} <= 29) || (0%{?rhel} && 0%{?rhel} <= 7)
%py2_build
%endif
%if %{with python3}
%py3_build
%endif

# generate html docs
PYTHONPATH="${PWD}:${PWD}/docs/" sphinx-build docs/source html
# remove the sphinx-build leftovers
rm -rf html/.{doctrees,buildinfo}

%install
%if %{with python3}
%py3_install
%endif
%if (0%{?fedora} && 0%{?fedora} <= 29) || (0%{?rhel} && 0%{?rhel} <= 7)
%py2_install
%endif

%if (0%{?fedora} && 0%{?fedora} <= 29) || (0%{?rhel} && 0%{?rhel} <= 7)
%files -n python2-%{pypi_name}
%license LICENSE
%doc README.md
%{python2_sitelib}/%{pypi_name}/
%{python2_sitelib}/%{pypi_name}-*.egg-info/
%exclude %{python2_sitelib}/tests
%exclude %{python3_sitelib}/fixtures

%files -n python2-%{pypi_name}-pytest
%license LICENSE
%{python2_sitelib}/%{pypi_name}/fixtures/
%endif

%if %{with python3}
%files -n python3-%{pypi_name}
%license LICENSE
%doc README.md
Expand All @@ -195,7 +92,6 @@ rm -rf html/.{doctrees,buildinfo}
%files -n python3-%{pypi_name}-pytest
%license LICENSE
%{python3_sitelib}/%{pypi_name}/fixtures/
%endif

%files -n %{pypi_name}-doc
%doc html
Expand Down
1 change: 0 additions & 1 deletion release-conf.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# list of major python versions that release-bot will build separate wheels for
python_versions:
- 3
- 2

# whether to release on fedora
fedora: true
Expand Down
13 changes: 6 additions & 7 deletions requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ source /etc/os-release

set -x

# In Dockerfile we install Python3 & Python2 packages from requirements.txt
# In Dockerfile we install Python3 packages from requirements.txt
# Here we install these rpms which are required by conu, either during testing or in runtime:
# - source-to-image, origin-clients, acl, docker, libselinux-utils: conu needs these binaries
# - pip: to have different binaries for Python3 & Python2
# - pytest: to have different binaries for Python3 & Python2
# - pip: to have different binaries for Python3
# - pytest: to have different binaries for Python3
# - pyxattr: to not build it from source
# - devel & gcc: to compile pyxattr if requirements.txt specifies different version than we install here

Expand All @@ -19,10 +19,9 @@ if [ -f /bin/dnf ]; then
dnf install -y acl docker libselinux-utils \
source-to-image \
origin-clients \
python3-pip python2-pip \
python3-pytest python2-pytest \
python3-pyxattr python2-pyxattr \
gcc python3-devel python2-devel \
python3-pip python3-pytest \
python3-pyxattr \
gcc python3-devel \
nmap-ncat \
podman
fi
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
enum34 ; python_version <= '2.7'
requests
six
docker
Expand Down
11 changes: 1 addition & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,7 @@ def get_requirements():
for line in fd.readlines():
if not line or line.startswith('-i'):
continue
parsed_line = line.split(';', 1)[0].strip()
packages.append(parsed_line)

# Sesheta dropped the '; python_version <= '2.7'' requirement from enum34 line which means
# that enum34 is being installed on python 3 and that actually breaks your workstation since
# re module is using enum -- you can't even use pip after you `pip3 install enum34`
# hence this is guard to make sure that we don't install enum34 on python3
if sys.version_info.major == 3:
packages.remove("enum34")

packages.append(line)
return packages


Expand Down
Loading

0 comments on commit 458484b

Please sign in to comment.