Skip to content

Commit

Permalink
Cherry pick changes (#427)
Browse files Browse the repository at this point in the history
* Fix relative imports (#426)
- No `..` should be used for package modules
- No `...` should be used for test code
* Fix compute abi tag (#424)
* Update vendorized pep425 to better support python 3.8
* Use packaging.tags to verify the pep425 module
* Test okonomiyaki on python 3.8
* Fix support python 2.7 for the pep425 tests
* Add packaging for test jenkins tests
* Use a separate test runner for Python 3.8
* Try to force a more recent packaging version
* Do not run the tests from the root folder
* Export the LANG environment variable to try and avoid encoding errors
* Another attempt at forcing package > 20.0
* We probably do not need to use unittest discover anymore
* Fix support to guess the system linux platform for Python 3.8
platform.linux_distribution is not available on python 3.8
This PR add `distro` as a dependcy for python 3.8, factors
out a _linux_distribution function to hide the differences and
updates the test and mocking code accordingly
* Minor cleanup
* Make path checks more robust on python 3.8
* Do not run test in the root folder on github
* Update tests to ignore packaging.tags which contain manylinux
Our code does not support the manylinux pep425 tags
* Fix abi guess from the runtime soabi variable
* More robust checks for the expected egg platform from the path
* Make sure that filepath is always lowercase
* More robust check for the egg paths
* Install packaging from pip in the jenkins tests
* Fix flake8 errors
  • Loading branch information
itziakos authored Jul 1, 2021
1 parent 141e0bb commit cede5ae
Show file tree
Hide file tree
Showing 40 changed files with 158 additions and 148 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
tests:
strategy:
matrix:
python-version: [2.7, 3.6]
python-version: [2.7, 3.6, 3.8]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -24,7 +24,9 @@ jobs:
- name: Install test dependencies
run: python -m pip install -r "dev_requirements.txt"
- name: Test with haas
run: python -m haas okonomiyaki
run: |
cd jenkins
python -m haas okonomiyaki
code-lint:
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 4 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ environment:

global:
PYTHONUNBUFFERED: "1"
LANG: "ENG"

matrix:
- python: "C:/Python27-x64"
Expand All @@ -14,6 +15,8 @@ environment:
- python: "C:/Python35"
- python: "C:/Python36-x64"
- python: "C:/Python36"
- python: "C:/Python38-x64"
- python: "C:/Python38"

branches:
only:
Expand All @@ -35,4 +38,5 @@ install:
- cmd: pip install .
- cmd: pip install -r dev_requirements.txt
test_script:
- cmd: cd jenkins
- cmd: coverage run -m haas okonomiyaki
1 change: 1 addition & 0 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ flake8
mock
testfixtures
hypothesis
packaging >= 20.0
1 change: 1 addition & 0 deletions jenkins/test
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pipeline {
execute "edm envs create okonomiyaki-dev --force"
execute "edm install -e okonomiyaki-dev -y haas mock testfixtures hypothesis"
execute "edm run -e okonomiyaki-dev -- pip install -e ."
execute "edm run -e okonomiyaki-dev -- pip install 'packaging >= 20.0'"
}
}

Expand Down
4 changes: 2 additions & 2 deletions okonomiyaki/_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import zipfile2

from ..file_formats import EggMetadata
from ..versions import MetadataVersion
from okonomiyaki.file_formats import EggMetadata
from okonomiyaki.versions import MetadataVersion


def _metadata_from_path(path, sha256):
Expand Down
30 changes: 12 additions & 18 deletions okonomiyaki/file_formats/_egg_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,25 @@
from attr import attr, attributes
from attr.validators import instance_of, optional

from ..errors import (
from okonomiyaki.errors import (
InvalidRequirementString, InvalidRequirementStringHyphen,
InvalidEggName, InvalidMetadataField,
MissingMetadata, UnsupportedMetadata
)
from ..platforms import (
EPDPlatform, PlatformABI, PythonABI, PythonImplementation
)
from ..platforms.legacy import LegacyEPDPlatform
from ..utils import (
compute_sha256, decode_if_needed, encode_if_needed, parse_assignments
)
from ..utils.py3compat import StringIO, string_types
from ..versions import EnpkgVersion, MetadataVersion
MissingMetadata, UnsupportedMetadata)
from okonomiyaki.platforms.legacy import LegacyEPDPlatform
from okonomiyaki.platforms import (
EPDPlatform, PlatformABI, PythonABI, PythonImplementation)
from okonomiyaki.utils import (
compute_sha256, decode_if_needed, encode_if_needed, parse_assignments)
from okonomiyaki.utils.py3compat import StringIO, string_types
from okonomiyaki.versions import EnpkgVersion, MetadataVersion
from .legacy import (
_guess_abi_tag, _guess_platform_abi, _guess_platform_tag, _guess_python_tag
)
_guess_abi_tag, _guess_platform_abi, _guess_platform_tag, _guess_python_tag)
from ._blacklist import (
EGG_PLATFORM_BLACK_LIST, EGG_PYTHON_TAG_BLACK_LIST,
may_be_in_platform_blacklist, may_be_in_python_tag_blacklist,
may_be_in_pkg_info_blacklist
)
may_be_in_pkg_info_blacklist)
from ._package_info import (
PackageInfo, _convert_if_needed, _keep_position, _read_pkg_info
)
PackageInfo, _convert_if_needed, _keep_position, _read_pkg_info)


