frigobar 2__tar.gz → 3__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: frigobar
3
- Version: 2
3
+ Version: 3
4
4
  Summary: Distribute Python apps to Windows machines without freezing them.
5
5
  Project-URL: Homepage, https://github.com/ubalklen/my_package
6
6
  Project-URL: Bug Tracker, https://github.com/ubalklen/my_package/issues
@@ -46,7 +46,16 @@ def create_frigobar(
46
46
  if not copy_directory:
47
47
  shutil.copy(script_path, script_dir)
48
48
  else:
49
- shutil.copytree(os.path.dirname(script_path), script_dir, dirs_exist_ok=True)
49
+
50
+ def ignore_target_dir(dir, contents):
51
+ return [c for c in contents if os.path.join(dir, c) == target_directory]
52
+
53
+ shutil.copytree(
54
+ os.path.dirname(script_path),
55
+ script_dir,
56
+ dirs_exist_ok=True,
57
+ ignore=ignore_target_dir,
58
+ )
50
59
 
51
60
  # Add a copy of the requirements file to frigobar
52
61
  if requirements_file:
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "frigobar"
7
- version = "2"
7
+ version = "3"
8
8
  description = "Distribute Python apps to Windows machines without freezing them."
9
9
  authors = [
10
10
  {name="ubalklen", email="42127323+ubalklen@users.noreply.github.com"},
@@ -21,6 +21,14 @@ def delete_test_frigobar():
21
21
  shutil.rmtree(target_dir, ignore_errors=True)
22
22
 
23
23
 
24
+ @pytest.fixture
25
+ def target_dir_inside_script_dir():
26
+ new_target_dir = path.join(test_dir, "script_folder", "test_frigobar")
27
+ shutil.rmtree(new_target_dir, ignore_errors=True)
28
+ yield new_target_dir
29
+ shutil.rmtree(new_target_dir, ignore_errors=True)
30
+
31
+
24
32
  def test_create_frigobar_abs_script_path():
25
33
  frigobar.create_frigobar(
26
34
  script_path=script_path,
@@ -75,7 +83,7 @@ powershell -ExecutionPolicy Bypass -File "%~dp0downloaders\download_deps.ps1" -R
75
83
  )
76
84
 
77
85
 
78
- def test_create_frigobar_with_folder():
86
+ def test_create_frigobar_copy_script_dir():
79
87
  frigobar.create_frigobar(
80
88
  script_path=script_path,
81
89
  target_directory=target_dir,
@@ -105,7 +113,7 @@ powershell -ExecutionPolicy Bypass -File "%~dp0downloaders\download_deps.ps1" -R
105
113
  )
106
114
 
107
115
 
108
- def test_create_frigobar_with_folder_and_rel_script_path():
116
+ def test_create_frigobar_copy_script_dir_and_rel_script_path():
109
117
  os.chdir(os.path.dirname(script_path))
110
118
  script_rel_path = os.path.basename(script_path)
111
119
  frigobar.create_frigobar(
@@ -137,6 +145,48 @@ powershell -ExecutionPolicy Bypass -File "%~dp0downloaders\download_deps.ps1" -R
137
145
  )
138
146
 
139
147
 
148
+ def test_create_frigobar_target_dir_inside_script_dir(target_dir_inside_script_dir):
149
+ frigobar.create_frigobar(
150
+ script_path=script_path,
151
+ target_directory=target_dir_inside_script_dir,
152
+ requirements_file=requirements_file,
153
+ python_version=python_version,
154
+ copy_directory=True,
155
+ )
156
+
157
+ assert path.exists(path.join(target_dir_inside_script_dir, "script", "script.py"))
158
+ assert path.exists(
159
+ path.join(target_dir_inside_script_dir, "script", "another_script.py")
160
+ )
161
+ assert path.exists(path.join(target_dir_inside_script_dir, "script", "data"))
162
+ assert path.exists(
163
+ path.join(target_dir_inside_script_dir, "script", "data", "data")
164
+ )
165
+ assert path.exists(
166
+ path.join(target_dir_inside_script_dir, "script", "requirements.txt")
167
+ )
168
+ assert path.exists(
169
+ path.join(target_dir_inside_script_dir, "downloaders", "download_python.ps1")
170
+ )
171
+ assert path.exists(
172
+ path.join(target_dir_inside_script_dir, "downloaders", "download_pip.ps1")
173
+ )
174
+ assert path.exists(
175
+ path.join(target_dir_inside_script_dir, "downloaders", "download_deps.ps1")
176
+ )
177
+ assert path.exists(path.join(target_dir_inside_script_dir, "script.bat"))
178
+
179
+ with open(path.join(target_dir_inside_script_dir, "script.bat"), "r") as f:
180
+ assert (
181
+ f.read()
182
+ == r'''powershell Unblock-File -Path '%~dp0downloaders\download_python.ps1'
183
+ powershell -ExecutionPolicy Bypass -File "%~dp0downloaders\download_python.ps1" -Version 3.8.5 -TargetDirectory "."
184
+ powershell -ExecutionPolicy Bypass -File "%~dp0downloaders\download_pip.ps1" -TargetDirectory "python-3.8.5-embed-amd64"
185
+ powershell -ExecutionPolicy Bypass -File "%~dp0downloaders\download_deps.ps1" -RequirementsFile "script\requirements.txt" -PipPath "python-3.8.5-embed-amd64\Scripts\pip.exe"
186
+ "%~dp0/python-3.8.5-embed-amd64/python.exe" "script\script.py"'''
187
+ )
188
+
189
+
140
190
  def test_create_frigobar_without_reqs():
141
191
  frigobar.create_frigobar(
142
192
  script_path=script_path,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes