splight-cli 5.5.2__tar.gz → 5.6.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. splight_cli-5.6.1/.github/workflows/code-style.yaml +21 -0
  2. splight_cli-5.6.1/.github/workflows/developer.yaml +98 -0
  3. splight_cli-5.6.1/.github/workflows/pre-release.yaml +71 -0
  4. splight_cli-5.6.1/.github/workflows/release.yaml +72 -0
  5. splight_cli-5.6.1/.github/workflows/scripts/check_dev_version.py +27 -0
  6. splight_cli-5.6.1/.github/workflows/scripts/check_master_version.py +30 -0
  7. splight_cli-5.6.1/.github/workflows/scripts/check_pypi_version.py +39 -0
  8. splight_cli-5.6.1/.github/workflows/scripts/check_release_version.py +35 -0
  9. splight_cli-5.6.1/.github/workflows/scripts/check_version_uploaded.py +35 -0
  10. splight_cli-5.6.1/.github/workflows/scripts/cleanup_pypi.py +91 -0
  11. splight_cli-5.6.1/.github/workflows/scripts/requirements.txt +2 -0
  12. splight_cli-5.6.1/.gitignore +60 -0
  13. splight_cli-5.6.1/.pre-commit-config.yaml +10 -0
  14. splight_cli-5.6.1/Makefile +50 -0
  15. {splight_cli-5.5.2 → splight_cli-5.6.1}/PKG-INFO +18 -25
  16. splight_cli-5.6.1/pyproject.toml +117 -0
  17. splight_cli-5.6.1/splight_cli/engine/__init__.py +31 -0
  18. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/engine/manager/manager.py +0 -6
  19. splight_cli-5.6.1/uv.lock +1814 -0
  20. splight_cli-5.5.2/pyproject.toml +0 -72
  21. splight_cli-5.5.2/splight_cli/engine/__init__.py +0 -24
  22. {splight_cli-5.5.2 → splight_cli-5.6.1}/README.md +0 -0
  23. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/__init__.py +0 -0
  24. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/cli.py +0 -0
  25. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/component/__init__.py +0 -0
  26. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/component/component.py +0 -0
  27. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/component/exceptions.py +0 -0
  28. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/component/loaders.py +0 -0
  29. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/component/templates/.splightignore +0 -0
  30. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/component/templates/Initialization +0 -0
  31. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/component/templates/README.md +0 -0
  32. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/component/templates/auto_readme.md +0 -0
  33. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/component/templates/main.py +0 -0
  34. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/component/templates/spec.json +0 -0
  35. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/component/templates/tests.py +0 -0
  36. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/component/tests/__init__.py +0 -0
  37. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/component/tests/test_component_manager.py +0 -0
  38. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/component/utils.py +0 -0
  39. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/config/__init__.py +0 -0
  40. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/constants.py +0 -0
  41. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/engine/alert/__init__.py +0 -0
  42. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/engine/asset/__init__.py +0 -0
  43. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/engine/attribute/__init__.py +0 -0
  44. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/engine/component/__init__.py +0 -0
  45. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/engine/datalake/__init__.py +0 -0
  46. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/engine/file/__init__.py +0 -0
  47. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/engine/manager/__init__.py +0 -0
  48. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/engine/manager/exceptions.py +0 -0
  49. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/engine/manager/tests/test_datalake_manager.py +0 -0
  50. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/engine/manager/tests/test_resource_manager.py +0 -0
  51. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/engine/secret/__init__.py +0 -0
  52. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/tests/test_component/Initialization +0 -0
  53. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/tests/test_component/README.md +0 -0
  54. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/tests/test_component/main.py +0 -0
  55. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/tests/test_component/spec.json +0 -0
  56. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/tests/test_component/tests.py +0 -0
  57. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/utils/__init__.py +0 -0
  58. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/utils/input.py +0 -0
  59. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/utils/json.py +0 -0
  60. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/utils/loader.py +0 -0
  61. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/utils/pprint.py +0 -0
  62. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/utils/template.py +0 -0
  63. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/utils/yaml.py +0 -0
  64. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/version.py +0 -0
  65. {splight_cli-5.5.2 → splight_cli-5.6.1}/splight_cli/workspace/__init__.py +0 -0
