Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Commit

Permalink
Fix python building (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
clburlison authored Feb 23, 2018
1 parent 067d95c commit 391ce97
Show file tree
Hide file tree
Showing 32 changed files with 266 additions and 417 deletions.
89 changes: 19 additions & 70 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,29 @@
version: 2
jobs:
build:
working_directory: /tmp/vendored
docker:
- image: nathanleclaire/curl:latest
steps:
- deploy:
name: Run lint job
command: |
set -x
# Only run if on the CircleCI cloud instance
if [ "$CIRCLE_BUILD_NUM" ]; then
# Gross method to have Circle trigger the job
# https://circleci.com/docs/2.0/defining-multiple-jobs/#triggering-jobs
curl -u ${CIRCLE_API_TOKEN}: \
-d build_parameters[CIRCLE_JOB]=lint \
-d revision=$CIRCLE_SHA1 \
https://circleci.com/api/v1.1/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/tree/$CIRCLE_BRANCH
fi
- deploy:
name: Run spell check job
command: |
set -x
# Only run if on the CircleCI cloud instance
if [ "$CIRCLE_BUILD_NUM" ]; then
# Gross method to have Circle trigger the job
# https://circleci.com/docs/2.0/defining-multiple-jobs/#triggering-jobs
curl -u ${CIRCLE_API_TOKEN}: \
-d build_parameters[CIRCLE_JOB]=spell-check \
-d revision=$CIRCLE_SHA1 \
https://circleci.com/api/v1.1/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/tree/$CIRCLE_BRANCH
fi
lint:
working_directory: /tmp/vendored
docker:
- image: clburlison/pylint:py2-wheezy
steps:
- checkout
- run:
name: Run tests
command: |
set -x
# Only run lint tests if a python file changed
changed_files="$(git --no-pager diff --name-only origin/master)"
if [[ $changed_files =~ .py ]]; then
echo "A python file was modified. Running python linter..."
flake8 --exclude=_src*,_patch*,payload,build .
fi
spell-check:
working_directory: /tmp/vendored
docker:
- image: clburlison/pylint:py2-wheezy
- image: circleci/python:2.7-jessie
working_directory: ~/repo
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum ".circleci/requirements.txt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: Run spell check
name: install dependencies
command: |
set -x
#set +e # Add this to override spelling errors failing CI tests.
# Then add an `exit 0` at the end of the run
pylint --disable=all --reports=n --enable=spelling \
--spelling-dict=en_US --ignore-comments=no \
--spelling-private-dict-file=tests/words \
build.py build openssl python tests tlsssl vendir
add-words:
working_directory: /tmp/vendored
docker:
- image: clburlison/pylint:py2-wheezy
steps:
- checkout
virtualenv venv
. venv/bin/activate
pip install -r .circleci/requirements.txt
- save_cache:
paths:
- ./venv
key: v1-dependencies-{{ checksum ".circleci/requirements.txt" }}
- run:
name: Add unknown words to 'tests/words'
name: run linting
command: |
set -x
pylint --disable=all --reports=n --enable=spelling \
--spelling-dict=en_US --ignore-comments=no \
--spelling-store-unknown-words=y \
--spelling-private-dict-file=tests/words \
build.py build openssl python tests tlsssl vendir
. venv/bin/activate
flake8
2 changes: 2 additions & 0 deletions .circleci/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
flake8==3.5.0
flake8_docstrings==1.3.0
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
# ignore = F401,F405,E402,F403
# max-line-length = 100
exclude = venv/*, code/tlsssl/_diffs/*, code/tlsssl/build/*, code/tlsssl/_patch/*, code/tlsssl/_src/*, code/tlsssl/payload/*
42 changes: 12 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,23 @@

The goal of this repo is to make it easy to "vendor" your own frameworks and programming languages in an automated fashion.

Once this project is complete you will be able to have own version of python, ruby, pyojbc bridge, OpenSSL, and more all in one nice big package or multiple smaller packages for easy deployment.
Once this project is complete you will be able to have own version of python with custom pip modules included, ruby, OpenSSL, and more all in one nice big package or multiple smaller packages for easy deployment.

To keep track of progress look at the [Master list](https://github.com/clburlison/vendored/issues/1)

# Usage

Currently parts of this project are working. You can run `./build.py` to build and optionally package some of these pieces. Or `cd` into one of the subfolders and run `python setup.py` directly (the help is quite 'helpful'). This will give you the most control at this point until the build script matures and has more arguments added.
Currently parts of this project are working. Make sure you `cd code`. You can run `sudo ./build.py` to build and optionally package some of these pieces. Or `cd` into one of the sub-folders and run `sudo python setup.py` directly (the help is quite 'helpful'). This will give you the most control at this point until the build script matures and has more arguments added.

It is recommended that you build this project in a clean environnement IE - a virtual machine. That will give you the best results and make sure your packages are clean.

## Requires:

### Requires:
* Apple Command Line Tools (installable with `xcode-select --install`)
* Python 2

### Override
## Override

vendored was created to be customizable. As such, it is possible to override almost every option. These overrides live in the `config.ini` file.

The `config.ini` file contains two sections:
Expand All @@ -31,14 +35,8 @@ A sample is shown below:
pkgid: com.clburlison
sign_cert_cn: Developer ID Installer: Clayton Burlison

## Creating a patch
Some of these tools require patch files for compiling. If you're unfamiliar with creating a patch file the basics look a little something like:

```bash
diff -u hello.c hello_new.c > hello.c.patch
```

# Working with the CI
## Working with the CI
CircleCI is set to run tests on this repo. Coding should follow the [PEP 8](https://www.python.org/dev/peps/pep-0008/) style guide and is verified with [`flake8`](https://pypi.python.org/pypi/flake8). While correct spellings for code is verified with enchant using the python-enchant module.

To run the CI tests locally the following tools must be installed:
Expand All @@ -52,27 +50,11 @@ To run the CI tests locally the following tools must be installed:
To run the lint job:

```bash
circleci build --job lint
circleci build
```

## Spelling CI
As with all projects some words that are used will not be part of the standard 'en_US' dictionary and are added to a custom file located in `tests/words`.

To run the spell-check job:

```bash
circleci build --job spell-check
```

To run the add-words job:

_Note:_ This will add new words to 'tests/words' so please run `spell-check` first

```bash
circleci build --job add-words
```
## Credits

# Credits
Huge thanks to...
* the [Google MacOps](https://github.com/google/macops/) team for open sourcing their solution
* [@pudquick](https://github.com/pudquick) for his work on tlsssl so we can patch the native Python 2.7 that ships on macOS
Expand All @@ -87,6 +69,6 @@ This project uses works from:
[EmojiOne](http://emojione.com/) | [briefcase](https://github.com/Ranks/emojione/blob/master/assets/png_512x512/1f4bc.png?raw=true)
[Ignace Mouzannar](http://ghantoos.org/) | [CI python spell checks post](http://ghantoos.org/2016/02/21/continuous-integration-python-comments-spellchecks-with-pylint-pyenchant-and-tox/)

# License
## License

This project uses the MIT License.
12 changes: 6 additions & 6 deletions build.py → code/build.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/usr/bin/python
"""
build.py - main program for vendored
"""
"""Build vendored packages."""

import os

from vendir import root

CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))


def build_openssl(*args):
"""Build the openssl project."""
openssl_dir = os.path.join(CURRENT_DIR, 'openssl')
os.chdir(openssl_dir)
cmd = ['/usr/bin/python', 'setup.py', '-vv', '-p', '-b', '-s']
cmd = ['/usr/bin/python', 'setup.py', '-vv', '-p', '-b', '-i']
os.system(' '.join(cmd))


Expand All @@ -33,10 +33,10 @@ def build_tlsssl():


def main():
"""Main routine"""
"""Build our required packages."""
root.root_check()
build_openssl()
build_python()
build_tlsssl()


if __name__ == '__main__':
Expand Down
20 changes: 12 additions & 8 deletions build/distribution.plist → code/build/distribution.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,22 @@
<line choice="com.clburlison.python"/>
<line choice="com.clburlison.tlsssl"/>
</choices-outline>
<choice id="default"/>
<choice id="com.clburlison.openssl" visible="true" selected="true" title="OpenSSL 1.0.2k">
<!-- START: OpenSSL -->
<pkg-ref id="com.clburlison.openssl" version="1.0.2n" onConclusion="none">openssl-1.0.2n.pkg</pkg-ref>
<choice id="com.clburlison.openssl" visible="true" start_selected="true" title="OpenSSL 1.0.2n">
<pkg-ref id="com.clburlison.openssl"/>
</choice>
<pkg-ref id="com.clburlison.openssl" version="1.0.2k" onConclusion="none">openssl-1.0.2k.pkg</pkg-ref>
<choice id="com.clburlison.python" visible="true" start_selected="false" title="Python 2.7.13">
<!-- END: OpenSSL -->
<!-- START: Python2 -->
<pkg-ref id="com.clburlison.python" version="2.7.14" onConclusion="none">python-2.7.14.pkg</pkg-ref>
<choice id="com.clburlison.python" visible="true" start_selected="true" title="Python 2.7.14">
<pkg-ref id="com.clburlison.python"/>
</choice>
<pkg-ref id="com.clburlison.python" version="2.7.13" onConclusion="none">python-2.7.13.pkg</pkg-ref>
<choice id="com.clburlison.tlsssl" visible="true" title="tlsssl module">
<!-- END: Python2 -->
<!-- START: tlsssl module -->
<pkg-ref id="com.clburlison.tlsssl" version="1.1.0" onConclusion="none">tlsssl-1.1.0.pkg</pkg-ref>
<choice id="com.clburlison.tlsssl" visible="true" start_selected="false" title="tlsssl module">
<pkg-ref id="com.clburlison.tlsssl"/>
</choice>
<pkg-ref id="com.clburlison.tlsssl" version="1.0.0" onConclusion="none">tlsssl-1.0.0.pkg</pkg-ref>
<pkg-ref id="com.clburlison.tlsssl" version="1.0.0" onConclusion="none">tlsssl-1.1.0.pkg</pkg-ref>
<!-- END: tlsssl module -->
</installer-gui-script>
File renamed without changes
File renamed without changes.
6 changes: 3 additions & 3 deletions build/temp_build.sh → code/build/temp_build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
# /usr/bin/productbuild --synthesize \
# --package ../openssl/openssl-1.0.2k.pkg \
# --package ../python/python-2.7.13.pkg \
# --package ../tlsssl/tlsssl-1.0.0.pkg \
# --package ../openssl/openssl-1.0.2n.pkg \
# --package ../python/python-2.7.14.pkg \
# --package ../tlsssl/tlsssl-1.1.0.pkg \
# distribution.plist


Expand Down
17 changes: 7 additions & 10 deletions config.ini → code/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,17 @@ pth_fname: 000vendored.pth
# the temporary build directory for openssl. Can be relative or absolute file paths
openssl_build_dir: /tmp/build-openssl
# the url path for openssl distribution, hash & version
openssl_dist: https://www.openssl.org/source/openssl-1.0.2k.tar.gz
openssl_dist_hash: 6b3977c61f2aedf0f96367dcfb5c6e578cf37e7b8d913b4ecb6643c3cb88d8c0
openssl_version: 1.0.2k
openssl_dist: https://www.openssl.org/source/openssl-1.0.2n.tar.gz
openssl_dist_hash: 370babb75f278c39e0c50e8c4e7493bc0f18db6867478341a832a982fd15a8fe
openssl_version: 1.0.2n

############## python variables ##############
# the temporary build directory for openssl. Can be relative or absolute file paths
# the temporary build directory for python. Can be relative or absolute file paths
python_build_dir: /tmp/build-python
# the url path for python2 distribution, hash & version
python2_dist: https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tar.xz
python2_dist_hash: 35d543986882f78261f97787fd3e06274bfa6df29fac9b4a94f73930ff98f731
python2_version: 2.7.13
# the specific version of PyOjbC that you want pip to install. The latest can
# be found at https://pypi.python.org/pypi/pyobjc
python2_objc_version: 3.2.1
python2_dist: https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tar.xz
python2_dist_hash: 71ffb26e09e78650e424929b2b457b9c912ac216576e6bd9e7d204ed03296a66
python2_version: 2.7.14

############## tlsssl variables ##############
# The install directory that tlsssl will be installed into
Expand Down
Loading

0 comments on commit 391ce97

Please sign in to comment.