csspin-python 3.1.1__py3-none-any.whl → 3.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
csspin_python/python.py CHANGED
@@ -74,9 +74,10 @@ import os
74
74
  import re
75
75
  import shutil
76
76
  import sys
77
+ from contextlib import contextmanager
77
78
  from subprocess import check_output
78
79
  from textwrap import dedent, indent
79
- from typing import Iterable, Type, Union
80
+ from typing import Generator, Iterable, Type, Union
80
81
 
81
82
  try:
82
83
  from typing import Self # type: ignore[attr-defined]
@@ -164,6 +165,7 @@ defaults = config(
164
165
  client_secret="", # nosec: B106
165
166
  ),
166
167
  index_url="https://pypi.org/simple",
168
+ skip_js_build=None,
167
169
  requires=config(python=["build", "wheel"]),
168
170
  )
169
171
 
@@ -289,12 +291,23 @@ def nuget_install(cfg: ConfigTree) -> None:
289
291
 
290
292
  def provision(cfg: ConfigTree) -> None:
291
293
  """Provision the python plugin"""
294
+ if not cfg.python.use and exists(cfg.python.python):
295
+ python_version = (
296
+ check_output([cfg.python.python, "--version"])
297
+ .decode()
298
+ .strip()
299
+ .replace("Python ", "")
300
+ )
301
+ if python_version and not python_version.startswith(cfg.python.version):
302
+ _cleanup_memoed_provisioners(cfg)
303
+ rmtree(cfg.python.provisioner_memo)
304
+ rmtree(cfg.python.aws_auth.memo)
305
+ rmtree(cfg.python.venv)
292
306
  with memoizer(cfg.python.provisioner_memo) as memo:
293
307
  if cfg.python.provisioner is None:
294
308
  cfg.python.provisioner = SimpleProvisioner(cfg)
295
309
  if not memo.check(cfg.python.provisioner):
296
310
  memo.add(cfg.python.provisioner)
297
-
298
311
  if not shutil.which(cfg.python.interpreter):
299
312
  cfg.python.provisioner.provision_python(cfg)
300
313
 
@@ -332,6 +345,10 @@ def configure(cfg: ConfigTree) -> None:
332
345
 
333
346
  if exists(cfg.python.python):
334
347
  cfg.python.site_packages = get_site_packages(interpreter=cfg.python.python)
348
+ # Built JS should still be available in this case
349
+ # Skip only if users hasn't explicitly set it to False
350
+ if cfg.python.skip_js_build is None:
351
+ cfg.python.skip_js_build = True
335
352
 
336
353
  if cfg.python.aws_auth.enabled:
337
354
  _check_aws_token_validity(cfg)
@@ -810,13 +827,31 @@ class SimpleProvisioner(ProvisionerProtocol):
810
827
  )
811
828
 
812
829
  def install(self: Self, cfg: ConfigTree) -> None:
813
- if requirements := self._filter(
814
- self._requirements, self._m, cfg.spin.project_root
815
- ):
816
- self._install_command(*self._split(requirements))
817
- self._m.clear()
818
- for req in requirements:
819
- self._m.add(_req_for_memo(req, cfg.spin.project_root))
830
+ @contextmanager
831
+ def skip_js_build(cfg: ConfigTree) -> Generator[None, None, None]:
832
+ if cfg.python.skip_js_build:
833
+ try:
834
+ setenv(SETUPTOOLS_CE_BUILD_JS_SKIP=1)
835
+ yield
836
+ setenv(SETUPTOOLS_CE_BUILD_JS_SKIP=None)
837
+ finally:
838
+ # Make sure the variable will not be written into the
839
+ # activation scripts
840
+ global EXPORTS # pylint: disable=global-statement
841
+ EXPORTS = [
842
+ (k, v) for k, v in EXPORTS if k != "SETUPTOOLS_CE_BUILD_JS_SKIP"
843
+ ]
844
+ else:
845
+ yield
846
+
847
+ with skip_js_build(cfg):
848
+ if self._m.items():
849
+ self._install_command("--upgrade", *self._split(self._requirements))
850
+ else:
851
+ self._install_command(*self._split(self._requirements))
852
+ self._m.clear()
853
+ for req in self._requirements:
854
+ self._m.add(_req_for_memo(req, cfg.spin.project_root))
820
855
 