@@ -0,0 +1,21 @@
1
+ name: Code Quality
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - master
7
+
8
+ jobs:
9
+ format:
10
+ runs-on: ubuntu-latest
11
+ name: Check Code Quality and Format
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - name: Install Python
15
+ uses: actions/setup-python@v5
16
+ with:
17
+ python-version: "3.11"
18
+ - name: Install latest uv and set Python version
19
+ uses: astral-sh/setup-uv@v6
20
+ - name: Lint
21
+ run: make check-format
@@ -0,0 +1,98 @@
1
+ # used when creating a feature branch for development
2
+ # enabling the creation of dev versions (x.y.z-devN) that are uploaded to pypi
3
+ # if the version is correct, that is, greater than the version of master and pypi
4
+ name: Developer
5
+ on: workflow_dispatch
6
+
7
+ env:
8
+ LIBRARY_NAME: "splight-cli"
9
+
10
+ jobs:
11
+ verify_version:
12
+ runs-on: ubuntu-latest
13
+ name: Verify version is higher than last PyPi package and master version
14
+ steps:
15
+ # get master version
16
+ - name: Checkout to master
17
+ uses: actions/checkout@v3
18
+ with:
19
+ ref: master
20
+
21
+ - name: Get version from master branch
22
+ run: |
23
+ if [ -f "setup.py" ]; then
24
+ echo "MASTER_VERSION=$(grep -E 'version' splight_cli/version.py | awk -F'\"' '{ print $2 }')" >> "$GITHUB_ENV"
25
+ else
26
+ echo "MASTER_VERSION=$(grep version pyproject.toml | awk '{print $3}' | tr -d '\"')" >> "$GITHUB_ENV"
27
+ fi
28
+
29
+ # get current branch version
30
+ - name: Checkout to feature branch
31
+ uses: actions/checkout@v3
32
+
33
+ - name: Checks if you are in the master branch
34
+ if: ${{ github.ref == 'refs/heads/master' }}
35
+ run: |
36
+ echo "Cannot run this action in the master branch."
37
+ exit 1
38
+
39
+ - name: Get version from feature branch
40
+ run: |
41
+ if [ -f "setup.py" ]; then
42
+ echo "CURRENT_VERSION=$(grep -E 'version' splight_cli/version.py | awk -F'\"' '{ print $2 }')" >> "$GITHUB_ENV"
43
+ else
44
+ echo "CURRENT_VERSION=$(grep version pyproject.toml | awk '{print $3}' | tr -d '\"')" >> "$GITHUB_ENV"
45
+ fi
46
+
47
+ - name: Set up Python
48
+ uses: actions/setup-python@v3
49
+ with:
50
+ python-version: "3.11"
51
+
52
+ # validate versions
53
+ - name: Validates version is a dev version.
54
+ run: python3 .github/workflows/scripts/check_dev_version.py ${{ env.CURRENT_VERSION }}
55
+
56
+ - name: Verifies the dev version is not uploaded.
57
+ run: python .github/workflows/scripts/check_version_uploaded.py ${{ env.CURRENT_VERSION }} $LIBRARY_NAME
58
+
59
+ upload_developer_to_pypi:
60
+ runs-on: ubuntu-latest
61
+ name: Upload the version to pypi only if it's a developer version
62
+ needs: [verify_version]
63
+ steps:
64
+ - name: Checkout to feature branch
65
+ uses: actions/checkout@v3
66
+
67
+ - name: Get version from feature branch
68
+ run: |
69
+ if [ -f "setup.py" ]; then
70
+ echo "CURRENT_VERSION=$(grep -E 'version' splight_cli/version.py | awk -F'\"' '{ print $2 }')" >> "$GITHUB_ENV"
71
+ else
72
+ echo "CURRENT_VERSION=$(grep version pyproject.toml | awk '{print $3}' | tr -d '\"')" >> "$GITHUB_ENV"
73
+ fi
74
+ - name: Set up Python
75
+ uses: actions/setup-python@v3
76
+ with:
77
+ python-version: "3.11"
78
+
79
+ - name: Install latest uv and set Python version
80
+ uses: astral-sh/setup-uv@v6
81
+
82
+ - name: Build package
83
+ run: uv build
84
+
85
+ - name: Load variable to decide whether to publish package
86
+ run: |
87
+ if [[ $CURRENT_VERSION =~ "dev" ]]; then
88
+ echo "PUBLISH_PACKAGE=true" >> "$GITHUB_ENV"
89
+ else
90
+ echo "PUBLISH_PACKAGE=false" >> "$GITHUB_ENV"
91
+ fi
92
+
93
+ - name: Publish package
94
+ uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
95
+ if: ${{ env.PUBLISH_PACKAGE == 'true' }}
96
+ with:
97
+ user: __token__
98
+ password: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,71 @@
1
+ # used when creating a pull request
2
+ # this step runs the tests, coding style and validates that the version is
3
+ # release and greater than the version of master and pypi
4
+ name: Pre Release
5
+ on:
6
+ pull_request:
7
+ types:
8
+ [opened, synchronize]
9
+ branches:
10
+ - master
11
+
12
+ env:
13
+ LIBRARY_NAME: "splight-cli"
14
+
15
+ jobs:
16
+ run_tests_and_coding_style:
17
+ runs-on: ubuntu-latest
18
+ name: Verify library tests and coding style
19
+ steps:
20
+ - name: Checkout to feature branch
21
+ uses: actions/checkout@v3
22
+
23
+ - name: Set up Python
24
+ uses: actions/setup-python@v3
25
+ with:
26
+ python-version: "3.11"
27
+
28
+ - name: Install latest uv and set Python version
29
+ uses: astral-sh/setup-uv@v6
30
+
31
+ - name: Install dependencies
32
+ run: |
33
+ uv sync
34
+
35
+ - name: Run tests
36
+ run: make test
37
+
38
+ verify_version:
39
+ runs-on: ubuntu-latest
40
+ name: Verify version is a valid release version and is higher than last PyPi package and master version
41
+ steps:
42
+ # get master version
43
+ - name: Checkout to master
44
+ uses: actions/checkout@v3
45
+ with:
46
+ ref: master
47
+
48
+ - name: Get version from master branch
49
+ run: echo "MASTER_VERSION=$(grep version pyproject.toml | head -1 | awk '{print $3}' | tr -d '\"')" >> "$GITHUB_ENV"
50
+
51
+ # get current branch version
52
+ - name: Checkout to feature branch
53
+ uses: actions/checkout@v3
54
+
55
+ - name: Set up Python
56
+ uses: actions/setup-python@v3
57
+ with:
58
+ python-version: "3.11"
59
+
60
+ - name: Get version from feature branch
61
+ run: echo "CURRENT_VERSION=$(grep version pyproject.toml | head -1 | awk '{print $3}' | tr -d '\"')" >> "$GITHUB_ENV"
62
+
63
+ # validate versions
64
+ - name: Verify version is a valid release version
65
+ run: python .github/workflows/scripts/check_release_version.py ${{ env.CURRENT_VERSION }}
66
+
67
+ - name: Verify version is greater than last pypi uploaded version
68
+ run: python .github/workflows/scripts/check_pypi_version.py ${{ env.CURRENT_VERSION }} $LIBRARY_NAME
69
+
70
+ - name: Verify version is greater than master version
71
+ run: python .github/workflows/scripts/check_master_version.py ${{ env.MASTER_VERSION }} ${{ env.CURRENT_VERSION }}
@@ -0,0 +1,72 @@
1
+ # used when a new feature has already been merged to master
2
+ # this step creates a new tag in the github repository, pushes the release
3
+ # version to pypi and deletes all dev versions
4
+ name: Release
5
+ on:
6
+ push:
7
+ branches:
8
+ - master
9
+
10
+ env:
11
+ LIBRARY_NAME: "splight-cli"
12
+
13
+ jobs:
14
+ tag_version:
15
+ runs-on: ubuntu-latest
16
+ name: Create tag version on github repository
17
+ steps:
18
+ - name: Checkout to feature branch
19
+ uses: actions/checkout@v3
20
+
21
+ - name: Get version from feature branch
22
+ run: echo "CURRENT_VERSION=$(grep version pyproject.toml | head -1 | awk '{print $3}' | tr -d '\"')" >> "$GITHUB_ENV"
23
+
24
+ - name: Create tag
25
+ uses: softprops/action-gh-release@v1
26
+ env:
27
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28
+ with:
29
+ name: Release ${{ env.CURRENT_VERSION }}
30
+ tag_name: ${{ env.CURRENT_VERSION }}
31
+
32
+ upload_release_to_pypi:
33
+ runs-on: ubuntu-latest
34
+ name: Upload release library version to pypi
35
+ needs: [tag_version]
36
+ steps:
37
+ - name: Checkout to feature branch
38
+ uses: actions/checkout@v3
39
+ - name: Set up Python
40
+ uses: actions/setup-python@v3
41
+ with:
42
+ python-version: "3.11"
43
+
44
+ - name: Install latest uv and set Python version
45
+ uses: astral-sh/setup-uv@v6
46
+
47
+ - name: Build package
48
+ run: uv build
49
+
50
+ - name: Publish package
51
+ uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
52
+ with:
53
+ user: __token__
54
+ password: ${{ secrets.PYPI_API_TOKEN }}
55
+
56
+ cleanup_pypi:
57
+ runs-on: ubuntu-latest
58
+ name: Remove all developer versions from pypi
59
+ needs: [upload_release_to_pypi]
60
+ steps:
61
+ - name: Checkout to feature branch
62
+ uses: actions/checkout@v3
63
+
64
+ # install requests and pypi-cleanup
65
+ - name: Install requirements
66
+ run: pip install -r .github/workflows/scripts/requirements.txt
67
+
68
+ - name: Get version from feature branch
69
+ run: echo "CURRENT_VERSION=$(grep version pyproject.toml | head -1 | awk '{print $3}' | tr -d '\"')" >> "$GITHUB_ENV"
70
+
71
+ - name: Remove all developer versions from pypi
72
+ run: python .github/workflows/scripts/cleanup_pypi.py $LIBRARY_NAME ${{ env.CURRENT_VERSION }} ${{ secrets.PYPI_USERNAME }} ${{ secrets.PYPI_PASSWORD}}
@@ -0,0 +1,27 @@
1
+ import sys
2
+
3
+ from pkg_resources import parse_version as parse
4
+
5
+
6
+ class VersionError(Exception):
7
+ """Raised when the feature version is not greater than the master
8
+ version."""
9
+
10
+
11
+ if __name__ == "__main__":
12
+ """Checks if the version is a developer version.
13
+
14
+ Parameters
15
+ ----------
16
+ version: The version from the feature branch
17
+
18
+ Raises
19
+ ------
20
+ VersionError if the version is not a developer version
21
+ """
22
+ version_line = sys.argv[1]
23
+
24
+ version = parse(version_line)
25
+
26
+ if not version.is_devrelease:
27
+ raise VersionError(f"Version {version} is not a developer version")
@@ -0,0 +1,30 @@
1
+ import sys
2
+
3
+ from pkg_resources import parse_version as parse
4
+
5
+
6
+ class VersionError(Exception):
7
+ """Raised when the feature version is not greater than the master
8
+ version."""
9
+
10
+
11
+ if __name__ == "__main__":
12
+ """Compares versions between the local repository and master.
13
+
14
+ Args:
15
+ old_version (arg 1) (str): local version number (x.y.z)
16
+ new_version (arg 2) (str): master version number (x.y.x)
17
+ Raises:
18
+ VersionError: if the local version is not greater than master version
19
+ """
20
+ old_version_line = sys.argv[1]
21
+ new_version_line = sys.argv[2]
22
+
23
+ master_version = parse(old_version_line)
24
+ project_version = parse(new_version_line)
25
+
26
+ if project_version <= master_version:
27
+ raise VersionError(
28
+ f"Feature version {project_version} is not greater than "
29
+ f"master version {master_version}"
30
+ )
@@ -0,0 +1,39 @@
1
+ import json
2
+ import sys
3
+ import urllib.request
4
+
5
+ from pkg_resources import parse_version as parse
6
+
7
+
8
+ class PypiVersionError(Exception):
9
+ """Raised when the version is not greater than the one on pypi."""
10
+
11
+
12
+ def get_pypi_version(project_name: str):
13
+ url = f"https://pypi.org/pypi/{project_name}/json"
14
+ response = urllib.request.urlopen(url)
15
+ version = json.loads(response.read())["info"]["version"]
16
+ return parse(version)
17
+
18
+
19
+ if __name__ == "__main__":
20
+ """Compares versions between the local repository and the package on pypi.
21
+
22
+ Args:
23
+ local_version (arg 1) (str): local version number (x.y.z)
24
+ project_name (arg 2) (str): name of the project on pypi
25
+ Raises:
26
+ PypiVersionError: if the local version is not greater than the one on
27
+ pypi
28
+ """
29
+ local_version = sys.argv[1]
30
+ project_name = sys.argv[2]
31
+
32
+ project_version = parse(local_version)
33
+ public_project_version = get_pypi_version(project_name)
34
+
35
+ if project_version <= public_project_version:
36
+ raise PypiVersionError(
37
+ f"Feature version {project_version} is not greater than "
38
+ f"uploaded version {public_project_version}"
39
+ )
@@ -0,0 +1,35 @@
1
+ import sys
2
+
3
+
4
+ class InvalidReleaseVersion(Exception):
5
+ """Raised when the version is not a valid release version."""
6
+
7
+
8
+ def is_release_version(str_version: str) -> bool:
9
+ try:
10
+ _ = tuple(int(i) for i in str_version.split("."))
11
+ except ValueError:
12
+ return False
13
+ else:
14
+ return True
15
+
16
+
17
+ if __name__ == "__main__":
18
+ """Verify if the format is release for a given string version.
19
+
20
+ Example:
21
+ - x.y.z: it's OK.
22
+ - x.y.x.dev0: raises InvalidReleaseVersion
23
+
24
+ Args:
25
+ version (arg 1) (str): current lib version number (x.y.z)
26
+ Raises:
27
+ InvalidReleaseVersion: if the current version is not a release
28
+ version.
29
+ """
30
+ string_version = sys.argv[1]
31
+ if not is_release_version(string_version):
32
+ raise InvalidReleaseVersion(
33
+ f"Current library version {string_version} is not a valid "
34
+ "release version."
35
+ )
@@ -0,0 +1,35 @@
1
+ import json
2
+ import sys
3
+ import urllib.request
4
+
5
+ from pkg_resources import parse_version as parse
6
+
7
+
8
+ class PypiVersionError(Exception):
9
+ """Raised if the local version was already uploaded to pypi."""
10
+
11
+
12
+ def get_pypi_versions(project_name: str):
13
+ url = f"https://pypi.org/pypi/{project_name}/json"
14
+ response = urllib.request.urlopen(url)
15
+ return [parse(r) for r in json.loads(response.read())["releases"].keys()]
16
+
17
+
18
+ if __name__ == "__main__":
19
+ """Checks the version was not uploaded.
20
+
21
+ Args:
22
+ local_version (arg 1) (str): local version number (x.y.z)
23
+ project_name (arg 2) (str): name of the project on pypi
24
+ Raises:
25
+ PypiVersionError: if the local version was already uploaded to pypi
26
+ """
27
+ local_version = sys.argv[1]
28
+ project_name = sys.argv[2]
29
+
30
+ project_version = parse(local_version)
31
+ uploaded_versions = get_pypi_versions(project_name)
32
+ if project_version in uploaded_versions:
33
+ raise PypiVersionError(
34
+ f"Feature version {project_version} is already uploaded to pypi."
35
+ )
@@ -0,0 +1,91 @@
1
+ import logging
2
+ import sys
3
+
4
+ import requests
5
+ from pypi_cleanup import CsfrParser
6
+
7
+
8
+ def delete_developer_versions(
9
+ package_name: str, release_version: str, username: str, password: str
10
+ ):
11
+ with requests.Session() as session:
12
+ # generate csrf token
13
+ with session.get("https://pypi.org/account/login/") as response:
14
+ response.raise_for_status()
15
+ form_action = "/account/login/"
16
+ parser = CsfrParser(form_action)
17
+ parser.feed(response.text)
18
+ if not parser.csrf:
19
+ raise ValueError(f"No CSFR found in {form_action}")
20
+ csrf = parser.csrf
21
+
22
+ # validate login
23
+ with session.post(
24
+ "https://pypi.org/account/login/",
25
+ data={
26
+ "csrf_token": csrf,
27
+ "username": username,
28
+ "password": password,
29
+ },
30
+ headers={"referer": "https://pypi.org/account/login/"},
31
+ ) as response:
32
+ response.raise_for_status()
33
+ if response.url == "https://pypi.org/account/login/":
34
+ logging.error(f"Login for user {username} failed")
35
+ return 1
36
+
37
+ # get developer versions to delete
38
+ with session.get(
39
+ f"https://pypi.org/pypi/{package_name}/json"
40
+ ) as response:
41
+ versions = list(response.json()["releases"].keys())
42
+ to_delete = [
43
+ version
44
+ for version in versions
45
+ if "dev" in version and release_version in version
46
+ ]
47
+
48
+ # delete versions
49
+ for version in to_delete:
50
+ logging.info(f"Deleting {package_name} version {version}")
51
+ form_action = f"/manage/project/{package_name}/release/{version}/"
52
+ form_url = f"https://pypi.org{form_action}"
53
+ with session.get(form_url) as response:
54
+ response.raise_for_status()
55
+ parser = CsfrParser(form_action, "confirm_delete_version")
56
+ parser.feed(response.text)
57
+ if not parser.csrf:
58
+ raise ValueError(f"No CSFR found in {form_action}")
59
+ csrf = parser.csrf
60
+ referer = response.url
61
+
62
+ with session.post(
63
+ form_url,
64
+ data={"csrf_token": csrf, "confirm_delete_version": version},
65
+ headers={"referer": referer},
66
+ ) as response:
67
+ response.raise_for_status()
68
+
69
+
70
+ if __name__ == "__main__":
71
+ """Remove all developer version from given release version
72
+
73
+ Args:
74
+ package_name (arg 1) (str): library package name (splight-lib)
75
+ release_version (arg 2) (str): current release version (x.y.z)
76
+ username (arg 3) (str): pypi account username
77
+ password (arg 4) (str): pypi account password
78
+ Raises:
79
+ ValueError: When CSRF fails.
80
+ """
81
+ package_name = sys.argv[1]
82
+ release_version = sys.argv[2]
83
+ username = sys.argv[3]
84
+ password = sys.argv[4]
85
+
86
+ public_project_version = delete_developer_versions(
87
+ package_name=package_name,
88
+ release_version=release_version,
89
+ username=username,
90
+ password=password,
91
+ )
@@ -0,0 +1,2 @@
1
+ requests==2.32.2
2
+ pypi-cleanup==0.1.4
@@ -0,0 +1,60 @@
1
+ # These are some examples of commonly ignored file patterns.
2
+ # You should customize this list as applicable to your project.
3
+ # Learn more about .gitignore:
4
+ # https://www.atlassian.com/git/tutorials/saving-changes/gitignore
5
+
6
+ *.svars
7
+ # Node artifact files
8
+ node_modules/
9
+ dist/
10
+ build/
11
+
12
+ # Compiled Java class files
13
+ *.class
14
+
15
+ # Compiled Python bytecode
16
+ *.py[cod]
17
+
18
+ # Log files
19
+ *.log
20
+
21
+ # Package files
22
+ *.jar
23
+
24
+ # Maven
25
+ target/
26
+ dist/
27
+
28
+ # JetBrains IDE
29
+ .idea/
30
+
31
+ # Unit test reports
32
+ TEST*.xml
33
+
34
+ # Generated by MacOS
35
+ .DS_Store
36
+
37
+ # Generated by Windows
38
+ Thumbs.db
39
+
40
+ # Applications
41
+ *.app
42
+ *.exe
43
+ *.war
44
+
45
+ # Large media files
46
+ *.mp4
47
+ *.tiff
48
+ *.avi
49
+ *.flv
50
+ *.mov
51
+ *.wmv
52
+
53
+ # Eggs
54
+ *.egg-info
55
+
56
+ # Cov report
57
+ .coverage
58
+
59
+ # Mise
60
+ mise.toml
@@ -0,0 +1,10 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ # Ruff version.
4
+ rev: v0.12.1
5
+ hooks:
6
+ # Run the linter.
7
+ - id: ruff-check
8
+ args: [ --fix ]
9
+ # Run the formatter.
10
+ - id: ruff-format
@@ -0,0 +1,50 @@
1
+ .PHONY: clean clean-test clean-pyc help
2
+ .DEFAULT_GOAL := help
3
+
4
+ define PRINT_HELP_PYSCRIPT
5
+ import re, sys
6
+
7
+ for line in sys.stdin:
8
+ match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
9
+ if match:
10
+ target, help = match.groups()
11
+ print("%-20s %s" % (target, help))
12
+ endef
13
+ export PRINT_HELP_PYSCRIPT
14
+
15
+ help:
16
+ @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
17
+
18
+ clean: clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
19
+
20
+ clean-pyc: ## remove Python file artifacts
21
+ find . -name '*.pyc' -exec rm -f {} +
22
+ find . -name '*.pyo' -exec rm -f {} +
23
+ find . -name '*~' -exec rm -f {} +
24
+ find . -name '__pycache__' -exec rm -fr {} +
25
+
26
+ clean-test: ## remove test and coverage artifacts
27
+ find . -name '*.pytest_cache' -exec rm -rf {} +
28
+ rm -f .coverage
29
+
30
+ update-version:
31
+ uv version --bump=$(scope)
32
+
33
+ test: ## run tests with pytest
34
+ uv run pytest splight_cli/
35
+
36
+ install:
37
+ uv sync --all-extras
38
+
39
+ install-dev:
40
+ uv sync --all-extras --dev
41
+
42
+ isort: ## run isort formatter
43
+ uv run isort .
44
+
45
+
46
+ format: install-dev
47
+ uv run pre-commit run --all-files
48
+
49
+ check-format: install-dev
50
+ uv run pre-commit run --all-files