Skip to content

Commit

Permalink
Fix the entry_point when installing through pip. (#4)
Browse files Browse the repository at this point in the history
* Fix the entry_point when installing through pip.
* Update the requirements to latest versions.
* Update README.md.
* Add property file for SonarCloud
* Add sonar badges
  • Loading branch information
sodul committed Apr 4, 2024
1 parent 265c4cd commit cd57b71
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 43 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ on:
branches: [ main ]
workflow_dispatch:
# Allow manual trigger for debugging the workflow.
env:
# Python version to run all the checks.
PY_FULL_CHECKS: '3.12'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
name: Python ${{ matrix.python-version }}
fail-fast: false
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand All @@ -44,10 +49,10 @@ jobs:
- name: Install
run: make dev-install
- name: pylint
if: matrix.python-version == '3.12'
if: matrix.python-version == env.PY_FULL_CHECKS && matrix.os == 'ubuntu-latest'
run: make pylint
- name: mypy
if: matrix.python-version == '3.12'
if: matrix.python-version == env.PY_FULL_CHECKS && matrix.os == 'ubuntu-latest'
run: make mypy
- name: Unit Tests
run: make test
5 changes: 5 additions & 0 deletions .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SonarCloud properties
# https://sonarcloud.io/project/overview?id=clumio-code_azure-sdk-trim

sonar.projectVersion=0.2.1
sonar.python.version=3.8,3.9,3.10,3.11,3.12
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ install:

# Install the script and the development dependencies.
dev-install:
pip install -r dev-requirements.txt
pip install -r requirements-dev.txt


uninstall:
Expand Down
58 changes: 35 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
# azure-sdk-trim

[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=clumio-code_azure-sdk-trim&metric=bugs)](https://sonarcloud.io/summary/new_code?id=clumio-code_azure-sdk-trim)
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=clumio-code_azure-sdk-trim&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=clumio-code_azure-sdk-trim)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=clumio-code_azure-sdk-trim&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=clumio-code_azure-sdk-trim)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=clumio-code_azure-sdk-trim&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=clumio-code_azure-sdk-trim)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=clumio-code_azure-sdk-trim&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=clumio-code_azure-sdk-trim)
[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=clumio-code_azure-sdk-trim&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=clumio-code_azure-sdk-trim)
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=clumio-code_azure-sdk-trim&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=clumio-code_azure-sdk-trim)

Simple Python script to purge mostly useless Azure SDK API versions.

The Azure SDK for python is 1.2GB and growing. The main reason for the
size and growth is that each release gets added internally and all prior
release are kept. This is a troublesome design which does not seem to be
addressed in the near future. This deleted most but not all API versions as
multiple versions are required for importing the models. This keep a high
releases are kept. This is a troublesome design that does not seem to be fully
addressed in the near future. The logic deletes most but not all older API
versions as multiple API versions can import prior versions, and the azure cli
can point directly at older, preview, versions. This approach keeps a high
compatibility level while trimming half of the space used.

The latest version has been tested with Python 3.12.1, but the unittests pass with 3.8.
For the Azure versions the latest version has been tested with azure-cli 2.53.0 to 2.57.0.
The 0.2.1 release has been tested with Python 3.12.2, azure-cli 2.58.0 where the
azure sdk is 1.2GB and the trimmed version is about 600MB.
We unittest against python versions 3.8 to 3.12 on macOS, Linux and Windows.

So Long & Thanks For All The Fish.


## Installation

Due to the highly specilized nature of this script it is not published on pypi.org so you can either download the script as a standalone script or
pip install it from github directly:
This script is not published on pypi.org but you can either download the script
as a standalone script or pip install it from github directly:

```shell
wget https://raw.githubusercontent.com/clumio-code/azure-sdk-trim/main/azure_sdk_trim/azure_sdk_trim.py
Expand All @@ -28,36 +38,38 @@ wget https://raw.githubusercontent.com/clumio-code/azure-sdk-trim/main/azure_sdk
pip install git+https://github.com/clumio-code/azure-sdk-trim@v0.2.0#egg=azure-sdk-trim
```

The script has been developed and tested with Python 3.12.1, but compatibility
with older releases of Python 3 should be possible.


## Caveats

While most third party packages that use the Azure SDK do not point to older
APIs explicitly, some do which can lead to issues. The script does not support
keeping a list of directories that should be preserved. In practice, we found
out that simply adding a symlink so that the old version points to the latest
version is a good enough workaround but this could lead to unsuspected behavior,
so we do not intend to add symlinks automatically. We recommend filing bugs
against the upstream maintainers so that they stop pointing to obsolete APIs.
APIs explicitly, some do which can lead to issues.

If you use a third party package that points to a specific version that got
deleted, then you will experience runtime failures. A temporary workaround can
be to create a symlink to point the old version folder to a newer version. This
usually works but could lead to unsuspected behavior.
As such, we do not intend to add symlinks automatically. We recommend filing
bugs against the upstream maintainers so that they stop pointing to obsolete
APIs versions.

We use newer Python syntax so py3.12 is recommended, but the code can be modified for
backward compatibility with 3.8 if needed. We will not accept any PR to add
support for unsupported versions of Python (anything older than 3.8).
We use newer Python syntax, so py3.12 is recommended, but the code can be
modified for backward compatibility with older python versions if needed.
We will not accept any PR to add support for unsupported versions of Python
(anything older than 3.8 as of this writing).


## Style Guide

We follow the [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html)
with a few distinctions. We use 100 character width and prefer single quotes
with a few distinctions. We use 100 characters width and prefer single quotes
over double quotes for regular string declarations. Triple quoting is always
done with double quotes: `"""A docstring.""""`

For most of the formatting we rely on [Gray](https://github.com/dizballanze/gray)
and [Black](https://github.com/psf/black) to ensure conformance.
For most of the formatting,
we rely on [Gray](https://github.com/dizballanze/gray)
configured to use [Black](https://github.com/psf/black).

Please run `gray .` before submitting any Pull Request.
Please run `gray .` and `make test mypy pylint`, before submitting any PR.


## Links
Expand Down
7 changes: 6 additions & 1 deletion azure_sdk_trim/azure_sdk_trim.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,10 @@ def main(argv: Sequence[str]):
purge_old_releases(base_dir)


if __name__ == '__main__':
def entry_point():
"""Entry point."""
sys.exit(main(sys.argv))


if __name__ == '__main__':
entry_point()
5 changes: 1 addition & 4 deletions gray.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#

formatters = pyupgrade,black,isort,unify
min-python-version = 3.9
min-python-version = 3.8

pyupgrade-keep-runtime-typing = true

Expand All @@ -15,11 +15,8 @@ isort-profile = google
isort-line-length = 100
isort-wrap-length = 80
isort-ignore-comments = false
isort-known-first-party = cdf_lib, clumio_lib, systest, clumioapi, cloud, resources
isort-known-local-folder = cdf, clumio
isort-lines-after-imports = -1
isort-multi-line-output = 5
isort-skip-gitignore = true


unify-quote = "'"
14 changes: 7 additions & 7 deletions dev-requirements.txt → requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#
# Python development requirements, allows us to locally install with just
# `pip install -r dev-requirements.txt`
# `pip install -r requirements-dev.txt`
#

-e .

black>=24.1.1
black>=24.3.0
gray>=0.14.0
green>=4.0.0
mypy>=1.8.0
green>=4.0.1
mypy>=1.9.0
mypy-extensions>=1.0.0
pyfakefs>=5.3.4
pylint>=3.0.3
pyupgrade>=3.15.0
pyfakefs>=5.3.5
pylint>=3.1.0
pyupgrade>=3.15.2
unify>=0.5
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
#

-e .
humanize>=4.9.0
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,25 @@

setup(
name='azure-sdk-trim',
version='0.2.0',
version='0.2.1',
description='Python SDK for Clumio REST API',
long_description=long_description,
long_description_content_type='text/markdown',
author='Clumio Inc.',
author_email='support@clumio.com',
url='https://clumio.com',
url='https://github.com/clumio-code/azure-sdk-trim',
classfiers=[
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
],
packages=find_packages(),
entry_points={'console_scripts': ['azure-sdk-trim=azure_sdk_trim.azure_sdk_trim:main']},
entry_points={'console_scripts': ['azure-sdk-trim=azure_sdk_trim.azure_sdk_trim:entry_point']},
install_requires=[
'humanize>=3.11.0',
'humanize>=4.9.0',
],
)

0 comments on commit cd57b71

Please sign in to comment.