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

Issue/drop pkg resources - first part #7990

Closed
wants to merge 89 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
37ee4b1
first commit
hlloreda Jul 31, 2024
7d333fe
Merge branch 'refs/heads/master' into issue/drop_pkg_resources
hlloreda Jul 31, 2024
021e009
wip
hlloreda Jul 31, 2024
1779105
mypy
hlloreda Jul 31, 2024
25893db
Merge branch 'refs/heads/master' into issue/drop_pkg_resources
hlloreda Aug 1, 2024
871e18d
refactor
hlloreda Aug 2, 2024
3a5743a
lower name
hlloreda Aug 8, 2024
a6a6dde
test
hlloreda Aug 9, 2024
c49b37e
Merge branch 'refs/heads/master' into issue/drop_pkg_resources
hlloreda Aug 9, 2024
a32e383
refactor
hlloreda Aug 9, 2024
3ea487c
Merge branch 'master' into issue/drop_pkg_resources
hlloreda Aug 19, 2024
3377996
rollback changes
hlloreda Aug 20, 2024
880d9da
rollback changes
hlloreda Aug 20, 2024
c5187f8
refactor
hlloreda Aug 21, 2024
a239a06
refactor
hlloreda Aug 21, 2024
06ea0cf
refactor
hlloreda Aug 21, 2024
aeb68cb
fix broken test
hlloreda Aug 21, 2024
c5d3246
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Aug 29, 2024
87e381a
refactor
hlloreda Aug 29, 2024
ae4915b
refactor
hlloreda Aug 29, 2024
4b8e2ad
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Aug 29, 2024
0768b2b
refactor
hlloreda Aug 29, 2024
8d71c66
add test safe requirement
hlloreda Aug 29, 2024
f884732
Remove SafeRequirement
hlloreda Aug 29, 2024
e523023
Remove SafeRequirement
hlloreda Aug 29, 2024
b0f0d8b
renaming
hlloreda Aug 29, 2024
b797205
Remove SafeRequirement
hlloreda Aug 29, 2024
259626f
fix parsing
hlloreda Aug 29, 2024
26420b2
fix name parameter
hlloreda Aug 30, 2024
b443555
refactor
hlloreda Aug 30, 2024
9a44a24
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Aug 30, 2024
fca2bfc
format mypy
hlloreda Aug 30, 2024
db0591c
fix comparing versions
hlloreda Sep 2, 2024
10b41bd
refactor + fix broken calls
hlloreda Sep 2, 2024
0c8d292
rollback + fix broken tests
hlloreda Sep 2, 2024
7962876
refactor
hlloreda Sep 2, 2024
f902c99
fix broken tests
hlloreda Sep 2, 2024
00c5506
refactor
hlloreda Sep 6, 2024
d65b1c0
Merge branch 'refs/heads/master' into issue/drop_pkg_resources_2
hlloreda Sep 16, 2024
e6975c5
merge master + introduce new type
hlloreda Sep 16, 2024
c8ec877
fix broken tests
hlloreda Sep 16, 2024
43a64c0
fix broken tests
hlloreda Sep 16, 2024
917f9ef
add warnings + use new name property
hlloreda Sep 16, 2024
1c43dc7
fix + mypy
hlloreda Sep 16, 2024
1dce986
refactor
hlloreda Sep 16, 2024
d241433
retake with plugins
hlloreda Sep 16, 2024
3a64bed
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Sep 17, 2024
8a88093
rollback old changes
hlloreda Sep 17, 2024
a046cf8
add missing test
hlloreda Sep 17, 2024
1896d2e
missing <
hlloreda Sep 17, 2024
22e4d1d
wrong number
hlloreda Sep 17, 2024
0c3ab6e
resolve mypy problems
hlloreda Sep 17, 2024
4f13c5d
refactor
hlloreda Sep 17, 2024
8e15960
more cases
hlloreda Sep 17, 2024
d8d03ac
refactor
hlloreda Sep 18, 2024
cc46563
refactor wrong type
hlloreda Sep 18, 2024
5fd461a
mypy-sync
hlloreda Sep 18, 2024
9037100
refactor
hlloreda Sep 18, 2024
d34ba90
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Sep 18, 2024
84270ae
fix broken tests
hlloreda Sep 18, 2024
6134daa
refactor
hlloreda Sep 18, 2024
45ef63f
refactor
hlloreda Sep 18, 2024
ab6f098
refactor
hlloreda Sep 18, 2024
4fb8902
regex broke tests
hlloreda Sep 18, 2024
784e533
remove old regex
hlloreda Sep 18, 2024
c750b49
incomplete refactor
hlloreda Sep 18, 2024
0993635
refactor
hlloreda Sep 18, 2024
cd11875
refactor
hlloreda Sep 18, 2024
c40fe2b
fix
hlloreda Sep 19, 2024
63f0a5f
refactor
hlloreda Sep 19, 2024
8facdcf
docstring
hlloreda Sep 19, 2024
bc43a12
refactor
hlloreda Sep 19, 2024
ccab505
add changelog
hlloreda Sep 20, 2024
254c14e
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Sep 20, 2024
d86a63f
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Sep 23, 2024
ae80eb8
refactor
hlloreda Sep 23, 2024
2d7bda9
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Sep 24, 2024
ba749a6
fix broken tests
hlloreda Sep 24, 2024
6aae7ae
revert change
hlloreda Sep 25, 2024
ba01c4d
rollback
hlloreda Sep 30, 2024
b12c5d2
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Sep 30, 2024
24692f8
refactor
hlloreda Sep 30, 2024
dc95c99
refactor
hlloreda Sep 30, 2024
3e71ebf
refactor to make sure to not share this instance
hlloreda Sep 30, 2024
2d79e9e
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Oct 1, 2024
d77a95d
refactor
hlloreda Oct 2, 2024
af785c4
remove constraint on setuptools
hlloreda Oct 2, 2024
8e4ae57
missing revert changes
hlloreda Oct 2, 2024
73d9cf3
missing revert changes
hlloreda Oct 2, 2024
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 .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ updates:
# Allow both direct and indirect updates for all packages
- dependency-type: "all"
ignore:
# #6668
- dependency-name: "setuptools"
update-types: ["version-update:semver-major"]
- dependency-name: "pytest-inmanta-extensions"
versions: [">=0.0.1"]
- dependency-name: "pydantic"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"pynacl~=1.5",
"python-dateutil~=2.0",
"pyyaml~=6.0",
"setuptools<71",
"setuptools",
"texttable~=1.0",
"tornado~=6.0",
# lower bound because of ilevkivskyi/typing_inspect#100
Expand Down
6 changes: 2 additions & 4 deletions src/inmanta/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,11 @@ def __init__(self, requirement: inmanta.util.CanonicalRequirement) -> None:
f"InmantaModuleRequirement instances work with inmanta module names, not python package names. "
f"Problematic case: {str(requirement)}"
)
self._requirement: inmanta.util.CanonicalRequirement = requirement
self._requirement = inmanta.util.parse_requirement(str(requirement))
sanderr marked this conversation as resolved.
Show resolved Hide resolved

