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

Loosen requirements and improve setup scripts #119

Merged
merged 10 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8"]
python-version: ["3.8"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8"]
python-version: ["3.8"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
jobs:
pytest:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9"]
permissions:
contents: read
id-token: write
Expand All @@ -30,11 +33,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements/requirements.txt

- name: Run pytest
run: |
access_token=$(az account get-access-token --scope api://88d2b022-3539-4dda-9e66-853801334a86/.default --query accessToken --output tsv)
echo ${#access_token}

export ACCESS_TOKEN=$access_token

pytest -q -s --token $access_token tests/test_sumo_thin_client.py
pytest -q -s -x --disable-warnings tests/test_sumo_thin_client.py
5 changes: 4 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import os

def pytest_addoption(parser):
parser.addoption("--token", action="store", default="")

def pytest_generate_tests(metafunc):
token = metafunc.config.option.token
# token = metafunc.config.option.token
token = os.environ.get("ACCESS_TOKEN")
token = token if len(token) > 0 else None

if "token" in metafunc.fixturenames:
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build-system]
requires = [
"pip>=19.1.1",
"setuptools>=28",
"setuptools_scm>=3.2.0",
"wheel"
]
7 changes: 0 additions & 7 deletions requirements.txt

This file was deleted.

7 changes: 7 additions & 0 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
msal>=1.18.0
msal-extensions>=1.0.0
requests>=2.24.0
pytest>=6.1.1
PyYAML>=5.4
setuptools>=49.2.1
pyjwt>=2.4.0
File renamed without changes.
30 changes: 29 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,37 @@
# -*- coding: utf-8 -*-

from setuptools import setup, find_packages
from pip._internal.req import parse_requirements as parse
from urllib.parse import urlparse


def _format_requirement(req):
print(req)
if req.is_editable:
# parse out egg=... fragment from VCS URL
parsed = urlparse(req.requirement)
egg_name = parsed.fragment.partition("egg=")[-1]
without_fragment = parsed._replace(fragment="").geturl()
return f"{egg_name} @ {without_fragment}"
return req.requirement


def parse_requirements(fname):
"""Turn requirements.txt into a list"""
reqs = parse(fname, session="test")
return [_format_requirement(ir) for ir in reqs]


REQUIREMENTS = parse_requirements("requirements/requirements.txt")
REQUIREMENTS_DOCS = parse_requirements("requirements/requirements_docs.txt")

EXTRAS_REQUIRE = {"docs": REQUIREMENTS_DOCS}


setup(
name="sumo-wrapper-python",
description="Python wrapper for the Sumo API",
license="Apache 2.0",
url="https://github.com/equinor/sumo-wrapper-python",
keywords="sumo, python",
classifiers=[
Expand All @@ -15,11 +42,12 @@
],
use_scm_version={"write_to": "src/sumo/wrapper/version.py"},
author="Equinor ASA",
install_requires=["requests", "msal", "PyYAML", "setuptools"],
install_requires=REQUIREMENTS,
python_requires=">=3.4",
packages=find_packages("src"),
package_dir={"": "src"},
include_package_data=True,
zip_safe=False,
extras_require=EXTRAS_REQUIRE,
entry_points={"console_scripts": ["sumo_login = sumo.wrapper.login:main"]},
)