Skip to content

Commit 263c9ca

Browse files
committed
Install pip requirements with --require-hashes and add requirements txt for all platforms
1 parent 6c9efa0 commit 263c9ca

36 files changed

Lines changed: 4844 additions & 377 deletions

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,4 @@ grr/var
2828
grr_server*.tar.gz
2929
LICENSE
3030
README.md
31-
travis
3231
vagrant

.github/workflows/build.yml

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,23 @@ jobs:
8787
- uses: actions/setup-python@v5
8888
with:
8989
python-version: '3.9'
90+
- name: Verify requirements
91+
run: |
92+
./travis/compile_requirements.sh ubuntu
93+
- name: Upload requirements to GitHub artifacts
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: ubuntu-requirements
97+
path: requirements/
98+
retention-days: 3
9099
- name: Set up
91100
run: |
92101
sudo apt install fakeroot debhelper libffi-dev libssl-dev
93102
pip install virtualenv
94103
virtualenv "${HOME}/INSTALL"
95104
- name: Build
96105
run: |
97-
travis/install_client_builder.sh
106+
travis/install_client_builder.sh ubuntu
98107
travis/build_templates.sh
99108
ls -la gcs_upload_dir
100109
- name: Upload installers to GitHub artifacts
@@ -115,9 +124,18 @@ jobs:
115124
run: |
116125
pip install --upgrade setuptools virtualenv
117126
virtualenv "${HOME}/INSTALL"
127+
- name: Verify requirements
128+
run: |
129+
./travis/compile_requirements.sh osx
130+
- name: Upload requirements to GitHub artifacts
131+
uses: actions/upload-artifact@v4
132+
with:
133+
name: osx-requirements
134+
path: requirements/
135+
retention-days: 3
118136
- name: Build installers
119137
run: |
120-
travis/install_client_builder.sh
138+
travis/install_client_builder.sh osx
121139
travis/build_templates.sh
122140
ls -la gcs_upload_dir
123141
- name: Upload installers to GitHub artifacts
@@ -136,6 +154,15 @@ jobs:
136154
DOCKER_USER: grrbot
137155
steps:
138156
- uses: actions/checkout@v4
157+
- name: Verify requirements
158+
run: |
159+
./travis/compile_requirements.sh centos
160+
- name: Upload requirements to GitHub artifacts
161+
uses: actions/upload-artifact@v4
162+
with:
163+
name: centos-requirements
164+
path: requirements/
165+
retention-days: 3
139166
- name: Build installers
140167
run: |
141168
docker run -dit \
@@ -150,7 +177,7 @@ jobs:
150177
# registered in the environment variables.
151178
docker exec "${DOCKER_CONTAINER}" bash -l travis/set_up_test_user.sh
152179
docker exec --user "${DOCKER_USER}" "${DOCKER_CONTAINER}" bash -l -c '/usr/local/bin/python3.9 -m venv "/home/${DOCKER_USER}/INSTALL"'
153-
docker exec --user "${DOCKER_USER}" "${DOCKER_CONTAINER}" bash -l travis/install_client_builder.sh
180+
docker exec --user "${DOCKER_USER}" "${DOCKER_CONTAINER}" bash -l travis/install_client_builder.sh centos
154181
docker exec --user "${DOCKER_USER}" "${DOCKER_CONTAINER}" bash -l travis/build_templates.sh
155182
docker exec "${DOCKER_CONTAINER}" rpm -vih gcs_upload_dir/*.rpm
156183
ls -la gcs_upload_dir
@@ -168,6 +195,15 @@ jobs:
168195
- uses: actions/setup-python@v5
169196
with:
170197
python-version: '3.9'
198+
- name: Verify requirements
199+
run: |
200+
.\travis\compile_requirements.bat
201+
- name: Upload requirements to GitHub artifacts
202+
uses: actions/upload-artifact@v4
203+
with:
204+
name: windows-requirements
205+
path: requirements/
206+
retention-days: 3
171207
- name: Build installers
172208
shell: bash
173209
run: |

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ ADD . ${GRR_SOURCE}
7878

7979
WORKDIR ${GRR_SOURCE}
8080

81-
RUN ${VIRTUAL_ENV}/bin/python -m pip install \
81+
RUN ${VIRTUAL_ENV}/bin/python -m pip install --require-hashes \
82+
-r travis/requirements/ubuntu.txt
83+
84+
RUN ${VIRTUAL_ENV}/bin/python -m pip install --no-deps --no-index \
8285
-e grr/proto \
8386
-e grr/core \
8487
-e grr/client \

api_client/python/requirements.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cryptography>=3.3.2
2+
requests>=2.25.1,<3
3+
Werkzeug>=2.1.2,<3
4+
# only required for shell
5+
ipython==7.15.0

api_client/python/setup.py

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env python
22
"""setup.py file for a GRR API client library."""
33

4+
from typing import List
5+
46
import configparser
57
import os
68
import shutil
@@ -41,43 +43,47 @@ def make_release_tree(self, base_dir, files):
4143
if os.path.exists(sdist_version_ini):
4244
os.unlink(sdist_version_ini)
4345
shutil.copy(
44-
os.path.join(THIS_DIRECTORY, "../../version.ini"), sdist_version_ini)
46+
os.path.join(THIS_DIRECTORY, "../../version.ini"), sdist_version_ini
47+
)
4548

4649

4750
VERSION = get_config()
4851

52+
53+
def parse_requirements(filename: str) -> List[str]:
54+
requirements = []
55+
with open(filename) as file:
56+
for line in file:
57+
requirement = line.strip()
58+
if (comment := requirement.find("#")) >= 0:
59+
requirement = requirement[:comment].strip()
60+
requirements.append(requirement)
61+
62+
return requirements
63+
64+
4965
setup_args = dict(
50-
name="grr-api-client",
51-
version=VERSION.get("Version", "packageversion"),
52-
description="GRR API client library",
53-
license="Apache License, Version 2.0",
54-
url="https://github.com/google/grr/tree/master/api_client/python",
55-
maintainer="GRR Development Team",
56-
maintainer_email="grr-dev@googlegroups.com",
57-
cmdclass={
58-
"sdist": Sdist,
59-
},
60-
packages=find_packages(),
61-
entry_points={
62-
"console_scripts": [
63-
"grr_api_shell = grr_api_client.api_shell:main",
64-
]
65-
},
66-
install_requires=[
67-
"grr_response_proto==%s" % VERSION.get("Version", "packagedepends"),
68-
# Note: grr-api-client might very much be used as a library and
69-
# therefore shouldn't pin dependencies that might be shared with other
70-
# pip packages.
71-
"cryptography>=3.3.2",
72-
"requests>=2.25.1,<3",
73-
"Werkzeug>=2.1.2,<3",
74-
],
75-
extra_requires={
76-
"shell": [
77-
"ipython==7.15.0",
78-
],
79-
},
80-
data=["version.ini"],
66+
name="grr-api-client",
67+
version=VERSION.get("Version", "packageversion"),
68+
description="GRR API client library",
69+
license="Apache License, Version 2.0",
70+
url="https://github.com/google/grr/tree/master/api_client/python",
71+
maintainer="GRR Development Team",
72+
maintainer_email="grr-dev@googlegroups.com",
73+
cmdclass={
74+
"sdist": Sdist,
75+
},
76+
packages=find_packages(),
77+
entry_points={
78+
"console_scripts": [
79+
"grr_api_shell = grr_api_client.api_shell:main",
80+
]
81+
},
82+
install_requires=[
83+
"grr_response_proto==%s" % VERSION.get("Version", "packagedepends"),
84+
]
85+
+ parse_requirements("requirements.in"),
86+
data=["version.ini", "requirements.in"],
8187
)
8288

8389
setup(**setup_args)

0 commit comments

Comments
 (0)