821
856
  @staticmethod
822
857
  def _split(requirements: Iterable[str]) -> list[str]:
@@ -826,20 +861,6 @@ class SimpleProvisioner(ProvisionerProtocol):
826
861
  requirement_list.extend(requirement.split())
827
862
  return requirement_list
828
863
 
829
- @staticmethod
830
- def _filter(
831
- requirements: set[str], memo: Memoizer, project_root: Union[Path, str]
832
- ) -> set[str]:
833
- """
834
- We want to filter all requirements prior to installing them, because we
835
- only want to run the install, when there are changes, as it takes pip
836
- quite some time to check, whether it has to do something.
837
- """
838
- if all(memo.check(_req_for_memo(req, project_root)) for req in requirements):
839
- return set()
840
- else:
841
- return requirements
842
-
843
864
 
844
865
  def _file_hash(filename: Union[Path, str]) -> str:
845
866
  """
@@ -901,8 +922,8 @@ def venv_provision( # pylint: disable=too-many-branches,missing-function-docstr
901
922
  cfg: ConfigTree,
902
923
  ) -> None:
903
924
  fresh_env = False
904
-
905
925
  info("Checking venv '{python.venv}'")
926
+
906
927
  if not exists(cfg.python.venv):
907
928
  info("Provisioning venv '{python.venv}'")
908
929
  cfg.python.provisioner.provision_venv(cfg)
@@ -943,6 +964,19 @@ def venv_provision( # pylint: disable=too-many-branches,missing-function-docstr
943
964
 
944
965
  def cleanup(cfg: ConfigTree) -> None:
945
966
  """Remove directories and files generated by the python plugin."""
967
+ _cleanup_memoed_provisioners(cfg)
968
+ rmtree(cfg.python.provisioner_memo)
969
+ rmtree(cfg.python.aws_auth.memo)
970
+ for path in cfg.python.build_wheels:
971
+ current_path = Path(interpolate1(path))
972
+ rmtree(current_path / "build")
973
+ rmtree(current_path / "dist")
974
+ for filename in os.listdir(current_path):
975
+ if filename.endswith(".egg-info") or filename.endswith(".dist-info"):
976
+ rmtree(current_path / filename)
977
+
978
+
979
+ def _cleanup_memoed_provisioners(cfg: ConfigTree) -> None:
946
980
  with memoizer(cfg.python.provisioner_memo) as memo:
947
981
  for provisioner in memo.items():
948
982
  try:
@@ -954,16 +988,6 @@ def cleanup(cfg: ConfigTree) -> None:
954
988
  )
955
989
  memo.clear()
956
990
 
957
- rmtree(cfg.python.provisioner_memo)
958
- rmtree(cfg.python.aws_auth.memo)
959
- for path in cfg.python.build_wheels:
960
- current_path = Path(interpolate1(path))
961
- rmtree(current_path / "build")
962
- rmtree(current_path / "dist")
963
- for filename in os.listdir(current_path):
964
- if filename.endswith(".egg-info") or filename.endswith(".dist-info"):
965
- rmtree(current_path / filename)
966
-
967
991
 
968
992
  def _get_pipconf(cfg: ConfigTree) -> Path:
969
993
  """Retrieve the pipconf configuration file path."""
@@ -160,3 +160,8 @@ python:
160
160
  role_arn:
161
161
  type: str
162
162
  help: The role ARN to assume when authenticating.
163
+ skip_js_build:
164
+ type: bool
165
+ help: |
166
+ If true the build_js part of setuptools_ce will be skipped
167
+ during provision.
@@ -1,11 +1,15 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: csspin-python
3
- Version: 3.1.1
3
+ Version: 3.2.0
4
4
  Summary: Plugin-package for csspin providing Python related plugins
5
5
  Author-email: CONTACT Software GmbH <info@contact-software.com>
6
6
  Maintainer-email: Waleri Enns <waleri.enns@contact-software.com>, Benjamin Thomas Schwertfeger <benjaminthomas.schwertfeger@contact-software.com>, Fabian Hafer <fabian.hafer@contact-software.com>
7
7
  License-Expression: Apache-2.0
8
- Project-URL: Homepage, https://contact-software.com
8
+ Project-URL: CONTACT Software GmbH, https://contact-software.com
9
+ Project-URL: Documentation, https://csspin-python.readthedocs.io/en/stable/
10
+ Project-URL: Issue Tracker, https://github.com/cslab/csspin-python/issues
11
+ Project-URL: Release Notes, https://csspin-python.readthedocs.io/en/stable/relnotes.html
12
+ Project-URL: Repository, https://github.com/cslab/csspin-python
9
13
  Classifier: Environment :: Console
10
14
  Classifier: Development Status :: 5 - Production/Stable
11
15
  Classifier: Intended Audience :: Developers
@@ -8,14 +8,14 @@ csspin_python/playwright.py,sha256=oFfphLqa4AB6K9vasCUFHN0kFXu63n3ocrsqVuRp4-0,5
8
8
  csspin_python/playwright_schema.yaml,sha256=TSeR16YHa7m7bfO59F2eMV-jXcglluTJdEpUeL16saY,1178
9
9
  csspin_python/pytest.py,sha256=pTOb5zFd9RINZwJsHNaRuSGVDkPMABzaAhwpAJo1nQE,4574
10
10
  csspin_python/pytest_schema.yaml,sha256=tzXtdF6MvGC9v59EVRJFfLeMMHqPsXcFXy2zJtRECBI,1535
11
- csspin_python/python.py,sha256=32L4S6fKMWh5tbU-Rv5l6NVqrjjPLAiL25cB5gfeiC4,34784
12
- csspin_python/python_schema.yaml,sha256=_EBDglOM9AuXOvYUjFRJkUmtezCHcObEYmO64f-FOHI,6176
11
+ csspin_python/python.py,sha256=rSdF72FkcxiCrzLWSV7Cr4Thx5OgHGN7b6RKgOaXFEg,35871
12
+ csspin_python/python_schema.yaml,sha256=pgVVjByUYjxQWek7aFmjQzRwmq2ROLvHYgwGPMrT9sM,6351
13
13
  csspin_python/radon.py,sha256=uFqm6FEi5oWj-_XVaAm3s9cam0cUmr1_FwRf40K6xWs,1876
14
14
  csspin_python/radon_schema.yaml,sha256=rlRzXw5z4XbjOVznRiUxWGP4E9hx1Jm-gGw1iQiYzE0,548
15
15
  csspin_python/uv_provisioner.py,sha256=MGedx4e286ZE1miwh70y6b3wePw3mmc0m1kG6H_738I,5999
16
16
  csspin_python/uv_provisioner_schema.yaml,sha256=Y8ZNC2OMnhR8Us3WUXAXK9hMjqGWAKFJB2puX4X5XNQ,727
17
- csspin_python-3.1.1.dist-info/licenses/LICENSE,sha256=4MAecetnRTQw5DlHtiikDSzKWO1xVLwzM5_DsPMYlnE,10172
18
- csspin_python-3.1.1.dist-info/METADATA,sha256=OsIblHbaQVC9ybAydVQ1L-YEzqKtzw3qyJZnXqc-nZs,4715
19
- csspin_python-3.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
- csspin_python-3.1.1.dist-info/top_level.txt,sha256=QSeglMEGbFu1z4L6MCQYwo01NgL0KojWvC4rzgMQ8gU,14
21
- csspin_python-3.1.1.dist-info/RECORD,,
17
+ csspin_python-3.2.0.dist-info/licenses/LICENSE,sha256=4MAecetnRTQw5DlHtiikDSzKWO1xVLwzM5_DsPMYlnE,10172
18
+ csspin_python-3.2.0.dist-info/METADATA,sha256=54Kz-P7RQC4aHc31QmvyZnY2QSZgrnn9BnIW5ogr8ws,5031
19
+ csspin_python-3.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
+ csspin_python-3.2.0.dist-info/top_level.txt,sha256=QSeglMEGbFu1z4L6MCQYwo01NgL0KojWvC4rzgMQ8gU,14
21
+ csspin_python-3.2.0.dist-info/RECORD,,