wowool-build 0.0.3.dev2__py3-none-any.whl → 0.0.4.dev2__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.
@@ -86,7 +86,7 @@ def delete_raw(
86
86
  raise UploadError(f"AWS CodeArtifact generic upload failed {cmd=}")
87
87
 
88
88
 
89
- def upload_raw(
89
+ def upload_raw_aws_cli(
90
90
  fn: Path,
91
91
  namespace: str,
92
92
  package: str,
@@ -120,6 +120,92 @@ def upload_raw(
120
120
  raise UploadError(f"AWS CodeArtifact generic upload failed: {error}")
121
121
 
122
122
 
123
+ def upload_raw(
124
+ fn: Path,
125
+ namespace: str,
126
+ package: str,
127
+ version: str,
128
+ aws: Optional[AwsCredentials] = None,
129
+ codeartifact: Optional[CodeArtifactCredentials] = None,
130
+ overwrite=False,
131
+ ):
132
+ """
133
+ Upload a raw asset to AWS CodeArtifact using boto3
134
+ """
135
+ fn = Path(fn)
136
+
137
+ try:
138
+ import boto3
139
+ except ImportError:
140
+ raise UploadError("boto3 is not installed. Please install it to use this function.")
141
+
142
+ aws = aws or AwsCredentials.from_environment()
143
+ codeartifact = codeartifact or CodeArtifactCredentials.from_environment()
144
+
145
+ # Check if credentials are valid
146
+ try:
147
+ sts_client = boto3.client("sts", region_name=aws.region)
148
+ identity = sts_client.get_caller_identity()
149
+ print(f"Using AWS Account: {identity['Account']}")
150
+ except Exception as e:
151
+ raise UploadError(f"AWS credential error: {e}")
152
+
153
+ # Create CodeArtifact client
154
+ client = boto3.client("codeartifact", region_name=aws.region)
155
+
156
+ # Delete existing version if overwrite is True
157
+ if overwrite:
158
+ try:
159
+ client.delete_package_versions(
160
+ domain=aws.domain,
161
+ domainOwner=str(aws.domain_owner),
162
+ repository=codeartifact.repository,
163
+ format="generic",
164
+ namespace=namespace,
165
+ package=package,
166
+ versions=[version],
167
+ )
168
+ print(f"Deleted existing version: {namespace}/{package}@{version}")
169
+ except Exception as error:
170
+ print(f"Note: Could not delete existing version: {error}", file=stderr)
171
+
172
+ # Calculate SHA-256 hash
173
+ try:
174
+ with open(fn, "rb", buffering=0) as ifs:
175
+ asset_hash = hashlib.file_digest(ifs, "sha256").hexdigest()
176
+ except Exception as error:
177
+ raise UploadError(f"Could not produce sha256 hash for {fn}: {error}")
178
+
179
+ # Read file content
180
+ try:
181
+ with open(fn, "rb") as f:
182
+ file_content = f.read()
183
+ except Exception as error:
184
+ raise UploadError(f"Could not read file {fn}: {error}")
185
+
186
+ # Upload the asset
187
+ try:
188
+ # Use publish_package_version instead
189
+ response = client.publish_package_version(
190
+ domain=aws.domain,
191
+ domainOwner=str(aws.domain_owner),
192
+ repository=codeartifact.repository,
193
+ format="generic",
194
+ namespace=namespace,
195
+ package=package,
196
+ packageVersion=version,
197
+ assetContent=file_content,
198
+ assetName=fn.name,
199
+ assetSHA256=asset_hash,
200
+ unfinished=True,
201
+ )
202
+
203
+ print(f"Successfully uploaded {fn.name} to {namespace}/{package}@{version}")
204
+ return response
205
+ except Exception as error:
206
+ raise UploadError(f"AWS CodeArtifact upload failed: {error}")
207
+
208
+
123
209
  def run_codeartifact(
124
210
  cmd: str,
125
211
  aws: Optional[AwsCredentials] = None,
@@ -212,20 +298,6 @@ def download_raw(
212
298
  except Exception as e:
213
299
  raise DownloadError(f"Error downloading asset: {str(e)} {output=}")
214
300
 
215
- output = Path(output)
216
-
217
- aws = aws or AwsCredentials.from_environment()
218
- codeartifact = codeartifact or CodeArtifactCredentials.from_environment()
219
- try:
220
- cmd = f"""aws codeartifact get-package-version-asset --package-version {version} --domain {aws.domain} --domain-owner {aws.domain_owner} --region {aws.region} --repository {codeartifact.repository} --format generic --namespace {namespace} --package {package} --asset {output.name} {output}"""
221
- result = run(cmd, shell=True, check=False, capture_output=True)
222
- print(result.stdout.decode())
223
- if result.returncode != 0:
224
- print(result.stderr.decode(), file=stderr)
225
- raise DownloadError(f"AWS CodeArtifact generic upload failed {cmd=}")
226
- except Exception as error:
227
- raise DownloadError(f"AWS CodeArtifact generic upload failed: {error}")
228
-
229
301
 
230
302
  def iter_packages(expression=".*", aws: Optional[AwsCredentials] = None, codeartifact: Optional[CodeArtifactCredentials] = None):
231
303
 
wowool/build/pypi.py CHANGED
@@ -20,7 +20,7 @@ def upload_pypi(fp: Path, expression: str = "*", repository: str | None = None):
20
20
  _check_not_dirty(fn)
21
21
  repository = environ.get("TWINE_REPOSITORY", None)
22
22
  repository_option = f"--repository-url {repository}" if repository else ""
23
- cmd = f"python -m twine upload {repository_option} dist/*"
23
+ cmd = f"python -m twine upload {repository_option} dist/{fn.name}"
24
24
  try:
25
25
  print(f"cmd: {cmd} {fn=} {fp_dist=}")
26
26
  run(cmd, shell=True, check=True, cwd=str(fp))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wowool-build
3
- Version: 0.0.3.dev2
3
+ Version: 0.0.4.dev2
4
4
  Summary: Wowool Build System
5
5
  Home-page: https://www.wowool.com/
6
6
  Author: Wowool
@@ -1,14 +1,14 @@
1
- wowool/build/codeartifact.py,sha256=ZOCqYwEdt1vW0g-jSwJMd6UFJZvNWqvLduhu0-jC04Y,9658
1
+ wowool/build/codeartifact.py,sha256=i1jOpdz7Ma3EGaFYq31W70h72XguuVBIZM4SIqRvI6Q,11619
2
2
  wowool/build/exceptions.py,sha256=04fMZc_bRMdinIqKCOqiwfO_xqwp_ZqO_SUgXfq4i58,88
3
3
  wowool/build/git.py,sha256=D3CGusjza6bkdI0YbKk-7HumbaPwNYxRWu9M0kT-rHc,3253
4
4
  wowool/build/logging.py,sha256=4ycT471N7V6vrEBXURF0-lho1hbmWA7PJyCHhfHVjeA,4988
5
5
  wowool/build/platform.py,sha256=dYEr4Pw0VyChQRnd0ZXwETXZsLVQ0tC9aC4Mu9KJZcc,901
6
6
  wowool/build/pydist.py,sha256=j_OiN2G-RVsQ8NwEv2gn19IBpJEcALIFUeYiDn_4NPY,3924
7
- wowool/build/pypi.py,sha256=fdPRdbPq2ZxWy3AdncL0qTWmUn_dA62NMWamwpC2Tto,921
7
+ wowool/build/pypi.py,sha256=3nlqSu590F2vodUivIa7oz5g9ZTbHc8-cjTGnrGRI2Y,929
8
8
  wowool/build/pytask.py,sha256=wlwnQGfVkEUiA_IcRYnz9_BM7hNmzpT_1turmwYHFEM,2879
9
9
  wowool/build/pytest.py,sha256=8F1ZklSvpTAnwODXZvzhF6qcND-MlDVbl-e4F1Pf3mI,5304
10
10
  wowool/build/utility.py,sha256=q5RwGFD5O9pewuIUxbYt5sA7lj6u1CjWi6PVWQwCxnQ,890
11
- wowool_build-0.0.3.dev2.dist-info/METADATA,sha256=DfwuEatWo5eILABLTtFG9Msqom5fq-U_POXqk-XGCz0,355
12
- wowool_build-0.0.3.dev2.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
13
- wowool_build-0.0.3.dev2.dist-info/top_level.txt,sha256=zerqoDN-iHSHwsS1SN2h0q4H6RI1FOVeHW8fNQC9YdU,7
14
- wowool_build-0.0.3.dev2.dist-info/RECORD,,
11
+ wowool_build-0.0.4.dev2.dist-info/METADATA,sha256=uK5jJ4RS0x1FWUmh5tmYDM_qAwSm0dFURFxF3Icy678,355
12
+ wowool_build-0.0.4.dev2.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
13
+ wowool_build-0.0.4.dev2.dist-info/top_level.txt,sha256=zerqoDN-iHSHwsS1SN2h0q4H6RI1FOVeHW8fNQC9YdU,7
14
+ wowool_build-0.0.4.dev2.dist-info/RECORD,,