Skip to content

Commit

Permalink
Memray open source bootstrap
Browse files Browse the repository at this point in the history
This commit prepares tha package for its release as Open Source. The
commit squashes the history associated with internal development,
striping any sensitive information as well as removing references to
"Bloomberg" and Bloomberg-specific configuration files.

This commit also adds:

* GitHub specific CI files to use GitHub actions.
* LICENSE files.
* A vanilla DockerFile.
* A vendored, patched version of libbacktrace checked in the source.
* OS-friendly documentation
  • Loading branch information
pablogsal committed Apr 9, 2022
1 parent d4a9c9d commit 2c33838
Show file tree
Hide file tree
Showing 144 changed files with 96,447 additions and 89 deletions.
97 changes: 97 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
BasedOnStyle: LLVM
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: TopLevel
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: true
AfterControlStatement: MultiLine
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterStruct: true
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BreakStringLiterals: true
ColumnLimit: 105
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 0
ContinuationIndentWidth: 8
Cpp11BracedListStyle: true
DerivePointerAlignment: false
FixNamespaceComments: true
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IndentCaseLabels: true
IndentGotoLabels: false
IndentPPDirectives: AfterHash
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 8
UseTab: Never
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/---bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: "\U0001F41B Bug Report"
about: "If something isn't working as expected \U0001F914."
---

## Bug Report

**Current Behavior** A clear and concise description of the behavior.

**Input Code**

- REPL or Repo link if applicable:

```python
your_code = "here"
```

**Expected behavior/code** A clear and concise description of what you expected to happen (or
code).

**Environment**

- Python(s): [e.g. python3.8, python3.9, ...]

**Possible Solution**

<!--- Only if you have suggestions on a fix for the bug -->

**Additional context/Screenshots** Add any other context about the problem here. If applicable, add
screenshots to help explain.
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/---feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: "\U0001F680 Feature Request"
about: Suggest an idea for this project
---

## Feature Request

**Is your feature request related to a problem? Please describe.** A clear and concise description
of what the problem is. Ex. I have an issue when [...]

**Describe the solution you'd like** A clear and concise description of what you want to happen.
Add any considered drawbacks.

**Describe alternatives you've considered** A clear and concise description of any alternative
solutions or features you've considered.

**Teachability, Documentation, Adoption, Migration Strategy** If you can, explain how users will be
able to use this and possibly write out a version the docs. Maybe a screenshot or design?
81 changes: 81 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.9', '3.8']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set up dependencies
run: |
sudo apt-get update
sudo apt-get install -qy libunwind-dev pkg-config nodejs npm
- name: Install Python dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install tox tox-gh-actions
- name: Run tox
run: tox . -vvv

lint_and_docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Set up dependencies
run: |
sudo apt-get update
sudo apt-get install -qy clang-format nodejs npm libunwind-dev pkg-config
npm install -g prettier
- name: Install Python dependencies
run: |
python3 -m pip install -r requirements-extra.txt
- name: Install Package
run: |
python3 -m pip install -e .
- name: Lint sources
run: |
make lint
- name: Build docs
run: |
make docs
valgrind:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Set up dependencies
run: |
sudo apt-get update
sudo apt-get install -qy libunwind-dev pkg-config nodejs npm valgrind
- name: Install Python dependencies and package
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements-test.txt
python3 -m pip install -e .
- name: Run Valgrind
run: make valgrind
- name: Run Helgrind
run: make helgrind

68 changes: 68 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Contributing

Before contributing to this repository, first please discuss the change you wish to make via an
issue, or any other method of communication with the maintainers of this repository.

You can also search this project for issues with the following labels:

