Skip to content

Commit

Permalink
Fix SetuptoolsDeprecationWarning issued by 'python -m build'
Browse files Browse the repository at this point in the history
Fix 'extras_require' in setup.py to fix the warning. This requires fixes
for the parsing of dependencies in test_dependencies_in_sync.py: Use the
'packaging' module which simplifies the code.
  • Loading branch information
rear1019 committed Nov 29, 2024
1 parent 1e73d3c commit 3867651
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 48 deletions.
1 change: 1 addition & 0 deletions .github/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ fi
# Install dependencies
if [ "$USE_CONDA" = "true" ]; then
if [ -n "$QT6_BINDINGS" ]; then
# conda has no PyQt6 package
echo "Cannot use Qt 6 with Conda" 1>&2
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ def run(self):
install_requires.append('qtconsole>=5.5.1,<5.7.0')

extras_require = {
'test:platform_system == "Windows"': ['pywin32'],
'test': [
'coverage',
'cython',
Expand All @@ -279,6 +278,7 @@ def run(self):
'pytest-order',
'pytest-qt',
'pytest-timeout',
'pywin32;platform_system=="Windows"',
'pyyaml',
'scipy',
'sympy',
Expand Down
74 changes: 27 additions & 47 deletions spyder/tests/test_dependencies_in_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import os.path as osp

# Third party imports
from packaging.requirements import Requirement
from packaging.specifiers import SpecifierSet
import pytest
import yaml

Expand Down Expand Up @@ -42,15 +44,11 @@ def parse_environment_yaml(fpath):
elif dep == 'websockify':
continue
else:
parts = dep.split(' ')
if len(parts) > 1:
ver = parts[-1]
if ver[0] == '=':
ver = '=' + ver

deps[parts[0]] = ver
req = Requirement(dep)
if req.specifier:
deps[req.name] = str(req.specifier)
else:
deps[parts[0]] = None
deps[req.name] = None

return deps

Expand All @@ -66,10 +64,7 @@ def parse_spyder_dependencies():

ver = dep['required_version']
if ver:
if ';' in ver:
ver = ver.replace(';', ',')
elif ver[0] == '=':
ver = '=' + ver
ver = str(SpecifierSet(ver))

deps[dep['package_name'].lower()] = ver

Expand Down Expand Up @@ -98,26 +93,16 @@ def parse_setup_install_requires(fpath):
dep_list = literal_eval('[' + '\n'.join(lines[start:end + 1]))
dep_list = [item for item in dep_list if item[0] != '#']
for dep in dep_list:
dep = dep.split(';')[0]
name, ver = None, None

for sep in ['>=', '==', '<=', '<', '>']:
if sep in dep:
idx = dep.index(sep)
name = dep[:idx]
ver = dep[idx:]
break

if name is not None:
name = name.split('[')[0]
else:
name = dep.split('[')[0]
req = Requirement(dep)

# Transform pypi to conda name
if name == 'pyqt5':
name = 'pyqt'
if req.name == 'pyqt5':
req.name = 'pyqt'

deps[name] = ver
if req.specifier:
deps[req.name] = str(req.specifier)
else:
deps[req.name] = None

return deps

Expand Down Expand Up @@ -145,27 +130,22 @@ def parse_setup_extra_requires(fpath):
dep_list = dep_dict.get('test')
dep_list = [item for item in dep_list if item[0] != '#']
for dep in dep_list:
dep = dep.split(';')[0]
name, ver = None, None

for sep in ['>=', '==', '<=', '<', '>']:
if sep in dep:
idx = dep.index(sep)
name = dep[:idx]
ver = dep[idx:]
break

if name is not None:
name = name.split('[')[0]
else:
name = dep.split('[')[0]
req = Requirement(dep)

# Transform pypi to conda name
if name == 'pyqt5':
name = 'pyqt'
if req.name == 'pyqt5':
req.name = 'pyqt'

if req.marker and not req.marker.evaluate():
# Skip dependencies which are not required for current environment
# (e.g. skip 'platform_system=="Windows"' on Linux)
continue

if req.specifier:
deps[req.name] = str(req.specifier)
else:
deps[req.name] = None

deps[name] = ver
print(deps)
return deps


Expand Down

0 comments on commit 3867651

Please sign in to comment.