@property
def project_name(self) -> str:
sanderr marked this conversation as resolved.
Show resolved Hide resolved
# Requirement converts all "_" to "-". Inmanta modules use "_"
warnings.warn(InmantaWarning("The `project_name` property has been deprecated in favor of `name`"))

return self.name

@property
Expand All @@ -121,7 +119,7 @@ def name(self) -> str:
def key(self) -> str:
# Requirement converts all "_" to "-". Inmanta modules use "_"
warnings.warn(InmantaWarning("The `key` property has been deprecated in favor of `name`"))
return self._requirement.name.replace("-", "_")
return self.name

@property
def specifier(self) -> SpecifierSet:
Expand Down
24 changes: 12 additions & 12 deletions tests/moduletool/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,17 @@ def modules_repo(git_modules_dir) -> str:
E-> H
D-> F,G
"""
make_module_simple_deps(reporoot, "A", ["B", "C", "D"], project=True)
make_module_simple_deps(reporoot, "B")
c = make_module_simple_deps(reporoot, "C", ["E", "F", "E::a"], version="3.0")
add_file(c, "model/a.cf", "import modI", "add mod C::a", "3.2")
make_module_simple_deps(reporoot, "D", ["F", "G"])
e = make_module_simple_deps(reporoot, "E", ["H"], version="3.0")
add_file(e, "model/a.cf", "import modJ", "add mod E::a", "3.2")
make_module_simple_deps(reporoot, "F")
make_module_simple_deps(reporoot, "G")
make_module_simple_deps(reporoot, "H")
make_module_simple_deps(reporoot, "I")
make_module_simple_deps(reporoot, "J")
make_module_simple_deps(reporoot, "a", ["b", "c", "d"], project=True)
make_module_simple_deps(reporoot, "b")
c = make_module_simple_deps(reporoot, "c", ["e", "f", "e::a"], version="3.0")
add_file(c, "model/a.cf", "import modi", "add mod c::a", "3.2")
make_module_simple_deps(reporoot, "d", ["f", "g"])
e = make_module_simple_deps(reporoot, "e", ["h"], version="3.0")
add_file(e, "model/a.cf", "import modj", "add mod e::a", "3.2")
make_module_simple_deps(reporoot, "f")
make_module_simple_deps(reporoot, "g")
make_module_simple_deps(reporoot, "h")
make_module_simple_deps(reporoot, "i")
make_module_simple_deps(reporoot, "j")

return reporoot
112 changes: 56 additions & 56 deletions tests/moduletool/test_freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,42 +32,42 @@

@pytest.mark.slowtest
def test_freeze_basic(git_modules_dir: str, modules_repo: str, tmpdir):
install_project(git_modules_dir, "projectA", tmpdir)
install_project(git_modules_dir, "projecta", tmpdir)
modtool = ModuleTool()
cmod = modtool.get_module("modC")
assert cmod.get_freeze("modC", recursive=False, mode="==") == {"std": "== 3.2", "modE": "== 3.2", "modF": "== 3.2"}
assert cmod.get_freeze("modC", recursive=True, mode="==") == {
cmod = modtool.get_module("modc")
assert cmod.get_freeze("modc", recursive=False, mode="==") == {"std": "== 3.2", "mode": "== 3.2", "modf": "== 3.2"}
assert cmod.get_freeze("modc", recursive=True, mode="==") == {
"std": "== 3.2",
"modE": "== 3.2",
"modF": "== 3.2",
"modH": "== 3.2",
"modJ": "== 3.2",
"mode": "== 3.2",
"modf": "== 3.2",
"modh": "== 3.2",
"modj": "== 3.2",
}

assert cmod.get_freeze("modC::a", recursive=False, mode="==") == {"std": "== 3.2", "modI": "== 3.2"}
assert cmod.get_freeze("modc::a", recursive=False, mode="==") == {"std": "== 3.2", "modi": "== 3.2"}


@pytest.mark.slowtest
def test_project_freeze_basic(git_modules_dir: str, modules_repo: str, tmpdir):
install_project(git_modules_dir, "projectA", tmpdir)
install_project(git_modules_dir, "projecta", tmpdir)
modtool = ModuleTool()
proj = modtool.get_project()
assert proj.get_freeze(recursive=False, mode="==") == {
"std": "== 3.2",
"modB": "== 3.2",
"modC": "== 3.2",
"modD": "== 3.2",
"modb": "== 3.2",
"modc": "== 3.2",
"modd": "== 3.2",
}
assert proj.get_freeze(recursive=True, mode="==") == {
"std": "== 3.2",
"modB": "== 3.2",
"modC": "== 3.2",
"modD": "== 3.2",
"modE": "== 3.2",
"modF": "== 3.2",
"modG": "== 3.2",
"modH": "== 3.2",
"modJ": "== 3.2",
"modb": "== 3.2",
"modc": "== 3.2",
"modd": "== 3.2",
"mode": "== 3.2",
"modf": "== 3.2",
"modg": "== 3.2",
"modh": "== 3.2",
"modj": "== 3.2",
}


Expand All @@ -85,7 +85,7 @@ def test_project_freeze_bad(git_modules_dir: str, modules_repo: str, tmpdir):

@pytest.mark.slowtest
def test_project_freeze(git_modules_dir: str, modules_repo: str, capsys, tmpdir):
coroot = install_project(git_modules_dir, "projectA", tmpdir)
coroot = install_project(git_modules_dir, "projecta", tmpdir)

app(["project", "freeze", "-o", "-"])

Expand All @@ -95,16 +95,16 @@ def test_project_freeze(git_modules_dir: str, modules_repo: str, capsys, tmpdir)
assert len(err) == 0, err
assert (
out
== """name: projectA
== """name: projecta
license: Apache 2.0
version: 0.0.1
modulepath: libs
downloadpath: libs
repo: %s
requires:
- modB ~= 3.2
- modC ~= 3.2
- modD ~= 3.2
- modb ~= 3.2
- modc ~= 3.2
- modd ~= 3.2
- std ~= 3.2
"""
% modules_repo
Expand All @@ -113,7 +113,7 @@ def test_project_freeze(git_modules_dir: str, modules_repo: str, capsys, tmpdir)

