diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d12a816..5927eb9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,26 +1,42 @@ -name: CI -on: [push] +name: Python CI + +on: + push: + branches: [ master ] + pull_request: + branches: + - '**' + workflow_dispatch: + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + jobs: - python-tests: - runs-on: ubuntu-latest + tests: + runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [ ubuntu-20.04 ] - python-version: [ '3.8' ] - toxenv: [django32, django42, quality] + python-version: [3.8] + toxenv: [django32, django42, quality, package] steps: - - name: Install system requirements + - name: Install translations dependencies run: sudo apt-get install -y gettext - - uses: actions/checkout@v2 - continue-on-error: true - - name: Python setup - uses: actions/setup-python@v2 + + - name: checkout repo + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: setup python + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - name: Install Requirements - run: | - pip install -r requirements/ci.txt + - name: Install Dependencies + run: pip install -r requirements/ci.txt - name: Run Tests env: diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index 00980f9..527dc58 100644 --- a/.github/workflows/pypi-publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -1,11 +1,11 @@ -name: pypi-publish +name: Publish package to PyPI on: release: types: [published] jobs: - publish-package: + push: runs-on: ubuntu-20.04 steps: @@ -13,21 +13,18 @@ jobs: uses: actions/checkout@v3 - name: setup python - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: 3.8 - - name: Install pip - run: pip install pip - - name: Install Dependencies - run: pip install setuptools wheel + run: pip install -r requirements/pip.txt - name: Build package run: python setup.py sdist bdist_wheel - name: Publish to PyPi - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.PYPI_UPLOAD_TOKEN }} diff --git a/.github/workflows/upgrade-python-requirements.yml b/.github/workflows/upgrade-python-requirements.yml new file mode 100644 index 0000000..dc92eef --- /dev/null +++ b/.github/workflows/upgrade-python-requirements.yml @@ -0,0 +1,29 @@ +name: Upgrade Python Requirements + +on: + schedule: + - cron: "0 0 * * 1" + workflow_dispatch: + inputs: + branch: + description: Target branch against which to create requirements PR + required: true + default: master + +jobs: + call-upgrade-python-requirements-workflow: + uses: openedx/.github/.github/workflows/upgrade-python-requirements.yml@master + # Do not run on forks + if: github.repository_owner == 'openedx' + with: + branch: ${{ github.event.inputs.branch || 'master' }} + # optional parameters below; fill in if you'd like github or email notifications + # user_reviewers: "" + # team_reviewers: "" + # email_address: "" + # send_success_notification: false + secrets: + requirements_bot_github_token: ${{ secrets.REQUIREMENTS_BOT_GITHUB_TOKEN }} + requirements_bot_github_email: ${{ secrets.REQUIREMENTS_BOT_GITHUB_EMAIL }} + edx_smtp_username: ${{ secrets.EDX_SMTP_USERNAME }} + edx_smtp_password: ${{ secrets.EDX_SMTP_PASSWORD }} diff --git a/.gitignore b/.gitignore index 18ed3be..ef8a3d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,42 @@ -var/ -xblock_google_drive.egg-info -*.log -*.pyc -*~ -venv/* +*.py[cod] +__pycache__ + +# C extensions +*.so + +# Packages +*.egg +*.egg-info +dist +build +eggs +parts +bin +var +sdist +env +venv +develop-eggs +.installed.cfg +lib +lib64 + +# Installer logs +pip-log.txt # Unit test / coverage reports .cache/ -.pytest_cache/ .coverage .coverage.* +.pytest_cache .tox coverage.xml htmlcov/ +diff-cover.html +pii_report # Translations -*.pot +*.mo # IDEs and text editors *~ @@ -24,8 +45,26 @@ htmlcov/ .project .pycharm_helpers/ .pydevproject -.DS_Store -# Build and dist related files -build/ -dist/ +# The Silver Searcher +.agignore + +# OS X artifacts +*.DS_Store + +# Logging +log/ +logs/ +chromedriver.log +ghostdriver.log + +# Complexity +output/*.html +output/*/index.html + +# Sphinx +docs/_build + +# Cookiecutter +output/ +dj-package/ diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..705d121 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,4 @@ +include LICENSE +include README.rst +include requirements/base.in +include requirements/constraints.txt diff --git a/Makefile b/Makefile index 0f229d2..cd7cde6 100644 --- a/Makefile +++ b/Makefile @@ -52,10 +52,9 @@ upgrade: $(COMMON_CONSTRAINTS_TXT) pip-compile --upgrade --rebuild -o requirements/pip-tools.txt requirements/pip-tools.in pip install -qr requirements/pip.txt pip install -qr requirements/pip-tools.txt - pip-compile --upgrade -o requirements/dev.txt requirements/base.in requirements/dev.in requirements/quality.in requirements/test.in requirements/travis.in + pip-compile --upgrade -o requirements/dev.txt requirements/base.in requirements/dev.in requirements/quality.in requirements/test.in pip-compile --upgrade -o requirements/quality.txt requirements/base.in requirements/quality.in requirements/test.in pip-compile --upgrade -o requirements/test.txt requirements/base.in requirements/test.in - pip-compile --upgrade -o requirements/travis.txt requirements/travis.in pip-compile --upgrade -o requirements/ci.txt requirements/ci.in # Let tox control the Django version for tests grep -e "^django==" requirements/test.txt > requirements/django.txt diff --git a/catalog-info.yaml b/catalog-info.yaml new file mode 100644 index 0000000..977284d --- /dev/null +++ b/catalog-info.yaml @@ -0,0 +1,30 @@ +# This file records information about this repo. Its use is described in OEP-55: +# https://open-edx-proposals.readthedocs.io/en/latest/processes/oep-0055-proc-project-maintainers.html + +apiVersion: backstage.io/v1alpha1 +# (Required) Acceptable Values: Component, Resource, System +# A repo will almost certainly be a Component. +kind: Component +metadata: + name: xblock-google-drive + description: This XBlock allows embedding documents and calendar. + annotations: + # (Optional) Annotation keys and values can be whatever you want. + # We use it in Open edX repos to have a comma-separated list of GitHub user + # names that might be interested in changes to the architecture of this + # component. + openedx.org/component-type: XBlock + openedx.org/arch-interest-groups: '' +spec: + + # (Required) This can be a group (`group:`) or a user (`user:`). + # Don't forget the "user:" or "group:" prefix. Groups must be GitHub team + # names in the openedx GitHub organization: https://github.com/orgs/openedx/teams + + owner: user:Agrendalath + + # (Required) Acceptable Type Values: service, website, library + type: library + + # (Required) Acceptable Lifecycle Values: experimental, production, deprecated + lifecycle: production diff --git a/google_drive/__init__.py b/google_drive/__init__.py index 6fa04c4..8991cc0 100644 --- a/google_drive/__init__.py +++ b/google_drive/__init__.py @@ -3,3 +3,5 @@ """ from .google_docs import GoogleDocumentBlock from .google_calendar import GoogleCalendarBlock + +__version__ = '0.6.0' diff --git a/requirements/ci.txt b/requirements/ci.txt index 12bfeda..9977cc8 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -6,15 +6,21 @@ # asgiref==3.7.2 # via django -certifi==2023.7.22 +cachetools==5.3.2 + # via tox +certifi==2023.11.17 # via requests +chardet==5.2.0 + # via tox charset-normalizer==3.3.2 # via requests +colorama==0.4.6 + # via tox coverage==6.5.0 # via coveralls coveralls==3.3.1 # via -r requirements/ci.in -distlib==0.3.7 +distlib==0.3.8 # via virtualenv django==3.2.23 # via @@ -29,21 +35,25 @@ filelock==3.13.1 # via # tox # virtualenv -idna==3.4 +idna==3.6 # via requests -lxml==4.9.3 +lxml==5.1.0 # via edx-i18n-tools packaging==23.2 - # via tox -path==16.7.1 + # via + # pyproject-api + # tox +path==16.9.0 # via edx-i18n-tools -platformdirs==3.11.0 - # via virtualenv +platformdirs==4.1.0 + # via + # tox + # virtualenv pluggy==1.3.0 # via tox polib==1.2.0 # via edx-i18n-tools -py==1.11.0 +pyproject-api==1.6.1 # via tox pytz==2023.3.post1 # via django @@ -51,19 +61,17 @@ pyyaml==6.0.1 # via edx-i18n-tools requests==2.31.0 # via coveralls -six==1.16.0 - # via tox sqlparse==0.4.4 # via django tomli==2.0.1 - # via tox -tox==3.28.0 # via - # -c requirements/common_constraints.txt - # -r requirements/ci.in -typing-extensions==4.8.0 + # pyproject-api + # tox +tox==4.12.0 + # via -r requirements/ci.in +typing-extensions==4.9.0 # via asgiref -urllib3==2.0.7 +urllib3==2.1.0 # via requests -virtualenv==20.24.6 +virtualenv==20.25.0 # via tox diff --git a/requirements/common_constraints.txt b/requirements/common_constraints.txt index afe6aa8..15aafb2 100644 --- a/requirements/common_constraints.txt +++ b/requirements/common_constraints.txt @@ -21,7 +21,3 @@ elasticsearch<7.14.0 # django-simple-history>3.0.0 adds indexing and causes a lot of migrations to be affected django-simple-history==3.0.0 - -# tox>4.0.0 isn't yet compatible with many tox plugins, causing CI failures in almost all repos. -# Details can be found in this discussion: https://github.com/tox-dev/tox/discussions/1810 -tox<4.0.0 diff --git a/requirements/dev.txt b/requirements/dev.txt index 2bb5ccd..d39412c 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -14,13 +14,13 @@ astroid==2.9.3 # via # pylint # pylint-celery -backports-functools-lru-cache==1.6.6 +backports-functools-lru-cache==2.0.0 # via caniusepython3 binaryornot==0.4.4 # via cookiecutter -boto3==1.28.77 +boto3==1.34.20 # via fs-s3fs -botocore==1.31.77 +botocore==1.34.20 # via # boto3 # s3transfer @@ -28,7 +28,7 @@ build==1.0.3 # via pip-tools caniusepython3==7.3.0 # via -r requirements/quality.in -certifi==2023.7.22 +certifi==2023.11.17 # via requests chardet==5.2.0 # via @@ -47,23 +47,18 @@ click-log==0.4.0 # via edx-lint code-annotations==1.5.0 # via edx-lint -cookiecutter==2.4.0 +cookiecutter==2.5.0 # via xblock-sdk -coverage[toml]==6.5.0 +coverage[toml]==7.4.0 # via # coverage - # coveralls # pytest-cov -coveralls==3.3.1 - # via -r requirements/travis.in -ddt==1.6.0 +ddt==1.7.1 # via -r requirements/test.in -diff-cover==8.0.0 +diff-cover==8.0.2 # via -r requirements/dev.in -distlib==0.3.7 - # via - # caniusepython3 - # virtualenv +distlib==0.3.8 + # via caniusepython3 django==3.2.23 # via # -c requirements/common_constraints.txt @@ -72,18 +67,12 @@ django==3.2.23 # edx-i18n-tools # openedx-django-pyfs # xblock-sdk -docopt==0.6.2 - # via coveralls edx-i18n-tools==1.3.0 - # via -r requirements/travis.in + # via -r requirements/test.in edx-lint==5.3.6 # via -r requirements/quality.in -exceptiongroup==1.1.3 +exceptiongroup==1.2.0 # via pytest -filelock==3.13.1 - # via - # tox - # virtualenv fs==2.4.16 # via # fs-s3fs @@ -95,19 +84,19 @@ fs-s3fs==1.1.1 # xblock-sdk gitdb==4.0.11 # via gitpython -gitpython==3.1.40 +gitpython==3.1.41 # via transifex-client -idna==3.4 +idna==3.6 # via requests -importlib-metadata==6.8.0 +importlib-metadata==7.0.1 # via build iniconfig==2.0.0 # via pytest -isort==5.12.0 +isort==5.13.2 # via # -r requirements/quality.in # pylint -jinja2==3.1.2 +jinja2==3.1.3 # via # code-annotations # cookiecutter @@ -118,14 +107,14 @@ jmespath==1.0.1 # botocore lazy==1.6 # via xblock -lazy-object-proxy==1.9.0 +lazy-object-proxy==1.10.0 # via astroid -lxml==4.9.3 +lxml==5.1.0 # via # edx-i18n-tools # xblock # xblock-sdk -mako==1.2.4 +mako==1.3.0 # via xblock markdown-it-py==3.0.0 # via rich @@ -142,38 +131,32 @@ mock==5.1.0 # via -r requirements/test.in nose==1.3.7 # via -r requirements/test.in -openedx-django-pyfs==3.4.0 +openedx-django-pyfs==3.4.1 # via xblock packaging==23.2 # via # build # caniusepython3 # pytest - # tox -path==16.7.1 +path==16.9.0 # via edx-i18n-tools -pbr==5.11.1 +pbr==6.0.0 # via stevedore pip-tools==7.3.0 # via -r requirements/dev.in -platformdirs==3.11.0 - # via - # pylint - # virtualenv +platformdirs==4.1.0 + # via pylint pluggy==1.3.0 # via # diff-cover # pytest - # tox polib==1.2.0 # via edx-i18n-tools -py==1.11.0 - # via tox pycodestyle==2.11.1 # via -r requirements/quality.in pydocstyle==6.3.0 # via -r requirements/quality.in -pygments==2.16.1 +pygments==2.17.2 # via # diff-cover # rich @@ -198,14 +181,14 @@ pypng==0.20220715.0 # xblock-sdk pyproject-hooks==1.0.0 # via build -pytest==7.4.3 +pytest==7.4.4 # via # -r requirements/test.in # pytest-cov # pytest-django pytest-cov==4.1.0 # via -r requirements/test.in -pytest-django==4.6.0 +pytest-django==4.7.0 # via -r requirements/test.in python-dateutil==2.8.2 # via @@ -232,12 +215,11 @@ requests==2.31.0 # -r requirements/base.in # caniusepython3 # cookiecutter - # coveralls # transifex-client # xblock-sdk -rich==13.6.0 +rich==13.7.0 # via cookiecutter -s3transfer==0.7.0 +s3transfer==0.10.0 # via boto3 simplejson==3.19.2 # via @@ -249,7 +231,6 @@ six==1.16.0 # fs # fs-s3fs # python-dateutil - # tox # transifex-client smmap==5.0.1 # via gitdb @@ -270,16 +251,11 @@ tomli==2.0.1 # pip-tools # pyproject-hooks # pytest - # tox -tox==3.28.0 - # via - # -c requirements/common_constraints.txt - # -r requirements/travis.in transifex-client==0.14.4 # via -r requirements/dev.in -types-python-dateutil==2.8.19.14 +types-python-dateutil==2.8.19.20240106 # via arrow -typing-extensions==4.8.0 +typing-extensions==4.9.0 # via # asgiref # astroid @@ -290,8 +266,6 @@ urllib3==1.26.18 # botocore # requests # transifex-client -virtualenv==20.24.6 - # via tox web-fragments==2.1.0 # via # xblock @@ -300,11 +274,11 @@ webob==1.8.7 # via # xblock # xblock-sdk -wheel==0.41.3 +wheel==0.42.0 # via pip-tools wrapt==1.13.3 # via astroid -xblock[django]==1.8.1 +xblock[django]==1.9.1 # via # -r requirements/base.in # xblock-sdk diff --git a/requirements/pip-tools.txt b/requirements/pip-tools.txt index ea34731..0e88226 100644 --- a/requirements/pip-tools.txt +++ b/requirements/pip-tools.txt @@ -8,7 +8,7 @@ build==1.0.3 # via pip-tools click==8.1.7 # via pip-tools -importlib-metadata==6.8.0 +importlib-metadata==7.0.1 # via build packaging==23.2 # via build @@ -21,7 +21,7 @@ tomli==2.0.1 # build # pip-tools # pyproject-hooks -wheel==0.41.3 +wheel==0.42.0 # via pip-tools zipp==3.17.0 # via importlib-metadata diff --git a/requirements/pip.txt b/requirements/pip.txt index 9014f2c..a4cf530 100644 --- a/requirements/pip.txt +++ b/requirements/pip.txt @@ -4,11 +4,11 @@ # # make upgrade # -wheel==0.41.3 +wheel==0.42.0 # via -r requirements/pip.in # The following packages are considered to be unsafe in a requirements file: -pip==23.3.1 +pip==23.3.2 # via -r requirements/pip.in -setuptools==68.2.2 +setuptools==69.0.3 # via -r requirements/pip.in diff --git a/requirements/quality.txt b/requirements/quality.txt index 15c04f0..d39412c 100644 --- a/requirements/quality.txt +++ b/requirements/quality.txt @@ -14,13 +14,13 @@ astroid==2.9.3 # via # pylint # pylint-celery -backports-functools-lru-cache==1.6.6 +backports-functools-lru-cache==2.0.0 # via caniusepython3 binaryornot==0.4.4 # via cookiecutter -boto3==1.28.77 +boto3==1.34.20 # via fs-s3fs -botocore==1.31.77 +botocore==1.34.20 # via # boto3 # s3transfer @@ -28,7 +28,7 @@ build==1.0.3 # via pip-tools caniusepython3==7.3.0 # via -r requirements/quality.in -certifi==2023.7.22 +certifi==2023.11.17 # via requests chardet==5.2.0 # via @@ -47,28 +47,31 @@ click-log==0.4.0 # via edx-lint code-annotations==1.5.0 # via edx-lint -cookiecutter==2.4.0 +cookiecutter==2.5.0 # via xblock-sdk -coverage[toml]==7.3.2 +coverage[toml]==7.4.0 # via # coverage # pytest-cov -ddt==1.6.0 +ddt==1.7.1 # via -r requirements/test.in -diff-cover==8.0.0 +diff-cover==8.0.2 # via -r requirements/dev.in -distlib==0.3.7 +distlib==0.3.8 # via caniusepython3 django==3.2.23 # via # -c requirements/common_constraints.txt # -c requirements/constraints.txt # -r requirements/base.in + # edx-i18n-tools # openedx-django-pyfs # xblock-sdk +edx-i18n-tools==1.3.0 + # via -r requirements/test.in edx-lint==5.3.6 # via -r requirements/quality.in -exceptiongroup==1.1.3 +exceptiongroup==1.2.0 # via pytest fs==2.4.16 # via @@ -81,19 +84,19 @@ fs-s3fs==1.1.1 # xblock-sdk gitdb==4.0.11 # via gitpython -gitpython==3.1.40 +gitpython==3.1.41 # via transifex-client -idna==3.4 +idna==3.6 # via requests -importlib-metadata==6.8.0 +importlib-metadata==7.0.1 # via build iniconfig==2.0.0 # via pytest -isort==5.12.0 +isort==5.13.2 # via # -r requirements/quality.in # pylint -jinja2==3.1.2 +jinja2==3.1.3 # via # code-annotations # cookiecutter @@ -104,13 +107,14 @@ jmespath==1.0.1 # botocore lazy==1.6 # via xblock -lazy-object-proxy==1.9.0 +lazy-object-proxy==1.10.0 # via astroid -lxml==4.9.3 +lxml==5.1.0 # via + # edx-i18n-tools # xblock # xblock-sdk -mako==1.2.4 +mako==1.3.0 # via xblock markdown-it-py==3.0.0 # via rich @@ -127,28 +131,32 @@ mock==5.1.0 # via -r requirements/test.in nose==1.3.7 # via -r requirements/test.in -openedx-django-pyfs==3.4.0 +openedx-django-pyfs==3.4.1 # via xblock packaging==23.2 # via # build # caniusepython3 # pytest -pbr==5.11.1 +path==16.9.0 + # via edx-i18n-tools +pbr==6.0.0 # via stevedore pip-tools==7.3.0 # via -r requirements/dev.in -platformdirs==3.11.0 +platformdirs==4.1.0 # via pylint pluggy==1.3.0 # via # diff-cover # pytest +polib==1.2.0 + # via edx-i18n-tools pycodestyle==2.11.1 # via -r requirements/quality.in pydocstyle==6.3.0 # via -r requirements/quality.in -pygments==2.16.1 +pygments==2.17.2 # via # diff-cover # rich @@ -173,14 +181,14 @@ pypng==0.20220715.0 # xblock-sdk pyproject-hooks==1.0.0 # via build -pytest==7.4.3 +pytest==7.4.4 # via # -r requirements/test.in # pytest-cov # pytest-django pytest-cov==4.1.0 # via -r requirements/test.in -pytest-django==4.6.0 +pytest-django==4.7.0 # via -r requirements/test.in python-dateutil==2.8.2 # via @@ -200,6 +208,7 @@ pyyaml==6.0.1 # via # code-annotations # cookiecutter + # edx-i18n-tools # xblock requests==2.31.0 # via @@ -208,9 +217,9 @@ requests==2.31.0 # cookiecutter # transifex-client # xblock-sdk -rich==13.6.0 +rich==13.7.0 # via cookiecutter -s3transfer==0.7.0 +s3transfer==0.10.0 # via boto3 simplejson==3.19.2 # via @@ -244,9 +253,9 @@ tomli==2.0.1 # pytest transifex-client==0.14.4 # via -r requirements/dev.in -types-python-dateutil==2.8.19.14 +types-python-dateutil==2.8.19.20240106 # via arrow -typing-extensions==4.8.0 +typing-extensions==4.9.0 # via # asgiref # astroid @@ -265,11 +274,11 @@ webob==1.8.7 # via # xblock # xblock-sdk -wheel==0.41.3 +wheel==0.42.0 # via pip-tools wrapt==1.13.3 # via astroid -xblock[django]==1.8.1 +xblock[django]==1.9.1 # via # -r requirements/base.in # xblock-sdk diff --git a/requirements/test.in b/requirements/test.in index 7c1c6ec..740a0c2 100644 --- a/requirements/test.in +++ b/requirements/test.in @@ -10,3 +10,4 @@ pytest pytest-cov pytest-django xblock-sdk +edx-i18n-tools # Manage translation files, needed both for Travis and development diff --git a/requirements/test.txt b/requirements/test.txt index 1827ac5..24a66c4 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -12,15 +12,15 @@ asgiref==3.7.2 # via django binaryornot==0.4.4 # via cookiecutter -boto3==1.28.77 +boto3==1.34.20 # via fs-s3fs -botocore==1.31.77 +botocore==1.34.20 # via # boto3 # s3transfer build==1.0.3 # via pip-tools -certifi==2023.7.22 +certifi==2023.11.17 # via requests chardet==5.2.0 # via @@ -32,23 +32,26 @@ click==8.1.7 # via # cookiecutter # pip-tools -cookiecutter==2.4.0 +cookiecutter==2.5.0 # via xblock-sdk -coverage[toml]==7.3.2 +coverage[toml]==7.4.0 # via # coverage # pytest-cov -ddt==1.6.0 +ddt==1.7.1 # via -r requirements/test.in -diff-cover==8.0.0 +diff-cover==8.0.2 # via -r requirements/dev.in # via # -c requirements/common_constraints.txt # -c requirements/constraints.txt # -r requirements/base.in + # edx-i18n-tools # openedx-django-pyfs # xblock-sdk -exceptiongroup==1.1.3 +edx-i18n-tools==1.3.0 + # via -r requirements/test.in +exceptiongroup==1.2.0 # via pytest fs==2.4.16 # via @@ -61,15 +64,15 @@ fs-s3fs==1.1.1 # xblock-sdk gitdb==4.0.11 # via gitpython -gitpython==3.1.40 +gitpython==3.1.41 # via transifex-client -idna==3.4 +idna==3.6 # via requests -importlib-metadata==6.8.0 +importlib-metadata==7.0.1 # via build iniconfig==2.0.0 # via pytest -jinja2==3.1.2 +jinja2==3.1.3 # via # cookiecutter # diff-cover @@ -79,11 +82,12 @@ jmespath==1.0.1 # botocore lazy==1.6 # via xblock -lxml==4.9.3 +lxml==5.1.0 # via + # edx-i18n-tools # xblock # xblock-sdk -mako==1.2.4 +mako==1.3.0 # via xblock markdown-it-py==3.0.0 # via rich @@ -98,19 +102,23 @@ mock==5.1.0 # via -r requirements/test.in nose==1.3.7 # via -r requirements/test.in -openedx-django-pyfs==3.4.0 +openedx-django-pyfs==3.4.1 # via xblock packaging==23.2 # via # build # pytest +path==16.9.0 + # via edx-i18n-tools pip-tools==7.3.0 # via -r requirements/dev.in pluggy==1.3.0 # via # diff-cover # pytest -pygments==2.16.1 +polib==1.2.0 + # via edx-i18n-tools +pygments==2.17.2 # via # diff-cover # rich @@ -120,14 +128,14 @@ pypng==0.20220715.0 # xblock-sdk pyproject-hooks==1.0.0 # via build -pytest==7.4.3 +pytest==7.4.4 # via # -r requirements/test.in # pytest-cov # pytest-django pytest-cov==4.1.0 # via -r requirements/test.in -pytest-django==4.6.0 +pytest-django==4.7.0 # via -r requirements/test.in python-dateutil==2.8.2 # via @@ -145,6 +153,7 @@ pytz==2023.3.post1 pyyaml==6.0.1 # via # cookiecutter + # edx-i18n-tools # xblock requests==2.31.0 # via @@ -152,9 +161,9 @@ requests==2.31.0 # cookiecutter # transifex-client # xblock-sdk -rich==13.6.0 +rich==13.7.0 # via cookiecutter -s3transfer==0.7.0 +s3transfer==0.10.0 # via boto3 simplejson==3.19.2 # via @@ -181,9 +190,9 @@ tomli==2.0.1 # pytest transifex-client==0.14.4 # via -r requirements/dev.in -types-python-dateutil==2.8.19.14 +types-python-dateutil==2.8.19.20240106 # via arrow -typing-extensions==4.8.0 +typing-extensions==4.9.0 # via # asgiref # rich @@ -200,9 +209,9 @@ webob==1.8.7 # via # xblock # xblock-sdk -wheel==0.41.3 +wheel==0.42.0 # via pip-tools -xblock[django]==1.8.1 +xblock[django]==1.9.1 # via # -r requirements/base.in # xblock-sdk diff --git a/requirements/travis.in b/requirements/travis.in deleted file mode 100644 index c84fb2a..0000000 --- a/requirements/travis.in +++ /dev/null @@ -1,6 +0,0 @@ -# Requirements for running tests in Travis --c constraints.txt - -coveralls # Code coverage reporting -tox # Virtualenv management for tests -edx-i18n-tools # Manage translation files, needed both for Travis and development diff --git a/requirements/travis.txt b/requirements/travis.txt deleted file mode 100644 index c1bcc30..0000000 --- a/requirements/travis.txt +++ /dev/null @@ -1,69 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.8 -# by the following command: -# -# make upgrade -# -asgiref==3.7.2 - # via django -certifi==2023.7.22 - # via requests -charset-normalizer==3.3.2 - # via requests -coverage==6.5.0 - # via coveralls -coveralls==3.3.1 - # via -r requirements/travis.in -distlib==0.3.7 - # via virtualenv -django==3.2.23 - # via - # -c requirements/common_constraints.txt - # -c requirements/constraints.txt - # edx-i18n-tools -docopt==0.6.2 - # via coveralls -edx-i18n-tools==1.3.0 - # via -r requirements/travis.in -filelock==3.13.1 - # via - # tox - # virtualenv -idna==3.4 - # via requests -lxml==4.9.3 - # via edx-i18n-tools -packaging==23.2 - # via tox -path==16.7.1 - # via edx-i18n-tools -platformdirs==3.11.0 - # via virtualenv -pluggy==1.3.0 - # via tox -polib==1.2.0 - # via edx-i18n-tools -py==1.11.0 - # via tox -pytz==2023.3.post1 - # via django -pyyaml==6.0.1 - # via edx-i18n-tools -requests==2.31.0 - # via coveralls -six==1.16.0 - # via tox -sqlparse==0.4.4 - # via django -tomli==2.0.1 - # via tox -tox==3.28.0 - # via - # -c requirements/common_constraints.txt - # -r requirements/travis.in -typing-extensions==4.8.0 - # via asgiref -urllib3==2.0.7 - # via requests -virtualenv==20.24.6 - # via tox diff --git a/setup.py b/setup.py index 705cadc..0aca009 100644 --- a/setup.py +++ b/setup.py @@ -1,21 +1,94 @@ """Setup for my_google_drive XBlock.""" -from __future__ import absolute_import - import os +import re +import sys from setuptools import setup -def package_data(pkg, roots): - """Generic function to find package_data. +def load_requirements(*requirements_paths): + """ + Load all requirements from the specified requirements files. + Requirements will include any constraints from files specified + with -c in the requirements files. + Returns a list of requirement strings. + """ + requirements = {} + constraint_files = set() + + # groups "pkg<=x.y.z,..." into ("pkg", "<=x.y.z,...") + requirement_line_regex = re.compile(r"([a-zA-Z0-9-_.\[\]]+)([<>=][^#\s]+)?") + + def add_version_constraint_or_raise(current_line, current_requirements, add_if_not_present): + regex_match = requirement_line_regex.match(current_line) + if regex_match: + package = regex_match.group(1) + version_constraints = regex_match.group(2) + existing_version_constraints = current_requirements.get(package, None) + # fine to add constraints to an unconstrained package, + # raise an error if there are already constraints in place + if existing_version_constraints and existing_version_constraints != version_constraints: + raise BaseException( + f'Multiple constraint definitions found for {package}:' + f' "{existing_version_constraints}" and "{version_constraints}".' + f'Combine constraints into one location with {package}' + f'{existing_version_constraints},{version_constraints}.' + ) + if add_if_not_present or package in current_requirements: + current_requirements[package] = version_constraints + + # read requirements from .in + # store the path to any constraint files that are pulled in + for path in requirements_paths: + with open(path) as reqs: + for line in reqs: + if is_requirement(line): + add_version_constraint_or_raise(line, requirements, True) + if line and line.startswith('-c') and not line.startswith('-c http'): + constraint_files.add(os.path.dirname(path) + '/' + line.split('#')[0].replace('-c', '').strip()) + + # process constraint files: add constraints to existing requirements + for constraint_file in constraint_files: + with open(constraint_file) as reader: + for line in reader: + if is_requirement(line): + add_version_constraint_or_raise(line, requirements, False) + + # process back into list of pkg><=constraints strings + constrained_requirements = [f'{pkg}{version or ""}' for (pkg, version) in sorted(requirements.items())] + return constrained_requirements + + +def is_requirement(line): + """ + Return True if the requirement line is a package requirement. + Returns: + bool: True if the line is not blank, a comment, + a URL, or an included file + """ + return line and line.strip() and not line.startswith(("-r", "#", "-e", "git+", "-c")) - All of the files under each of the `roots` will be declared as package - data for package `pkg`. +def get_version(*file_paths): + """ + Extract the version string from the file. + Input: + - file_paths: relative path fragments to file with + version string """ + filename = os.path.join(os.path.dirname(__file__), *file_paths) + version_file = open(filename, encoding="utf8").read() + version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M) + if version_match: + return version_match.group(1) + raise RuntimeError('Unable to find version string.') + + +def package_data(pkg, root_list): + """Generic function to find package_data for `pkg` under `root`.""" data = [] - for root in roots: + for root in root_list: for dirname, _, files in os.walk(os.path.join(pkg, root)): for fname in files: data.append(os.path.relpath(os.path.join(dirname, fname), pkg)) @@ -23,27 +96,38 @@ def package_data(pkg, roots): return {pkg: data} +VERSION = get_version('google_drive', '__init__.py') + +if sys.argv[-1] == 'tag': + print("Tagging the version on GitHub:") + os.system("git tag -a %s -m 'version %s'" % (VERSION, VERSION)) + os.system("git push --tags") + sys.exit() + +README = open(os.path.join(os.path.dirname(__file__), 'README.rst'), encoding="utf8").read() + setup( name='xblock-google-drive', - version='0.5.0', + version=VERSION, description='An XBlock which allows embedding of Google documents and calendar within an edX course', - url='https://github.com/openedx/xblock-google-drive', - packages=[ - 'google_drive', - ], - install_requires=[ - 'mako', - 'XBlock', - 'xblock-utils', - ], - dependency_links=[ - 'http://github.com/openedx/xblock-utils/tarball/master#egg=xblock-utils', + long_description=README, + long_description_content_type='text/x-rst', + classifiers=[ + 'Programming Language :: Python', + 'Programming Language :: Python :: 3.8', + 'Framework :: Django', + 'Framework :: Django :: 3.2', + 'Framework :: Django :: 4.2', ], + url='https://github.com/openedx/xblock-google-drive', + install_requires=load_requirements('requirements/base.in'), entry_points={ 'xblock.v1': [ 'google-document = google_drive:GoogleDocumentBlock', 'google-calendar = google_drive:GoogleCalendarBlock' ] }, + packages=['google_drive'], package_data=package_data("google_drive", ["static", "templates", "public", "translations", "conf"]), + python_requires=">=3.8", ) diff --git a/tox.ini b/tox.ini index 08f8d1f..4a59232 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py38-django{32,42},quality +envlist = py38-django{32,42},quality,package [pycodestyle] exclude = .git,.tox @@ -14,7 +14,7 @@ addopts = --cov google_drive --cov-report term-missing --durations=10 norecursedirs = .* requirements [testenv] -allowlist_externals = +allowlist_externals = make mkdir rm @@ -22,7 +22,7 @@ deps = django32: Django>=3.2,<4.0 django42: Django>=4.2,<4.3 -r{toxinidir}/requirements/test.txt -setenv = +setenv = DJANGO_SETTINGS_MODULE = workbench.settings SCREENSHOT_DIR={toxinidir}/var/logs SELENIUM_DRIVER_LOG_DIR={toxinidir}/var/logs @@ -33,12 +33,19 @@ commands = make validate_translations [testenv:quality] -allowlist_externals = +allowlist_externals = make -deps = +deps = -r{toxinidir}/requirements/quality.txt -commands = - pylint google_drive setup.py - pycodestyle google_drive setup.py +commands = + pylint google_drive + pycodestyle google_drive make selfcheck +[testenv:package] +deps = + build + twine +commands = + python -m build + twine check dist/*