_EGG_NAME_RE = re.compile(r"""
Expand Down
4 changes: 2 additions & 2 deletions okonomiyaki/file_formats/_package_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import zipfile2

from ..utils import py3compat, compute_sha256
from ..errors import OkonomiyakiError
from okonomiyaki.utils import py3compat, compute_sha256
from okonomiyaki.errors import OkonomiyakiError

from ._blacklist import EGG_PKG_INFO_BLACK_LIST, may_be_in_pkg_info_blacklist
from ._wheel_info import WheelInfo
Expand Down
6 changes: 3 additions & 3 deletions okonomiyaki/file_formats/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"""
import re

from ..errors import InvalidMetadataField
from ..platforms import PythonImplementation, default_abi
from ..versions import RuntimeVersion
from okonomiyaki.errors import InvalidMetadataField
from okonomiyaki.platforms import PythonImplementation, default_abi
from okonomiyaki.versions import RuntimeVersion

# To parse the python field in our index and spec/depend
_PYVER_RE = re.compile(r"(?P<major>\d+)\.(?P<minor>\d+)")
Expand Down
8 changes: 4 additions & 4 deletions okonomiyaki/file_formats/setuptools_egg.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
sysconfig = None
import warnings

from ..errors import OkonomiyakiError
from ..platforms import PythonImplementation
from ..utils import py3compat
from okonomiyaki.errors import OkonomiyakiError
from okonomiyaki.platforms import PythonImplementation
from okonomiyaki.utils import py3compat
from ._egg_info import _guess_python_tag
from ._package_info import PackageInfo

Expand Down Expand Up @@ -100,7 +100,7 @@ def _guess_abi_from_running_python():
soabi = None

if soabi and soabi.startswith('cpython-'):
return 'cp' + soabi.split('-', 1)[-1]
return 'cp' + soabi.split('-', 2)[1]
else:
return None

Expand Down
2 changes: 1 addition & 1 deletion okonomiyaki/file_formats/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import io
import os.path

from ... import repositories
from okonomiyaki import repositories

DATA_DIR = os.path.join(
os.path.dirname(repositories.__file__), "tests", "data")
Expand Down
24 changes: 10 additions & 14 deletions okonomiyaki/file_formats/tests/test__egg_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,25 @@
else:
import unittest

from ...errors import (
from okonomiyaki.errors import (
InvalidEggName, InvalidMetadataField, MissingMetadata, UnsupportedMetadata,
InvalidRequirementStringHyphen
)
from ...utils import tempdir
from ...utils.test_data import (
MKL_10_3_RH5_X86_64, NOSE_1_3_4_RH6_X86_64, NOSE_1_3_4_RH5_X86_64
)
from ...platforms import EPDPlatform, PlatformABI
from ...platforms.legacy import LegacyEPDPlatform
from ...versions import EnpkgVersion, MetadataVersion
InvalidRequirementStringHyphen)
from okonomiyaki.utils import tempdir
from okonomiyaki.utils.test_data import (
MKL_10_3_RH5_X86_64, NOSE_1_3_4_RH6_X86_64, NOSE_1_3_4_RH5_X86_64)
from okonomiyaki.platforms import EPDPlatform, PlatformABI
from okonomiyaki.platforms.legacy import LegacyEPDPlatform
from okonomiyaki.versions import EnpkgVersion, MetadataVersion

from .._egg_info import (
Requirement, EggMetadata, LegacySpecDepend, parse_rawspec,
split_egg_name
)
split_egg_name)

from .common import (
BROKEN_MCCABE_EGG, DATA_DIR, ENSTALLER_EGG, ETS_EGG,
FAKE_MEDIALOG_BOARDFILE_1_6_1_EGG, FAKE_MEDIALOG_BOARDFILE_1_6_1_PKG_INFO,
MKL_EGG, NUMEXPR_2_2_2_EGG, PYMULTINEST_EGG, _OSX64APP_EGG,
PYSIDE_1_0_3_EGG, XZ_5_2_0_EGG
)
PYSIDE_1_0_3_EGG, XZ_5_2_0_EGG)


M = MetadataVersion.from_string
Expand Down
2 changes: 1 addition & 1 deletion okonomiyaki/file_formats/tests/test__package_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import unittest

