-
Notifications
You must be signed in to change notification settings - Fork 11
[EN-3260] [PythonAPI] Add compatibility of PythonAPI with Python 3.9+ #39
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
[EN-3260] [PythonAPI] Add compatibility of PythonAPI with Python 3.9+ #39
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good 👍 , there are few places I would like to ask to change a bit, but they are more about cosmetic ones or our usual approaches in terms of solving some regular cases.
For example - usage of pathlib
as standart library to handle things about interaction with file system. Doing so we are trying to focus our team experience and skills on some particular set of technologies to achieve excellence in.
.github/workflows/publishpackage.yml
Outdated
@@ -34,12 +34,11 @@ jobs: | |||
poetry install --no-root | |||
shell: bash | |||
- name: Create tarball | |||
if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.7 | |||
if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-18.04' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that we'll run this task 8 times in a row, but in reality we need only one tarball with source distribution. Please consider variant to create only one of them. ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, yes.
.github/workflows/publishpackage.yml
Outdated
@@ -11,8 +11,8 @@ jobs: | |||
build: | |||
strategy: | |||
matrix: | |||
os: [ubuntu-latest, windows-latest, macos-latest] | |||
python-version: [3.6, 3.7, 3.8] | |||
os: [ubuntu-18.04, ubuntu-latest, windows-latest, macos-latest] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks just a bit strange, why do we have such priority for Bionic Beaver (18.04)? So according to this configuration we are building for ubuntu 21.04/21.10 and 18.04. Why so? This question is actual for this config and other ones with same line as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for choosing the minimum Linux version? This is because glibc "controls" everything. There is some backward compatibility. That is, we can take Ubuntu 18.04 (this is LTS) and get the minimum version of glibc (2.27 https://launchpad.net/ubuntu/bionic/+source/glibc ). The so libraries will be able to run on newer versions of glibc.
By the way, ubuntu-latest is Ubuntu 20.04 LTS. https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources.
I suggest using the minimal version for wheel too. Or all versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, okay, this sounds pretty reasonable. If we can rely on ubuntu's backward comp and we can use all necessary python versions with it - I have no objections to use 18.04 as base version for linux build. 👍 🙂
build.py
Outdated
__c_api_extracted_root_dir = self.__path_to_extract / f'dxfeed-c-api-{self.__version}-no-tls' | ||
is_x64 = 8 * struct.calcsize("P") == 64 | ||
|
||
if platform.system() == 'Windows': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are usually using default values approach instead of additional elses. It's not something critical, just our preferable way of resolving such cases. Actual here and in following if/else statements as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
build.py
Outdated
|
||
__c_api_library_name = f'DXFeed{c_api_debug_suffix}{c_api_x64_suffix}' | ||
|
||
if platform.system() == 'Windows': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably if we'll reformat this 2 level if swapping platform's instruction set (x86/x64) and OS name then we'll be able to reuse some part of of the logic and avoid part of the code duplications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rewrote this. Hopefully it's gotten a little shorter.
build.py
Outdated
c_api_extracted_library_dir = __c_api_extracted_root_dir / 'bin' / 'x64' | ||
c_api_library_file_name = f'lib{__c_api_library_name}.dylib' | ||
else: | ||
raise Exception('Unsupported platform') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call Exception
too general class for this purposes. What do you think about using i.e. RuntimeError
? 🤔
pyproject.toml
Outdated
sphinx = '^4.1.2' | ||
sphinx_rtd_theme = '^0.5.2' | ||
pygments = '^2.10' | ||
toml = '^0.10.2' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have toml as usual dependencies, so no need to add it to dev-deps too. 😉
build.py
Outdated
|
||
def download(self) -> str: | ||
__c_api_extracted_root_dir = self.__path_to_extract / f'dxfeed-c-api-{self.__version}-no-tls' | ||
is_x64 = 8 * struct.calcsize("P") == 64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are usually using single quotes to indicate character or str values. It's just internal team arrangement. 🙂 Actual here and in other cases as well.
build.py
Outdated
print(f'Extracting to "{self.__path_to_extract}"') | ||
zipfile.extractall(self.__path_to_extract) | ||
|
||
if __debug__: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add some explanation here about how it could and should be used in the future? 🤔
I mean here not exactly __debug__
field, but use cases for this particular case. 🤔
build.py
Outdated
|
||
if (not os.path.exists(self.__path_to_extract)) or (not os.path.exists(__c_api_extracted_root_dir)): | ||
url = f'https://github.com/dxFeed/dxfeed-c-api/releases/download/{self.__version}/dxfeed-c-api-' \ | ||
f'{self.__version}-{current_os}-no-tls.zip ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like here is one redundant space on the line's end. 😉
- I would suggest to move github link to the
pyproject.toml
file same way as we have moved version there 🤔
No description provided.