Skip to content

Commit 2bf42d9

Browse files
GitHub actions (#73)
1 parent 1e41122 commit 2bf42d9

File tree

15 files changed

+170
-231
lines changed

15 files changed

+170
-231
lines changed

.github/workflows/main.yml

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: ci
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
name: build ${{ matrix.os }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
13+
os: ["ubuntu-18.04", "macos-10.15", "windows-2019"]
14+
python-version: ["3.7"]
15+
steps:
16+
- uses: actions/checkout@v2
17+
# run vcvars on windows
18+
- uses: ilammy/msvc-dev-cmd@v1
19+
20+
# warning: if something is changed so that the cached dependencies are not correct
21+
# this cache will not notice and the build will be slow, to fix this, increment the
22+
# version in the key
23+
- name: Cache Dependencies
24+
id: cache-dependencies
25+
uses: actions/cache@v2
26+
with:
27+
path: cache
28+
key: ${{ runner.os }}-dependencies-v7
29+
30+
- name: Set up Python
31+
uses: actions/setup-python@v2
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
architecture: x64
35+
36+
- name: Install Procgen Build
37+
run: python -m pip install -e procgen-build
38+
39+
- name: Build
40+
run: python -u -m procgen_build.build_package
41+
42+
- name: Upload wheel artifact
43+
uses: actions/upload-artifact@v2
44+
with:
45+
name: wheels
46+
path: wheelhouse/*
47+
48+
# - name: Publish distribution 📦 to Test PyPI
49+
# uses: pypa/gh-action-pypi-publish@master
50+
# with:
51+
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
52+
# repository_url: https://test.pypi.org/legacy/
53+
54+
# - name: Publish distribution 📦 to PyPI
55+
# if: startsWith(github.ref, 'refs/tags')
56+
# uses: pypa/gh-action-pypi-publish@master
57+
# with:
58+
# password: ${{ secrets.PYPI_API_TOKEN }}
59+
60+
dev:
61+
name: dev ${{ matrix.os }}
62+
runs-on: ${{ matrix.os }}
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
67+
os: ["ubuntu-18.04", "macos-10.15", "windows-2019"]
68+
python-version: ["3.7"]
69+
steps:
70+
- uses: actions/checkout@v2
71+
# run vcvars on windows
72+
- uses: ilammy/msvc-dev-cmd@v1
73+
74+
- name: Set up Python
75+
uses: actions/setup-python@v2
76+
with:
77+
python-version: ${{ matrix.python-version }}
78+
architecture: x64
79+
80+
- name: Install Procgen Build
81+
run: python -m pip install -e procgen-build
82+
83+
- name: Test
84+
run: python -u -m procgen_build.dev_test

.travis.yml

-72
This file was deleted.

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ Supported platforms:
2626

2727
Supported Pythons:
2828

29-
- 3.6 64-bit
3029
- 3.7 64-bit
3130
- 3.8 64-bit
31+
- 3.9 64-bit
32+
- 3.10 64-bit
3233

3334
Supported CPUs:
3435

@@ -40,7 +41,7 @@ First make sure you have a supported version of python:
4041

4142
```
4243
# run these commands to check for the correct python version
43-
python -c "import sys; assert (3,6,0) <= sys.version_info <= (3,9,0), 'python is incorrect version'; print('ok')"
44+
python -c "import sys; assert (3,7,0) <= sys.version_info <= (3,10,0), 'python is incorrect version'; print('ok')"
4445
python -c "import platform; assert platform.architecture()[0] == '64bit', 'python is not 64-bit'; print('ok')"
4546
```
4647

@@ -183,7 +184,7 @@ This returns a list of byte strings representing the state of each game in the v
183184

184185
# Install from Source
185186

186-
If you want to change the environments or create new ones, you should build from source. You can get miniconda from https://docs.conda.io/en/latest/miniconda.html if you don't have it, or install the dependencies from [`environment.yml`](environment.yml) manually. On Windows you will also need "Visual Studio 15 2017" installed.
187+
If you want to change the environments or create new ones, you should build from source. You can get miniconda from https://docs.conda.io/en/latest/miniconda.html if you don't have it, or install the dependencies from [`environment.yml`](environment.yml) manually. On Windows you will also need "Visual Studio 16 2019" installed.
187188

188189
```
189190
git clone [email protected]:openai/procgen.git

environment.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ channels:
44
dependencies:
55
- python=3.7.3
66
# https://www.anaconda.com/utilizing-the-new-compilers-in-anaconda-distribution-5/
7-
- c-compiler=1.0.4
8-
- cmake=3.14.0
7+
- c-compiler=1.3.0
8+
- cmake=3.21.3
99
- qt=5.12.5 # conda-forge does not have 5.13.2 available
1010
- pip
1111
- pip:
+12-94
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,19 @@
11
import platform
2-
from urllib.request import urlretrieve
32
import os
4-
import subprocess as sp
5-
import fnmatch
63

7-
import blobfile as bf
8-
9-
from .common import run, GCS_BUCKET
4+
from .common import run
105

116

127
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
138

149

15-
# https://stackoverflow.com/a/50135504
16-
def init_vsvars():
17-
print("Initializing environment for Visual Studio")
18-
19-
vcvars_path = "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Auxiliary/Build/vcvars64.bat"
20-
21-
env_bat_file_path = "setup_build_environment_temp.bat"
22-
env_txt_file_path = "build_environment_temp.txt"
23-
with open(env_bat_file_path, "w") as env_bat_file:
24-
env_bat_file.write('call "%s"\n' % vcvars_path)
25-
env_bat_file.write("set > %s\n" % env_txt_file_path)
26-
27-
os.system(env_bat_file_path)
28-
with open(env_txt_file_path, "r") as env_txt_file:
29-
lines = env_txt_file.read().splitlines()
30-
31-
os.remove(env_bat_file_path)
32-
os.remove(env_txt_file_path)
33-
for line in lines:
34-
if "=" not in line:
35-
print(f"invalid line {repr(line)}")
36-
continue
37-
k, v = line.split("=", 1)
38-
os.environ[k] = v
39-
40-
41-
def get_var(pattern):
42-
for key, value in os.environ:
43-
if fnmatch.fnmatch(key, pattern):
44-
return os.environ[key]
45-
return None
46-
47-
48-
def setup_google_credentials():
49-
# brew install travis
50-
# travis login --org
51-
# gcloud iam service-accounts create procgen-travis-ci --project <project>
52-
# gcloud iam service-accounts keys create /tmp/key.json --iam-account procgen-travis-ci@<project>.iam.gserviceaccount.com
53-
# gsutil iam ch serviceAccount:procgen-travis-ci@<project>.iam.gserviceaccount.com:objectAdmin gs://{GCS_BUCKET}
54-
# travis encrypt-file --org /tmp/key.json
55-
input_path = os.path.join(SCRIPT_DIR, "key.json.enc")
56-
output_path = os.path.join(os.getcwd(), "key.json")
57-
for h in ["d853b3b05b79", "41b34d34b52c"]:
58-
key = os.environ.get(f"encrypted_{h}_key")
59-
iv = os.environ.get(f"encrypted_{h}_iv")
60-
if key is not None:
61-
break
62-
if key is None:
63-
# being compiled on a fork
64-
return False
65-
sp.run(["openssl", "aes-256-cbc", "-K", key, "-iv", iv, "-in", input_path, "-out", output_path, "-d"], check=True)
66-
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = output_path
67-
return True
68-
69-
7010
def main():
71-
have_credentials = setup_google_credentials()
72-
7311
os.environ.update(
7412
{
75-
"CIBW_BUILD": "cp36-macosx_x86_64 cp37-macosx_x86_64 cp38-macosx_x86_64 cp36-manylinux_x86_64 cp37-manylinux_x86_64 cp38-manylinux_x86_64 cp36-win_amd64 cp37-win_amd64 cp38-win_amd64",
76-
"CIBW_BEFORE_BUILD": "pip install -e procgen-build && python -u -m procgen_build.build_qt --output-dir /tmp/qt5",
13+
"CIBW_BUILD": "cp37-macosx_x86_64 cp38-macosx_x86_64 cp39-macosx_x86_64 cp310-macosx_x86_64 cp37-manylinux_x86_64 cp38-manylinux_x86_64 cp39-manylinux_x86_64 cp310-manylinux_x86_64 cp37-win_amd64 cp38-win_amd64 cp39-win_amd64 cp310-win_amd64",
14+
"CIBW_BEFORE_BUILD": "pip install -r procgen-build/requirements.txt && pip install -e procgen-build && python -u -m procgen_build.build_qt --output-dir /tmp/qt5",
7715
"CIBW_TEST_EXTRAS": "test",
16+
"CIBW_BEFORE_TEST": "pip install -r procgen-build/requirements.txt",
7817
# the --pyargs option causes pytest to use the installed procgen wheel
7918
"CIBW_TEST_COMMAND": "pytest --verbose --benchmark-disable --durations=16 --pyargs procgen",
8019
# this is where build-qt.py will put the files
@@ -83,44 +22,23 @@ def main():
8322
# "CIBW_BUILD_VERBOSITY": "3",
8423
}
8524
)
86-
if platform.system() == "Darwin":
87-
# cibuildwheel's python copy on mac os x sometimes fails with this error:
88-
# [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)
89-
urlretrieve(
90-
"https://curl.haxx.se/ca/cacert.pem",
91-
os.environ["TRAVIS_BUILD_DIR"] + "/cacert.pem",
92-
)
93-
os.environ["SSL_CERT_FILE"] = os.environ["TRAVIS_BUILD_DIR"] + "/cacert.pem"
94-
elif platform.system() == "Linux":
95-
# since we're inside a docker container, adjust the credentials path to point at the mounted location
96-
if have_credentials:
97-
os.environ["CIBW_ENVIRONMENT"] = (
98-
os.environ["CIBW_ENVIRONMENT"]
99-
+ " GOOGLE_APPLICATION_CREDENTIALS=/host"
100-
+ os.environ["GOOGLE_APPLICATION_CREDENTIALS"]
101-
)
25+
if platform.system() == "Linux":
10226
if "TRAVIS_TAG" in os.environ:
10327
# pass TRAVIS_TAG to the container so that it can build wheels with the correct version number
10428
os.environ["CIBW_ENVIRONMENT"] = (
10529
os.environ["CIBW_ENVIRONMENT"]
10630
+ " TRAVIS_TAG=" + os.environ["TRAVIS_TAG"]
10731
)
108-
elif platform.system() == "Windows":
109-
init_vsvars()
32+
os.environ["CIBW_ENVIRONMENT"] = (
33+
os.environ["CIBW_ENVIRONMENT"]
34+
+ f" CACHE_DIR=/host{os.getcwd()}/cache"
35+
)
36+
else:
37+
os.environ["CACHE_DIR"] = os.path.join(os.getcwd(), "cache")
11038

111-
run("pip install cibuildwheel==1.4.1")
39+
run("pip install cibuildwheel==2.3.1")
11240
run("cibuildwheel --output-dir wheelhouse")
11341

114-
if have_credentials:
115-
print("upload wheels", platform.system())
116-
input_dir = "wheelhouse"
117-
output_dir = f"gs://{GCS_BUCKET}/builds/"
118-
for filename in bf.listdir(input_dir):
119-
src = bf.join(input_dir, filename)
120-
dst = bf.join(output_dir, filename)
121-
print(src, "=>", dst)
122-
bf.copy(src, dst, overwrite=True)
123-
12442

12543
if __name__ == "__main__":
12644
main()

0 commit comments

Comments
 (0)