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

SG-32061 Python3.7+ Syntax #297

Closed
wants to merge 13 commits into from
Closed
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
3 changes: 0 additions & 3 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,3 @@

[run]
source=shotgun_api3
omit=
shotgun_api3/lib/httplib2/*
shotgun_api3/lib/six.py
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

[flake8]
max-line-length = 120
exclude = shotgun_api3/lib/httplib2/*,shotgun_api3/lib/six.py,tests/httplib2test.py,tests/mock.py
exclude = tests/mock.py
7 changes: 4 additions & 3 deletions azure-pipelines-templates/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
# Python 2 and 3, but also for all OSes
- script: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install .
python -m pip install -r tests/ci_requirements.txt
displayName: Install tools

Expand Down Expand Up @@ -93,9 +94,9 @@ jobs:
# Pass the values needed to authenticate with the Shotgun site and create some entities.
# Remember, on a pull request from a client or on forked repos, those variables
# will be empty!
SG_SERVER_URL: $(ci_site)
SG_SCRIPT_NAME: $(ci_site_script_name)
SG_API_KEY: $(ci_site_script_key)
SG_SERVER_URL: ${{variables.ci_site}}
SG_SCRIPT_NAME: ${{variables.ci_site_script_name}}
SG_API_KEY: ${{variables.ci_site_script_key}}
# The unit tests manipulate the user and project during the tests, which can cause collisions,
# so sandbox each build variant.
# Ideally, we would use the agent name here. The problem is that the agent name is in a build
Expand Down
4 changes: 2 additions & 2 deletions docs/advanced/packaging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ There are caveats you need to be aware of when creating such an app.
HTTPS Validation and cacerts.txt
********************************
When creating the connection to ShotGrid a file is used to validate the ShotGrid certificate. This
file is located at ``shotgun_api3/lib/httplib2/cacerts.txt``. Because this file is not a Python
file can be located with ``httplib2.BUILTIN_CA_CERTS``. Because this file is not a Python
file imported by your application, py2app will not know to include it in your package, it will
need to be explicitly specified in your ``setup.py`` file (edit the path based on the location
where your ``shotgun_api3`` package is located)::

DATA_FILES = [
('shotgun_api3', ['/shotgun/src/python-api/shotgun_api3/lib/httplib2/cacerts.txt'])
('shotgun_api3', [httplib2.BUILTIN_CA_CERTS])
]

Once you create your py2app package its contents should include two files (among others) in the
Expand Down
4 changes: 2 additions & 2 deletions docs/cookbook/examples/ami_handler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ via ``POST``. If you're using a custom protocol the data is sent via ``GET``.
# Imports
# ---------------------------------------------------------------------------------------------
import sys, os
import six
import urllib.parse
import logging as logger

# ---------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -218,7 +218,7 @@ via ``POST``. If you're using a custom protocol the data is sent via ``GET``.
params = params.split("&")
p = {"column_display_names": [], "cols": []}
for arg in params:
key, value = map(six.moves.urllib.parse.unquote, arg.split("=", 1))
key, value = map(urllib.parse.unquote, arg.split("=", 1))
if key == "column_display_names" or key == "cols":
p[key].append(value)
else:
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ If you're using pip with `requirements.txt`, add the following line::
Installing with ``setup.py``
****************************

From a local copy of the repository, you can run ``python setup.py install`` to copy the package inside your python ``site-packages``. Note that while ``setuptools`` will complain about syntax errors when installing the library, the library is fully functional. However, it ships with both Python 2 and Python 3 copies of ``httplib2``, which will generate syntax errors when byte-compiling the Python modules.
From a local copy of the repository, you can run ``python setup.py install`` to copy the package inside your python ``site-packages``. Note that while ``setuptools`` will complain about syntax errors when installing the library, the library is fully functional.
3 changes: 0 additions & 3 deletions docs/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,3 @@ Example for a user whose language preference is set to Japanese:
},
...
}

.. note::
If needed, the encoding of the returned localized string can be ensured regardless the Python version using shotgun_api3.lib.six.ensure_text().
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@
f = open('LICENSE')
license = f.read().strip()

# For python 2.4 support
script_args = sys.argv[1:]
if (sys.version_info[0] <= 2) or (sys.version_info[0] == 2 and sys.version_info[1] <= 5):
if 'install' in script_args and '--no-compile' not in script_args:
script_args.append('--no-compile')


setup(
name='shotgun_api3',
Expand All @@ -39,4 +34,9 @@
include_package_data=True,
package_data={'': ['cacerts.txt', 'cacert.pem']},
zip_safe=False,
python_requires='>=3.7.0',
install_requires=[
'httplib2>=0.19.1',
'certifi>=2022.12.7',
],
)
29 changes: 0 additions & 29 deletions shotgun_api3/lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,8 @@

Some third-party modules are bundled with `python-api` inside lib.

### httplib2

`httplib2` is used to make http connections to the ShotGrid server. We bundle both python2 and python3 compatible versions since httplib2 chose to maintain parallel versions of the module for python 2 and 3 compatibility.

The version of `httplib2` bundled should be updated manually, however its version is included in the unused `shotgun_api3/lib/requirements.txt` to allow Github's automated CVE notifications to work.

### mimetypes

The `mimetypes` module is broken on Windows only for Python 2.7.0 to 2.7.9 inclusively.
We bundle the version from 2.7.10

See bugs:

* [9291](http://bugs.python.org/issue9291) (Fixed in 2.7.7)
* [21652](http://bugs.python.org/issue21652) (Fixed in 2.7.8)
* [22028](http://bugs.python.org/issue22028) (Fixed in 2.7.10)

The version of `mimetypes` bundled should be updated manually if necessary, however it is unlikely this will be needed, as it is only used for Python versions 2.7.0 - 2.7.9, and newer Python versions simply use the native `mimetypes` module.

### six

Six is a Python 2/3 compatibility library. In python-api, it's used to make simultaneous support for Python on 2 and 3 easier to maintain and more readable, but allowing the use of common helper functions, unified interfaces for modules that changed, and variables to ease type comparisons. For more on six, see the [documentation](https://six.readthedocs.io/).

The version of `six` bundled should be updated manually, however its version is included in the unused `shotgun_api3/lib/requirements.txt` to allow Github's automated CVE notifications to work.

## ShotGrid Modules

### sgsix

`sgsix` is a module that contains extensions to `six`. These might be additional helper functions, variables, etc. that supplement six's functionality. It is intended that `sgsix` can be used within other packages that include or depend on the `python-api` package as well.

### sgtimezone

`sgtimezone` contains classes for easing the conversion between the server (UTC) timezone and client timezone.
Expand Down
4 changes: 0 additions & 4 deletions shotgun_api3/lib/certifi/__init__.py

This file was deleted.

12 changes: 0 additions & 12 deletions shotgun_api3/lib/certifi/__main__.py

This file was deleted.

Loading