| Label | Search Term | Description |
| ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [good-first-issue](https://github.com/bloomberg/memray/search?q=is%3Aissue+is%3Aopen+label%3Agood-first-issue&type=Issues&utf8=%E2%9C%93) | `is:issue is:open label:good-first-issue` | Recommended for first-time contributors! These are well-defined, and allow a user to get familiar with the project's workflow before tackling more complex issues. |
| [help wanted](https://github.com/bloomberg/memray/search?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22+&type=Issues&utf8=%E2%9C%93) | `is:issue is:open label:"help wanted"` | General issues where contributors help is wanted. |
| [question](https://github.com/bloomberg/memray/search?q=is%3Aissue+is%3Aopen+label%3Aquestion&type=Issues&utf8=%E2%9C%93) | `is:issue is:open label:question` | Open discussions to resolve everything from implementation details to desired functionality. |

## Documentation

**Public** modules, functions, classes, and methods must be documented using [Python
docstrings][pep 257]. **Non-public** functions and methods must also be documented for defining the
API contract. In addition to being useful for generating documentation, docstrings add clarity when
looking through the source code or using the [built-in help][builtin-help] system, and can be
leveraged in autocompletion by IDEs.

Please see [PEP 257][] for details on semantics and conventions associated with Python docstrings.

### Docstring style

Docstrings must follow [Google style docstrings][google-style]. This docstring style is more
pleasant to read when browsing the source.

## Type hints

All functions and methods should be type annotated. This allows for static analysis and more
intelligent code completion from tools & IDEs.

Type annotations must use [type comment](#py27-type-comment) annotations until 2.7 support is
completely phased out. Please see [PEP 484][] for details on definitions and tools surrounding type
annotations.

## Tests

Changes should always include tests. If this is a bug fix it is a good idea to add the tests as the
first commit of the pull request and the changes to fix the issue in subsequent commits to make it
easier to validate it.

## Pull requests

### PRs should be linked to a GitHub issue

Before opening a pull request to this repository, first please make sure there is a GitHub issue
where your change has been discussed with the maintainers. Mention the issue number in your pull
request description using one of the
[supported keywords](https://help.github.com/articles/closing-issues-using-keywords/). For example,
adding `Closes: #100` in the pull request description will link the PR with the issue and GitHub
will automatically close the issue upon merging it.

Do not include the issue reference in your commit messages however, add it only in the description
of the PR.

<!-- LINKS -->

[pep 257]: https://www.python.org/dev/peps/pep-0257/ "Docstring Conventions"
[pep 484]: https://www.python.org/dev/peps/pep-0484/ "Type Hints"
[google-style]: https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html "Example Google Style Python Docstrings"
[py27-type-comment]: https://www.python.org/dev/peps/pep-0484/#suggested-syntax-for-python-2-7-and-straddling-code "Suggested syntax for Python 2.7 and straddling code"
[builtin-help]: https://docs.python.org/3/library/functions.html#help

<!--
vim: tw=99:spell
-->
52 changes: 52 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
FROM debian:latest

RUN apt-get update \
&& apt-get install -y --force-yes --no-install-recommends \
build-essential \
libunwind-dev \
pkg-config \
python3-dev \
python3-dbg \
python3-pip \
python3-venv \
make \
cmake \
gdb \
valgrind \
lcov \
nodejs \
npm \
clang-format \
git \
ccache \
wget \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ENV PYTHON=/venv/bin/python \
VIRTUAL_ENV=/venv \
PYTHONDONTWRITEBYTECODE=1 \
PATH=/bin:$PATH \
CC=gcc \
CXX=g++

RUN python3.9 -m venv /venv

ENV PATH="$VIRTUAL_ENV/bin:$PATH"

COPY requirements-test.txt requirements-extra.txt requirements-docs.txt /tmp/

RUN $PYTHON -m pip install -U \
-r /tmp/requirements-extra.txt \
-r /tmp/requirements-test.txt \
-r /tmp/requirements-docs.txt \
cython \
setuptools \
wheel

RUN npm install -g prettier

RUN ln -s /usr/bin/ccache /bin/g++ \
&& ln -s /usr/bin/ccache /bin/gcc

WORKDIR /src
Loading

0 comments on commit 2c33838

Please sign in to comment.