Skip to content

Commit b6e5f4c

Browse files
authored
Merge pull request #7 from nexB/resolution
Add resolution for dependencies
2 parents 1fc0a12 + 8bdb257 commit b6e5f4c

24 files changed

Lines changed: 1568 additions & 95 deletions

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dev:
1818

1919
isort:
2020
@echo "-> Apply isort changes to ensure proper imports ordering"
21-
${VENV}/bin/isort --sl src tests
21+
${VENV}/bin/isort --sl -l 100 src tests
2222

2323
black:
2424
@echo "-> Apply black code formatter"
@@ -32,9 +32,10 @@ valid: isort black
3232

3333
check:
3434
@echo "-> Run pycodestyle (PEP8) validation"
35-
@${ACTIVATE} pycodestyle --max-line-length=100 --exclude=venv,lib,thirdparty,docs,migrations,settings.py .
35+
@${ACTIVATE} pycodestyle --max-line-length=110 \
36+
--exclude=.eggs,etc/scripts,src/_packagedcode,venv,lib,thirdparty,docs .
3637
@echo "-> Run isort imports ordering validation"
37-
@${ACTIVATE} isort --sl --check-only .
38+
@${ACTIVATE} isort --sl --check-only -l 100 src tests
3839
@echo "-> Run black validation"
3940
@${ACTIVATE} black --check -l 100
4041

README.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ The goal of python-inspector is to be a comprehensive library
2424
that can handle every style of Python package layouts, manifests and lockfiles.
2525

2626

27+
Usage
28+
--------
29+
30+
- Install with pip::
31+
32+
pip install python-inspector
33+
34+
- Run a command line with::
35+
36+
dad --help
37+
38+
39+
2740
Its companion libraries are:
2841

2942
- ``pip-requirements-parser``, a mostly correct pip requirements parsing

azure-pipelines.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,47 @@ jobs:
1111
parameters:
1212
job_name: ubuntu18_cpython
1313
image_name: ubuntu-18.04
14-
python_versions: ['3.6', '3.7', '3.8', '3.9', '3.10']
14+
python_versions: ['3.8', '3.9', '3.10']
1515
test_suites:
16-
all: venv/bin/pytest -n 2 -vvs
16+
all: |
17+
venv/bin/pytest -n 2 -vvs
1718
1819
- template: etc/ci/azure-posix.yml
1920
parameters:
2021
job_name: ubuntu20_cpython
2122
image_name: ubuntu-20.04
22-
python_versions: ['3.6', '3.7', '3.8', '3.9', '3.10']
23+
python_versions: ['3.8', '3.9', '3.10']
2324
test_suites:
2425
all: venv/bin/pytest -n 2 -vvs
2526

2627
- template: etc/ci/azure-posix.yml
2728
parameters:
2829
job_name: macos1015_cpython
2930
image_name: macos-10.15
30-
python_versions: ['3.6', '3.7', '3.8', '3.9', '3.10']
31+
python_versions: ['3.8', '3.9', '3.10']
3132
test_suites:
3233
all: venv/bin/pytest -n 2 -vvs
3334

3435
- template: etc/ci/azure-posix.yml
3536
parameters:
3637
job_name: macos11_cpython
3738
image_name: macos-11
38-
python_versions: ['3.7', '3.8', '3.9', '3.10']
39+
python_versions: ['3.8', '3.9', '3.10']
3940
test_suites:
4041
all: venv/bin/pytest -n 2 -vvs
4142

4243
- template: etc/ci/azure-win.yml
4344
parameters:
4445
job_name: win2019_cpython
4546
image_name: windows-2019
46-
python_versions: ['3.6', '3.7', '3.8', '3.9', '3.10']
47+
python_versions: ['3.8', '3.9', '3.10']
4748
test_suites:
4849
all: venv\Scripts\pytest -n 2 -vvs
4950

5051
- template: etc/ci/azure-win.yml
5152
parameters:
5253
job_name: win2022_cpython
5354
image_name: windows-2022
54-
python_versions: ['3.7', '3.8', '3.9', '3.10']
55+
python_versions: ['3.8', '3.9', '3.10']
5556
test_suites:
5657
all: venv\Scripts\pytest -n 2 -vvs

docs/source/dependencies-design.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ For each dependency, there can be a version "requirement" that can be an
2121
exact version, a version expression (aka. version specifier) as defined
2222
in `pep-0440 <https://www.python.org/dev/peps/pep-0440/>`__
2323
with additional OS and environment tags and constraints as specified in
24-
`pep-0508 <https://www.python.org/dev/peps/pep-0508/>`__ .
24+
`pep-0508 <https://www.python.org/dev/peps/pep-0508/>`__ .
2525

26-
In particular the required Python version of a package (or version specifier)
27-
can be set for the whole package (with the``python_requires`` attribute) or as
28-
a marker for a given direct or indirect dependency. pip processes requirement
26+
In particular the required Python version of a package (or version specifier)
27+
can be set for the whole package (with the``python_requires`` attribute) or as
28+
a marker for a given direct or indirect dependency. pip processes requirement
2929
specifiers and constraints from a "requirements" file and internally resolves
3030
dependency versions recursively by querying the PyPI Python package
3131
index repository at https://PyPI.org
@@ -129,7 +129,7 @@ And a flat list of unique dependencies would be:
129129
- thing 3.0
130130
- shebang 1.0
131131