from okonomiyaki.utils.test_data import OKONOMIYAKI_0_17_0_PY2
from ...errors import OkonomiyakiError
from okonomiyaki.errors import OkonomiyakiError
from .common import (
BROKEN_MCCABE_EGG, PIP_EGG, PKG_INFO_ENSTALLER_1_0_DESCRIPTION,
PIP_PKG_INFO, PKG_INFO_ENSTALLER_1_0, PYMULTINEST_EGG, SUPERVISOR_EGG,
Expand Down
8 changes: 4 additions & 4 deletions okonomiyaki/file_formats/tests/test_egg_file_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

import os.path as op

from ...platforms import EPDPlatform
from ...utils import compute_md5
from ...utils import py3compat
from ...versions import EnpkgVersion
from okonomiyaki.platforms import EPDPlatform
from okonomiyaki.utils import compute_md5
from okonomiyaki.utils import py3compat
from okonomiyaki.versions import EnpkgVersion

from ..egg import EggBuilder, EggRewriter
from .._egg_info import Dependencies, EggMetadata, LegacySpecDepend
Expand Down
2 changes: 1 addition & 1 deletion okonomiyaki/platforms/_arch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from attr import attr, attributes
from attr.validators import instance_of

from ..errors import OkonomiyakiError
from okonomiyaki.errors import OkonomiyakiError


@enum.unique
Expand Down
3 changes: 2 additions & 1 deletion okonomiyaki/platforms/_pep425_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def get_abi_tag():
if get_flag('WITH_PYMALLOC',
lambda: impl == 'cp',
warn=(impl == 'cp')):
m = 'm'
if sys.version_info < (3, 8):
m = 'm'
if get_flag('Py_UNICODE_SIZE',
lambda: sys.maxunicode == 0x10ffff,
expected=4,
Expand Down
21 changes: 17 additions & 4 deletions okonomiyaki/platforms/_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from attr import attr, attributes
from attr.validators import instance_of

from ..errors import OkonomiyakiError
from okonomiyaki.errors import OkonomiyakiError

from ._arch import Arch

Expand Down Expand Up @@ -153,9 +153,7 @@ def _guess_platform_details(os_kind):
elif os_kind == OSKind.darwin:
return FamilyKind.mac_os_x, NameKind.mac_os_x, platform.mac_ver()[0]
elif os_kind == OSKind.linux:
name = platform.linux_distribution()[0].lower()
name = name.split()[0]
_, release, _ = platform.dist()
name, release = _linux_distribution()
try:
name_kind = NameKind[name]
except KeyError:
Expand Down Expand Up @@ -183,3 +181,18 @@ def _guess_platform(arch_string=None):
family_kind, name_kind, release = _guess_platform_details(os_kind)

return Platform(os_kind, name_kind, family_kind, release, arch, machine)


def _linux_distribution():
""" Get the linux distribution of the running system.
"""
try:
name, release, _ = platform.linux_distribution()
except AttributeError:
# We are probably running on Python > 3.8
# see https://docs.python.org/3.6/library/platform.html?highlight=linux_distribution#unix-platforms
import distro
name, release, _ = distro.linux_distribution()
name = name.split()[0]
return name.lower(), release
4 changes: 2 additions & 2 deletions okonomiyaki/platforms/abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from attr import attributes, attr
from attr.validators import instance_of

from ..errors import OkonomiyakiError
from ..versions import RuntimeVersion
from okonomiyaki.errors import OkonomiyakiError
from okonomiyaki.versions import RuntimeVersion

from .epd_platform import EPDPlatform
from ._platform import OSKind
Expand Down
4 changes: 2 additions & 2 deletions okonomiyaki/platforms/epd_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from attr import attributes, attr
from attr.validators import instance_of

from ..versions import RuntimeVersion
from ..errors import OkonomiyakiError, InvalidPEP440Version
from okonomiyaki.versions import RuntimeVersion
from okonomiyaki.errors import OkonomiyakiError, InvalidPEP440Version
from ._arch import Arch, ArchitectureKind
from ._platform import OSKind, FamilyKind, NameKind, Platform

Expand Down
2 changes: 1 addition & 1 deletion okonomiyaki/platforms/legacy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from attr import attributes, attr
from attr.validators import instance_of

from ..errors import OkonomiyakiError
from okonomiyaki.errors import OkonomiyakiError

from .epd_platform import EPDPlatform

Expand Down
2 changes: 1 addition & 1 deletion okonomiyaki/platforms/platform_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from attr import attr, attributes
from attr.validators import instance_of, optional

from ..errors import OkonomiyakiError
from okonomiyaki.errors import OkonomiyakiError

from ._arch import Arch
from .epd_platform import EPDPlatform
Expand Down
2 changes: 1 addition & 1 deletion okonomiyaki/platforms/python_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from attr import attributes, attr
from attr.validators import instance_of

from ..errors import InvalidMetadataField
from okonomiyaki.errors import InvalidMetadataField


_KIND_TO_ABBREVIATED = {
Expand Down
Loading

0 comments on commit cede5ae

Please sign in to comment.