Skip to content

Commit a7a078f

Browse files
committedAug 3, 2021
change pip packaging to have actual separate packages for besapi and bescli
1 parent 1dfb3aa commit a7a078f

16 files changed

+592
-454
lines changed
 

‎.flake8

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[flake8]
2+
select = B,C,E,F,P,W,B9
3+
max-line-length = 88
4+
extend-ignore = E203, W503, F401
5+
6+
### DEFAULT IGNORES FOR 4-space INDENTED PROJECTS ###
7+
# E127, E128 are hard to silence in certain nested formatting situations.
8+
# E203 doesn't work for slicing
9+
# E265, E266 talk about comment formatting which is too opinionated.
10+
# E402 warns on imports coming after statements. There are important use cases
11+
# that require statements before imports.
12+
# E501 is not flexible enough, we're using B950 instead.
13+
# E722 is a duplicate of B001.
14+
# P207 is a duplicate of B003.
15+
# P208 is a duplicate of C403.
16+
# W503 talks about operator formatting which is too opinionated.
17+
ignore = E127, E128, E203, E265, E266, E402, E501, E722, P207, P208, W503
18+
exclude =
19+
.git
20+
__pycache__

‎.github/workflows/test_build.yaml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
name: test_build
3+
4+
on:
5+
push:
6+
paths:
7+
- "**.py"
8+
- "setup.cfg"
9+
- "MANIFEST.in"
10+
- "pyproject.toml"
11+
- "requirements.txt"
12+
- ".github/workflows/test_build.yaml"
13+
- ".github/workflows/tag_and_release.yaml"
14+
pull_request:
15+
paths:
16+
- "**.py"
17+
- "setup.cfg"
18+
- "MANIFEST.in"
19+
- "pyproject.toml"
20+
- "requirements.txt"
21+
- ".github/workflows/test_build.yaml"
22+
- ".github/workflows/tag_and_release.yaml"
23+
24+
jobs:
25+
test_build:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v2
29+
- name: Set up Python
30+
uses: actions/setup-python@v2
31+
with:
32+
python-version: 3.8
33+
- name: Install requirements
34+
run: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
35+
- name: Install build tools
36+
run: pip install setuptools wheel build
37+
- name: Run build
38+
run: python3 -m build
39+
- name: Get Wheel File Path
40+
id: getwheelfile
41+
shell: bash
42+
run: echo "::set-output name=wheelfile::$(find "dist" -type f -name "*.whl")"
43+
- name: Test pip install of wheel
44+
run: pip install ${{ steps.getwheelfile.outputs.wheelfile }}

‎.github/workflows/yamllint.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: yamllint
3+
4+
on:
5+
push:
6+
paths:
7+
- "**.yaml"
8+
- "**.yml"
9+
pull_request:
10+
paths:
11+
- "**.yaml"
12+
- "**.yml"
13+
14+
jobs:
15+
yamllint:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v2
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: 3.8
24+
25+
- name: Install yamllint
26+
run: pip install yamllint
27+
28+
- name: Lint YAML files
29+
run: yamllint . -f parsable

‎.pylintrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[MESSAGES CONTROL]
2+
disable = C0330, C0326, C0103, c-extension-no-member
3+
4+
[format]
5+
max-line-length = 88

‎.yamllint.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
# for some reason my github actions YAML trip this one but I don't understand why
6+
truthy:
7+
level: warning
8+
# 88 chars should be enough, but don't fail if a line is longer
9+
line-length:
10+
max: 88
11+
level: warning
12+
new-lines:
13+
level: warning

‎MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include schemas/*.xsd
1+
include src/besapi/schemas/*.xsd

‎setup.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setup(
99
name="besapi",
10-
version="0.6",
10+
version="0.7",
1111
author="Matt Hansen",
1212
author_email="hansen.m@psu.edu",
1313
description="Library for working with the BigFix REST API",
@@ -18,10 +18,11 @@
1818
"python-besapi is a Python library designed to "
1919
"interact with the BES (BigFix) REST API."
2020
),
21-
py_modules=["besapi", "bescli"],
21+
packages=["besapi","bescli"],
2222
package_data={
2323
"besapi": ["schemas/*.xsd"],
2424
},
2525
install_requires=["requests", "lxml", "cmd2"],
2626
include_package_data=True,
27+
package_dir={"": "src"},
2728
)

‎__init__.py ‎src/besapi/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# https://stackoverflow.com/questions/279237/import-a-module-from-a-relative-path/4397291
22

3-
from .besapi import *
3+
from . import besapi
4+

‎src/besapi/__main__.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"""
2+
To run this module directly
3+
"""
4+
from bescli import bescli
5+
6+
bescli.main()

‎besapi.py ‎src/besapi/besapi.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
Library for communicating with the BES (BigFix) REST API.
1111
"""
1212

13+
import site
14+
import os.path
15+
1316
import requests
1417
from lxml import etree, objectify
1518
from pkg_resources import resource_filename
@@ -171,7 +174,11 @@ def objectify_text(self, text):
171174
return objectify.fromstring(root_xml)
172175

173176
def main():
174-
import bescli
177+
try:
178+
from bescli import bescli
179+
except ImportError:
180+
site.addsitedir(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
181+
from bescli import bescli
175182
bescli.main()
176183

177184

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)
Please sign in to comment.