glpkg 1.4.2__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.
glpkg-1.4.2/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2025 bugproduction
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
glpkg-1.4.2/PKG-INFO ADDED
@@ -0,0 +1,169 @@
1
+ Metadata-Version: 2.4
2
+ Name: glpkg
3
+ Version: 1.4.2
4
+ Summary: Tool to make GitLab generic package registry operations easy.
5
+ Author-email: bugproduction <bugproduction@outlook.com>
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://gitlab.com/bugproduction/glpkg.git
8
+ Keywords: GitLab,packages,registry,generic
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE.md
12
+ Dynamic: license-file
13
+
14
+ # glpkg - GitLab Generic Package tools
15
+
16
+ glpkg is a tool that makes it easy to work with [GitLab generic packages](https://docs.gitlab.com/user/packages/generic_packages/).
17
+
18
+ Generic package registries of GitLab projects are supported. Group registries are not, as the GitLab REST API for groups is very limited.
19
+
20
+ ## Installation
21
+
22
+ Install the tool from with pip:
23
+
24
+ ```bash
25
+ pip install glpkg
26
+ ```
27
+
28
+ To check the installation and version, run:
29
+
30
+ ```bash
31
+ glpkg --version
32
+ ```
33
+
34
+ If you see a version in the terminal, you're good to go!
35
+
36
+ ## Usage
37
+
38
+ When in doubt
39
+
40
+ ```bash
41
+ glpkg --help
42
+ ```
43
+
44
+ might help
45
+
46
+ By default, the used GitLab host is gitlab.com. If you use a self-hosted GitLab, use argument `--host my-gitlab.net` with the commands.
47
+
48
+ > Only https scheme is supported.
49
+
50
+ To authenticate with the package registry in any of the commands below, use `--token readapitoken123` argument where the `readapitoken123` is a [personal](https://docs.gitlab.com/user/profile/personal_access_tokens/#create-a-personal-access-token) or [project](https://docs.gitlab.com/user/project/settings/project_access_tokens/#create-a-project-access-token) access token, with read API scope. In case the package registry is public, you can omit this argument.
51
+
52
+ Alternatively you can use a token stored in your `.netrc` file by setting `--netrc` argument.
53
+
54
+ > If you use the tool in GitLab CI, read [below](#Use-in-GitLab-pipelines) on how to use the `CI_JOB_TOKEN`.
55
+
56
+ The arguments related to the GitLab host or authentication (`--token`, `--netrc`, and `--ci`) are omitted in the examples below to focus on the commands.
57
+
58
+ In general, run `glpkg --help` when needed.
59
+
60
+ ### Listing package versions
61
+
62
+ To list the versions of a generic package, run
63
+
64
+ ```bash
65
+ glpkg list --project 12345 --name mypackagename
66
+ ```
67
+
68
+ Where:
69
+ - `12345` is your projects ID ([Find the Project ID](https://docs.gitlab.com/user/project/working_with_projects/#find-the-project-id)) or the path of the project (like `namespace/project`)
70
+ - `mypackagename` is the name of the generic package
71
+
72
+ The output will be, if package is found, something like:
73
+
74
+ ```bash
75
+ Name Version
76
+ mypackagename 1.0
77
+ mypackagename 1.5
78
+ mypackagename 2.0
79
+ ```
80
+
81
+ ### Download generic package
82
+
83
+ To download all files from a specific version of a generic package, run
84
+
85
+ ```bash
86
+ glpkg download --project 12345 --name mypackagename --version 1.0
87
+ ```
88
+
89
+ Where:
90
+ - `12345` is your projects ID ([Find the Project ID](https://docs.gitlab.com/user/project/working_with_projects/#find-the-project-id)) or the path of the project (like `namespace/project`)
91
+ - `mypackagename` is the name of the generic package
92
+ - `1.0` is the version of the generic package from which the files are downloaded
93
+
94
+ By default the files will be downloaded in the current working directory. To download the files to another directory, add argument `--destination` to the command. In all cases, as long as you have permissions to the destination directory, any pre-existing files will be overridden without warning.
95
+
96
+ To download only a specific file from the package, add `--file` argument.
97
+
98
+ ```bash
99
+ glpkg download --project 12345 --name mypackagename --version 1.5 --file the_only_one --destination /temp
100
+ ```
101
+
102
+ > If a package has multiple files with the same filename, the tool can only download the newest file. This is a restriction of GitLab API.
103
+
104
+ ### Upload a file to a generic package
105
+
106
+ To upload a file to a version of a generic package, run
107
+
108
+ ```bash
109
+ glpkg upload --project 12345 --name mypackagename --version 1.0 --file my-file.txt
110
+ ```
111
+
112
+ Where:
113
+ - `12345` is your projects ID ([Find the Project ID](https://docs.gitlab.com/user/project/working_with_projects/#find-the-project-id)) or the path of the project (like `namespace/project`)
114
+ - `mypackagename` is the name of the generic package
115
+ - `1.0` is the version of the generic package to which the file is uploaded
116
+ - `my-file.txt` is the file that is uploaded to the generic package. Only relative paths are supported, and the relative path (e.g. `folder/file.txt`) is preserved when uploading the file to the package.
117
+
118
+ > A GitLab generic package may have multiple files with the same file name. However, it likely is not a great idea, as they cannot be downloaded separately from the GitLab API.
119
+
120
+ To upload multiple files, or to upload a single file from a different directory, use `--source` argument. If no `--file` argument is set, all of the files in the source directory are uploaded, recursively. As an example, to upload all files from a `upload` folder to the package:
121
+
122
+ ```bash
123
+ glpkg upload --project 12345 --name mypackagename --version 1.0 --source upload
124
+ ```
125
+
126
+ Note: a file in `upload` folder will be uploaded to the root of the package. If you want to upload the file to a `dir` folder in the package, make a structure in the upload folder, like `upload/dir/`.
127
+
128
+ ### Delete a file from a generic package
129
+
130
+ To delete a file from a specific generic package, run
131
+
132
+ ```bash
133
+ glpkg delete --project 12345 --name mypackagename --version 1.0 --file my-file.txt
134
+ ```
135
+
136
+ Where
137
+ - `12345` is your projects ID ([Find the Project ID](https://docs.gitlab.com/user/project/working_with_projects/#find-the-project-id)) or the path of the project (like `namespace/project`)
138
+ - `mypackagename` is the name of the generic package
139
+ - `1.0` is the version of the generic package from the file is deleted
140
+ - `my-file.txt` is the file that is deleted. Only relative paths are supported. Note that the package may contain multiple files with same name. In this case, one file of them is deleted.
141
+
142
+ The token that is used to delete files must have at least Maintainer role in the project.
143
+
144
+ ### Delete a package version
145
+
146
+ To delete a specific generic package version, run
147
+
148
+ ```bash
149
+ glpkg delete --project 12345 --name mypackagename --version 1.0
150
+ ```
151
+
152
+ Where
153
+ - `12345` is your projects ID ([Find the Project ID](https://docs.gitlab.com/user/project/working_with_projects/#find-the-project-id)) or the path of the project (like `namespace/project`)
154
+ - `mypackagename` is the name of the generic package
155
+ - `1.0` is the version of the generic package that is deleted
156
+
157
+ The token that is used to delete packages must have at least Maintainer role in the project.
158
+
159
+ ### Use in GitLab pipelines
160
+
161
+ If you use the tool in a GitLab pipeline, setting argument `--ci` uses [GitLab predefined variables](https://docs.gitlab.com/ci/variables/predefined_variables/) to configure the tool. In this case `CI_SERVER_HOST`, `CI_PROJECT_ID`, and `CI_JOB_TOKEN` environment variables are used. The `--project`, and `--token` arguments can still be used to override the project ID or to use a personal or project access token instead of `CI_JOB_TOKEN`.
162
+
163
+ In other words, you don't need to give the `--host`, `--project`, or `--token` arguments if you are interacting with the package registry of the project where the pipeline is running. Example: uploading `my-file.txt` to generic package `mypackagename` version `1.0` in the project package registry in CI:
164
+
165
+ ```bash
166
+ glpkg upload --ci --name mypackagename --version 1.0 --file my-file.txt
167
+ ```
168
+
169
+ To use the `CI_JOB_TOKEN` with package registry of another projects, add `--project <otherproject ID>` argument. Remember that you may need to add [permissions for the CI_JOB_TOKEN](https://docs.gitlab.com/ci/jobs/ci_job_token/#control-job-token-access-to-your-project) in the other project.
glpkg-1.4.2/README.md ADDED
@@ -0,0 +1,156 @@
1
+ # glpkg - GitLab Generic Package tools
2
+
3
+ glpkg is a tool that makes it easy to work with [GitLab generic packages](https://docs.gitlab.com/user/packages/generic_packages/).
4
+
5
+ Generic package registries of GitLab projects are supported. Group registries are not, as the GitLab REST API for groups is very limited.
6
+
7
+ ## Installation
8
+
9
+ Install the tool from with pip:
10
+
11
+ ```bash
12
+ pip install glpkg
13
+ ```
14
+
15
+ To check the installation and version, run:
16
+
17
+ ```bash
18
+ glpkg --version
19
+ ```
20
+
21
+ If you see a version in the terminal, you're good to go!
22
+
23
+ ## Usage
24
+
25
+ When in doubt
26
+
27
+ ```bash
28
+ glpkg --help
29
+ ```
30
+
31
+ might help
32
+
33
+ By default, the used GitLab host is gitlab.com. If you use a self-hosted GitLab, use argument `--host my-gitlab.net` with the commands.
34
+
35
+ > Only https scheme is supported.
36
+
37
+ To authenticate with the package registry in any of the commands below, use `--token readapitoken123` argument where the `readapitoken123` is a [personal](https://docs.gitlab.com/user/profile/personal_access_tokens/#create-a-personal-access-token) or [project](https://docs.gitlab.com/user/project/settings/project_access_tokens/#create-a-project-access-token) access token, with read API scope. In case the package registry is public, you can omit this argument.
38
+
39
+ Alternatively you can use a token stored in your `.netrc` file by setting `--netrc` argument.
40
+
41
+ > If you use the tool in GitLab CI, read [below](#Use-in-GitLab-pipelines) on how to use the `CI_JOB_TOKEN`.
42
+
43
+ The arguments related to the GitLab host or authentication (`--token`, `--netrc`, and `--ci`) are omitted in the examples below to focus on the commands.
44
+
45
+ In general, run `glpkg --help` when needed.
46
+
47
+ ### Listing package versions
48
+
49
+ To list the versions of a generic package, run
50
+
51
+ ```bash
52
+ glpkg list --project 12345 --name mypackagename
53
+ ```
54
+
55
+ Where:
56
+ - `12345` is your projects ID ([Find the Project ID](https://docs.gitlab.com/user/project/working_with_projects/#find-the-project-id)) or the path of the project (like `namespace/project`)
57
+ - `mypackagename` is the name of the generic package
58
+
59
+ The output will be, if package is found, something like:
60
+
61
+ ```bash
62
+ Name Version
63
+ mypackagename 1.0
64
+ mypackagename 1.5
65
+ mypackagename 2.0
66
+ ```
67
+
68
+ ### Download generic package
69
+
70
+ To download all files from a specific version of a generic package, run
71
+
72
+ ```bash
73
+ glpkg download --project 12345 --name mypackagename --version 1.0
74
+ ```
75
+
76
+ Where:
77
+ - `12345` is your projects ID ([Find the Project ID](https://docs.gitlab.com/user/project/working_with_projects/#find-the-project-id)) or the path of the project (like `namespace/project`)
78
+ - `mypackagename` is the name of the generic package
79
+ - `1.0` is the version of the generic package from which the files are downloaded
80
+
81
+ By default the files will be downloaded in the current working directory. To download the files to another directory, add argument `--destination` to the command. In all cases, as long as you have permissions to the destination directory, any pre-existing files will be overridden without warning.
82
+
83
+ To download only a specific file from the package, add `--file` argument.
84
+
85
+ ```bash
86
+ glpkg download --project 12345 --name mypackagename --version 1.5 --file the_only_one --destination /temp
87
+ ```
88
+
89
+ > If a package has multiple files with the same filename, the tool can only download the newest file. This is a restriction of GitLab API.
90
+
91
+ ### Upload a file to a generic package
92
+
93
+ To upload a file to a version of a generic package, run
94
+
95
+ ```bash
96
+ glpkg upload --project 12345 --name mypackagename --version 1.0 --file my-file.txt
97
+ ```
98
+
99
+ Where:
100
+ - `12345` is your projects ID ([Find the Project ID](https://docs.gitlab.com/user/project/working_with_projects/#find-the-project-id)) or the path of the project (like `namespace/project`)
101
+ - `mypackagename` is the name of the generic package
102
+ - `1.0` is the version of the generic package to which the file is uploaded
103
+ - `my-file.txt` is the file that is uploaded to the generic package. Only relative paths are supported, and the relative path (e.g. `folder/file.txt`) is preserved when uploading the file to the package.
104
+
105
+ > A GitLab generic package may have multiple files with the same file name. However, it likely is not a great idea, as they cannot be downloaded separately from the GitLab API.
106
+
107
+ To upload multiple files, or to upload a single file from a different directory, use `--source` argument. If no `--file` argument is set, all of the files in the source directory are uploaded, recursively. As an example, to upload all files from a `upload` folder to the package:
108
+
109
+ ```bash
110
+ glpkg upload --project 12345 --name mypackagename --version 1.0 --source upload
111
+ ```
112
+
113
+ Note: a file in `upload` folder will be uploaded to the root of the package. If you want to upload the file to a `dir` folder in the package, make a structure in the upload folder, like `upload/dir/`.
114
+
115
+ ### Delete a file from a generic package
116
+
117
+ To delete a file from a specific generic package, run
118
+
119
+ ```bash
120
+ glpkg delete --project 12345 --name mypackagename --version 1.0 --file my-file.txt
121
+ ```
122
+
123
+ Where
124
+ - `12345` is your projects ID ([Find the Project ID](https://docs.gitlab.com/user/project/working_with_projects/#find-the-project-id)) or the path of the project (like `namespace/project`)
125
+ - `mypackagename` is the name of the generic package
126
+ - `1.0` is the version of the generic package from the file is deleted
127
+ - `my-file.txt` is the file that is deleted. Only relative paths are supported. Note that the package may contain multiple files with same name. In this case, one file of them is deleted.
128
+
129
+ The token that is used to delete files must have at least Maintainer role in the project.
130
+
131
+ ### Delete a package version
132
+
133
+ To delete a specific generic package version, run
134
+
135
+ ```bash
136
+ glpkg delete --project 12345 --name mypackagename --version 1.0
137
+ ```
138
+
139
+ Where
140
+ - `12345` is your projects ID ([Find the Project ID](https://docs.gitlab.com/user/project/working_with_projects/#find-the-project-id)) or the path of the project (like `namespace/project`)
141
+ - `mypackagename` is the name of the generic package
142
+ - `1.0` is the version of the generic package that is deleted
143
+
144
+ The token that is used to delete packages must have at least Maintainer role in the project.
145
+
146
+ ### Use in GitLab pipelines
147
+
148
+ If you use the tool in a GitLab pipeline, setting argument `--ci` uses [GitLab predefined variables](https://docs.gitlab.com/ci/variables/predefined_variables/) to configure the tool. In this case `CI_SERVER_HOST`, `CI_PROJECT_ID`, and `CI_JOB_TOKEN` environment variables are used. The `--project`, and `--token` arguments can still be used to override the project ID or to use a personal or project access token instead of `CI_JOB_TOKEN`.
149
+
150
+ In other words, you don't need to give the `--host`, `--project`, or `--token` arguments if you are interacting with the package registry of the project where the pipeline is running. Example: uploading `my-file.txt` to generic package `mypackagename` version `1.0` in the project package registry in CI:
151
+
152
+ ```bash
153
+ glpkg upload --ci --name mypackagename --version 1.0 --file my-file.txt
154
+ ```
155
+
156
+ To use the `CI_JOB_TOKEN` with package registry of another projects, add `--project <otherproject ID>` argument. Remember that you may need to add [permissions for the CI_JOB_TOKEN](https://docs.gitlab.com/ci/jobs/ci_job_token/#control-job-token-access-to-your-project) in the other project.
@@ -0,0 +1,39 @@
1
+ [build-system]
2
+ requires = ["setuptools"]
3
+
4
+ [project]
5
+ name = "glpkg"
6
+ dynamic = ["version"]
7
+ description = "Tool to make GitLab generic package registry operations easy."
8
+ readme = "README.md"
9
+ keywords = ["GitLab", "packages", "registry", "generic"]
10
+ license = "MIT"
11
+ license-files = ["LICENSE.md"]
12
+ authors = [
13
+ { name="bugproduction", email="bugproduction@outlook.com" }
14
+ ]
15
+ requires-python = ">= 3.9"
16
+ dependencies = []
17
+
18
+ [project.urls]
19
+ Repository = "https://gitlab.com/bugproduction/glpkg.git"
20
+
21
+ [project.scripts]
22
+ glpkg = "gitlab.__main__:cli"
23
+
24
+
25
+ [tool.setuptools.dynamic]
26
+ version = {attr = "gitlab.__version__"}
27
+
28
+ [tool.setuptools.packages.find]
29
+ where = ["src"]
30
+
31
+ [tool.pytest.ini_options]
32
+ pythonpath = ["src"]
33
+ addopts = "--cov=src --cov-report term"
34
+
35
+ [tool.pylint.'MESSAGES CONTROL']
36
+ min-public-methods = 1
37
+ max-args = 6
38
+ max-positional-arguments = 6
39
+ ignore = ["build", "test"]
glpkg-1.4.2/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,5 @@
1
+ """GitLab packages initialization module"""
2
+
3
+ from gitlab.packages import Packages
4
+
5
+ __version__ = "1.4.2"
@@ -0,0 +1,24 @@
1
+ """GitLab packages main module"""
2
+
3
+ import sys
4
+
5
+ from gitlab.cli_handler import CLIHandler
6
+
7
+
8
+ def cli() -> int:
9
+ """
10
+ Runs the main program of the glpkg.
11
+
12
+ Uses arguments from command line and executes the given command.
13
+
14
+ Return
15
+ ------
16
+ int
17
+ Zero when everything is fine, non-zero otherwise.
18
+ """
19
+ handler = CLIHandler()
20
+ return handler.do_it()
21
+
22
+
23
+ if __name__ == "__main__":
24
+ sys.exit(cli())