132-
The implementation may likely be similar to
132+
The implementation may likely be similar to
133133
`pipgrip <https://github.com/ddelange/pipgrip>`__,
134134
but using the `resolvelib <https://github.com/sarugaku/resolvelib>`__
135135
library as used and vendored in pip instead of an implementation of
@@ -139,7 +139,7 @@ The expected benefit of this tool is a simpler way to resolve Python
139139
dependencies that will not require complex installation of a Python toolchain
140140
specific to a given project environment when the goal is only to resolve
141141
dependencies. In particular the key new capability is to run this tool on a
142-
single Python version and resolve versions for alternative Python versions,
142+
single Python version and resolve versions for alternative Python versions,
143143
operating systems and architectures without having to install all the packages
144144
in the dependency tree.
145145

@@ -158,7 +158,8 @@ The outline of the processing is to:
158158
- For each top-level requirement (e.g. name/version):
159159

160160
- Fetch all the corresponding versions metadata using the PyPI API(s)
161-
- Fetch the packages as needed to further obtain the next-level dependencies, and this recursively
161+
- Fetch the packages as needed to further obtain the next-level
162+
dependencies, and this recursively
162163

163164
- Resolve a correct dependency version for each name.
164165
- Dump JSON
@@ -168,7 +169,7 @@ User experience:
168169
----------------
169170

170171
The goal of the command line interface and user experience is to be
171-
obvious and familiar to a pip user.
172+
obvious and familiar to a pip user.
172173

173174
Create a new CLI named "dad" short for "dad analyzes dependencies" with
174175
these key options:
@@ -352,4 +353,3 @@ ScanCode Toolkit can detect the and normalize the declared licenses in package
352353
metadata and also collect and normalize all the metadata. This could be
353354
a refinement for later.
354355

355-

etc/scripts/utils_requirements.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# See https://github.com/nexB/skeleton for support or download.
99
# See https://aboutcode.org for more information about nexB OSS projects.
1010
#
11+
import os
1112
import re
1213
import subprocess
1314

requirements-dev.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
aboutcode-toolkit==7.0.2
2+
black==22.3.0
3+
bleach==4.1.0
4+
boolean.py==4.0
5+
cffi==1.15.0
6+
cryptography==37.0.2
7+
dataclasses==0.8
8+
docutils==0.18.1
9+
et-xmlfile==1.1.0
10+
execnet==1.9.0
11+
importlib-resources==5.4.0
12+
iniconfig==1.1.1
13+
isort==5.10.1
14+
jeepney==0.7.1
15+
jinja2==3.0.3
16+
keyring==23.4.1
17+
license-expression==30.0.0
18+
markupsafe==2.0.1
19+
mypy-extensions==0.4.3
20+
openpyxl==3.0.10
21+
pathspec==0.9.0
22+
pkginfo==1.8.3
23+
platformdirs==2.4.0
24+
pluggy==1.0.0
25+
py==1.11.0
26+
pycodestyle==2.8.0
27+
pycparser==2.21
28+
pygments==2.12.0
29+
pytest==7.0.1
30+
pytest-forked==1.4.0
31+
pytest-xdist==2.5.0
32+
readme-renderer==34.0
33+
requests-toolbelt==0.9.1
34+
rfc3986==1.5.0
35+
secretstorage==3.3.2
36+
six==1.16.0
37+
tomli==1.2.3
38+
tqdm==4.64.0
39+
twine==3.8.0
40+
typed-ast==1.5.4
41+
webencodings==0.5.1

requirements.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
attrs==21.4.0
2+
beautifulsoup4==4.11.1
3+
certifi==2022.5.18.1
4+
charset-normalizer==2.0.12
5+
click==8.0.4
6+
colorama==0.4.4
7+
commoncode==30.2.0
8+
dparse2==0.6.1
9+
idna==3.3
10+
importlib-metadata==4.8.3
11+
intbitset==3.0.1
12+
packageurl-python==0.9.9
13+
packaging==21.3
14+
pip-requirements-parser==31.2.0
15+
pkginfo2==30.0.0
16+
pyparsing==3.0.9
17+
PyYAML==6.0
18+
requests==2.27.1
19+
resolvelib==0.8.1
20+
saneyaml==0.5.2
21+
soupsieve==2.3.2.post1
22+
text-unidecode==1.3
23+
toml==0.10.2
24+
typing==3.6.6
25+
typing_extensions==4.1.1
26+
urllib3==1.26.9
27+
zipp==3.6.0

src/_packagedcode/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,12 @@ class DependentPackage(ModelMixin):
356356
"lockfiles for Composer or Cargo contain extra dependency data.",
357357
)
358358

359+
# dependencies = List(
360+
# item_type="DependentPackage",
361+
# label="dependencies",
362+
# help="A list of DependentPackage for this package.",
363+
# )
364+
359365

360366
@attr.attributes(slots=True)
361367
class Dependency(DependentPackage):

src/_packagedcode/pypi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ def get_requires_dependencies(requires, default_scope="install"):
812812
is_runtime=True,
813813
is_optional=False,
814814
is_resolved=is_resolved,
815-
extracted_requirement=requirement,
815+
extracted_requirement=str(req),
816816
)
817817
)
818818

0 commit comments

Comments
 (0)