@pytest.mark.slowtest
def test_project_freeze_disk(git_modules_dir: str, modules_repo: str, capsys, tmpdir):
coroot = install_project(git_modules_dir, "projectA", tmpdir)
coroot = install_project(git_modules_dir, "projecta", tmpdir)

app(["project", "freeze"])

Expand All @@ -125,16 +125,16 @@ def test_project_freeze_disk(git_modules_dir: str, modules_repo: str, capsys, tm
with open(os.path.join(coroot, "project.yml"), encoding="utf-8") as fh:
assert (
fh.read()
== """name: projectA
== """name: projecta
license: Apache 2.0
version: 0.0.1
modulepath: libs
downloadpath: libs
repo: %s
requires:
- modB ~= 3.2
- modC ~= 3.2
- modD ~= 3.2
- modb ~= 3.2
- modc ~= 3.2
- modd ~= 3.2
- std ~= 3.2
"""
% modules_repo
Expand All @@ -143,7 +143,7 @@ def test_project_freeze_disk(git_modules_dir: str, modules_repo: str, capsys, tm

@pytest.mark.slowtest
def test_project_freeze_odd_opperator(git_modules_dir: str, modules_repo: str, tmpdir):
coroot = install_project(git_modules_dir, "projectA", tmpdir)
coroot = install_project(git_modules_dir, "projecta", tmpdir)

# Start a new subprocess, because inmanta-cli executes sys.exit() when an invalid argument is used.
process = subprocess.Popen(
Expand All @@ -165,10 +165,10 @@ def test_project_freeze_odd_opperator(git_modules_dir: str, modules_repo: str, t
def test_project_options_in_config(git_modules_dir: str, modules_repo: str, capsys, tmpdir):
coroot = install_project(
git_modules_dir,
"projectA",
"projecta",
tmpdir,
config_content=f"""
name: projectA
name: projecta
license: Apache 2.0
version: 0.0.1
modulepath: libs
Expand All @@ -188,7 +188,7 @@ def verify():

with open("project.yml", encoding="utf-8") as fh:
assert fh.read() == (
"""name: projectA
"""name: projecta
license: Apache 2.0
version: 0.0.1
modulepath: libs
Expand All @@ -197,14 +197,14 @@ def verify():
freeze_recursive: true
freeze_operator: ==
requires:
- modB == 3.2
- modC == 3.2
- modD == 3.2
- modE == 3.2
- modF == 3.2
- modG == 3.2
- modH == 3.2
- modJ == 3.2
- modb == 3.2
- modc == 3.2
- modd == 3.2
- mode == 3.2
- modf == 3.2
- modg == 3.2
- modh == 3.2
- modj == 3.2
- std == 3.2
"""
% modules_repo
Expand All @@ -218,58 +218,58 @@ def verify():

@pytest.mark.slowtest
def test_module_freeze(git_modules_dir: str, modules_repo: str, capsys, tmpdir):
coroot = install_project(git_modules_dir, "projectA", tmpdir)
coroot = install_project(git_modules_dir, "projecta", tmpdir)

def verify():
out, err = capsys.readouterr()

assert os.path.getsize(os.path.join(coroot, "project.yml")) != 0
assert len(err) == 0, err
assert out == (
"""name: modC
"""name: modc
license: Apache 2.0
version: '3.2'
requires:
- modE ~= 3.2
- modF ~= 3.2
- modI ~= 3.2
- mode ~= 3.2
- modf ~= 3.2
- modi ~= 3.2
- std ~= 3.2
"""
)

app(["module", "-m", "modC", "freeze", "-o", "-"])
app(["module", "-m", "modc", "freeze", "-o", "-"])
verify()


@pytest.mark.slowtest
def test_module_freeze_self_disk(git_modules_dir: str, modules_repo: str, capsys, tmpdir):
coroot = install_project(git_modules_dir, "projectA", tmpdir)
coroot = install_project(git_modules_dir, "projecta", tmpdir)

def verify():
out, err = capsys.readouterr()

assert len(err) == 0, err
assert len(out) == 0, out

modpath = os.path.join(coroot, "libs/modC/module.yml")
modpath = os.path.join(coroot, "libs/modc/module.yml")
assert os.path.getsize(os.path.join(coroot, "project.yml")) != 0
assert os.path.getsize(modpath) != 0

with open(modpath, encoding="utf-8") as fh:
outf = fh.read()
assert outf == (
"""name: modC
"""name: modc
license: Apache 2.0
version: '3.2'
requires:
- modE ~= 3.2
- modF ~= 3.2
- modI ~= 3.2
- mode ~= 3.2
- modf ~= 3.2
- modi ~= 3.2
- std ~= 3.2
"""
)

modp = os.path.join(coroot, "libs/modC")
modp = os.path.join(coroot, "libs/modc")
app(["project", "install"])
os.chdir(modp)
app(["module", "freeze"])
Expand Down