Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename to networkx-graph #2

Merged
merged 7 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterFunction: true
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: true
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

44 changes: 0 additions & 44 deletions .github/workflows/conda.yml

This file was deleted.

13 changes: 5 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ repos:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
exclude: ^conda\.recipe/meta\.yaml$
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
Expand All @@ -47,7 +45,7 @@ repos:
rev: v1.5.4
hooks:
- id: remove-tabs
exclude: ^(docs)
exclude: ^(docs|Makefile)

# CMake formatting
- repo: https://github.com/cheshirekow/cmake-format-precommit
Expand All @@ -58,8 +56,7 @@ repos:
types: [file]
files: (\.cmake|CMakeLists.txt)(.in)?$

# Suggested hook if you add a .clang-format file
# - repo: https://github.com/pre-commit/mirrors-clang-format
# rev: v13.0.0
# hooks:
# - id: clang-format
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v13.0.0
hooks:
- id: clang-format
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ target_link_libraries(_core PRIVATE pybind11::headers)
target_compile_definitions(_core PRIVATE VERSION_INFO=${PROJECT_VERSION})

# The install directory is the output (wheel) directory
install(TARGETS _core DESTINATION scikit_build_example)
install(TARGETS _core DESTINATION networkx_graph)
110 changes: 110 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
PROJECT_SOURCE_DIR ?= $(abspath ./)
PROJECT_NAME ?= $(shell basename $(PROJECT_SOURCE_DIR))
NUM_JOBS ?= 8

all:
@echo nothing special

lint:
pre-commit run -a
lint_install:
pre-commit install
.PHONY: lint

reset_submodules:
git submodule update --init --recursive

clean:
rm -rf build *.egg-info dist
force_clean:
docker run --rm -v `pwd`:`pwd` -w `pwd` -it alpine/make make clean

pytest:
python3 -m pip install pytest numpy
pytest tests # --capture=tee-sys
clitest:
python3 -m networkx_graph add 3 5
python3 -m networkx_graph subtract 8 5
.PHONY: test pytest clitest

docs_build:
mkdocs build
docs_serve:
mkdocs serve -a 0.0.0.0:8088

DOCKER_TAG_WINDOWS ?= ghcr.io/cubao/build-env-windows-x64:v0.0.1
DOCKER_TAG_LINUX ?= ghcr.io/cubao/build-env-manylinux2014-x64:v0.0.4
DOCKER_TAG_MACOS ?= ghcr.io/cubao/build-env-macos-arm64:v0.0.1

test_in_win:
docker run --rm -w `pwd` -v `pwd`:`pwd` -v `pwd`/build/win:`pwd`/build -it $(DOCKER_TAG_WINDOWS) bash
test_in_mac:
docker run --rm -w `pwd` -v `pwd`:`pwd` -v `pwd`/build/mac:`pwd`/build -it $(DOCKER_TAG_MACOS) bash
test_in_linux:
docker run --rm -w `pwd` -v `pwd`:`pwd` -v `pwd`/build/linux:`pwd`/build -it $(DOCKER_TAG_LINUX) bash

DEV_CONTAINER_NAME ?= $(USER)_$(subst /,_,$(PROJECT_NAME)____$(PROJECT_SOURCE_DIR))
DEV_CONTAINER_IMAG ?= $(DOCKER_TAG_LINUX)
test_in_dev_container:
docker ps | grep $(DEV_CONTAINER_NAME) \
&& docker exec -it $(DEV_CONTAINER_NAME) bash \
|| docker run --rm --name $(DEV_CONTAINER_NAME) \
--network host --security-opt seccomp=unconfined \
-v `pwd`:`pwd` -w `pwd` -it $(DEV_CONTAINER_IMAG) bash


PYTHON ?= python3
build:
$(PYTHON) -m pip install scikit_build_core pyproject_metadata pathspec pybind11
CMAKE_BUILD_PARALLEL_LEVEL=$(NUM_JOBS) $(PYTHON) -m pip install --no-build-isolation -Ceditable.rebuild=true -Cbuild-dir=build -ve.
python_install:
$(PYTHON) -m pip install . --verbose
python_wheel:
$(PYTHON) -m pip wheel . -w build --verbose
python_sdist:
$(PYTHON) -m pip sdist . --verbose
python_test: pytest
.PHONY: build

# conda create -y -n py36 python=3.6
# conda create -y -n py37 python=3.7
# conda create -y -n py38 python=3.8
# conda create -y -n py39 python=3.9
# conda create -y -n py310 python=3.10
# conda env list
python_build_py36:
PYTHON=python conda run --no-capture-output -n py36 make python_build
python_build_py37:
PYTHON=python conda run --no-capture-output -n py37 make python_build
python_build_py38:
PYTHON=python conda run --no-capture-output -n py38 make python_build
python_build_py39:
PYTHON=python conda run --no-capture-output -n py39 make python_build
python_build_py310:
PYTHON=python conda run --no-capture-output -n py310 make python_build
python_build_all: python_build_py36 python_build_py37 python_build_py38 python_build_py39 python_build_py310
python_build_all_in_linux:
docker run --rm -w `pwd` -v `pwd`:`pwd` -v `pwd`/build/linux:`pwd`/build -it $(DOCKER_TAG_LINUX) make python_build_all
make repair_wheels && rm -rf dist/*.whl && mv wheelhouse/*.whl dist && rm -rf wheelhouse
python_build_all_in_macos: python_build_py38 python_build_py39 python_build_py310
python_build_all_in_windows: python_build_all

repair_wheels:
python -m pip install auditwheel # sudo apt install patchelf
ls dist/*-linux_x86_64.whl | xargs -n1 auditwheel repair --plat manylinux2014_x86_64
rm -rf dist/*-linux_x86_64.whl && cp wheelhouse/*.whl dist && rm -rf wheelhouse

pypi_remote ?= pypi
upload_wheels:
python -m pip install twine
twine upload build/*.whl -r $(pypi_remote)

tar.gz:
tar -cvz --exclude .git -f ../$(PROJECT_NAME).tar.gz .
ls -alh ../$(PROJECT_NAME).tar.gz

# https://stackoverflow.com/a/25817631
echo-% : ; @echo -n $($*)
Echo-% : ; @echo $($*)
ECHO-% : ; @echo $* = $($*)
echo-Tab: ; @echo -n ' '
93 changes: 2 additions & 91 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,92 +1,3 @@
# scikit_build_example
# networkx-graph

[![Gitter][gitter-badge]][gitter-link]

| CI | status |
|----------------------|--------|
| conda.recipe | [![Conda Actions Status][actions-conda-badge]][actions-conda-link] |
| pip builds | [![Pip Actions Status][actions-pip-badge]][actions-pip-link] |


An example project built with [pybind11][] and [scikit-build-core][]. Python
3.7+ (see older commits for older versions of Python using [scikit-build (classic)][]).


[gitter-badge]: https://badges.gitter.im/pybind/Lobby.svg
[gitter-link]: https://gitter.im/pybind/Lobby
[actions-badge]: https://github.com/pybind/scikit_build_example/workflows/Tests/badge.svg
[actions-conda-link]: https://github.com/pybind/scikit_build_example/actions?query=workflow%3AConda
[actions-conda-badge]: https://github.com/pybind/scikit_build_example/workflows/Conda/badge.svg
[actions-pip-link]: https://github.com/pybind/scikit_build_example/actions?query=workflow%3APip
[actions-pip-badge]: https://github.com/pybind/scikit_build_example/workflows/Pip/badge.svg
[actions-wheels-link]: https://github.com/pybind/scikit_build_example/actions?query=workflow%3AWheels
[actions-wheels-badge]: https://github.com/pybind/scikit_build_example/workflows/Wheels/badge.svg

## Installation

- Clone this repository
- `pip install ./scikit_build_example`

## Test call

```python
import scikit_build_example

scikit_build_example.add(1, 2)
```

## Files

This example has several files that are a good idea, but aren't strictly
necessary. The necessary files are:

* `pyproject.toml`: The Python project file
* `CMakeLists.txt`: The CMake configuration file
* `src/main.cpp`: The source file for the C++ build
* `src/scikit_build_example/__init__.py`: The Python portion of the module. The root of the module needs to be `<package_name>`, `src/<package_name>`, or `python/<package_name>` to be auto-discovered.

These files are also expected and highly recommended:

* `.gitignore`: Git's ignore list, also used by `scikit-build-core` to select files for the SDist
* `README.md`: The source for the PyPI description
* `LICENSE`: The license file

There are also several completely optional directories:

* `.github`: configuration for [Dependabot][] and [GitHub Actions][]
* `conda.recipe`: Example recipe. Normally you should submit projects to conda-forge instead of building them yourself, but this is useful for testing the example.
* `docs/`: Documentation
* `tests/`: Tests go here

And some optional files:

* `.pre-commit-config.yaml`: Configuration for the fantastic static-check runner [pre-commit][].
* `noxfile.py`: Configuration for the [nox][] task runner, which helps make setup easier for contributors.

This is a simplified version of the recommendations in the [Scientific-Python
Development Guide][], which is a _highly_ recommended read for anyone
interested in Python package development (Scientific or not). The guide also
has a cookiecutter that includes scikit-build-core and pybind11 as a backend
choice.

### CI Examples

There are examples for CI in `.github/workflows`. A simple way to produces
binary "wheels" for all platforms is illustrated in the "wheels.yml" file,
using [cibuildwheel][].

## License

pybind11 is provided under a BSD-style license that can be found in the LICENSE
file. By using, distributing, or contributing to this project, you agree to the
terms and conditions of this license.

[cibuildwheel]: https://cibuildwheel.readthedocs.io
[scientific-python development guide]: https://learn.scientific-python.org/development
[dependabot]: https://docs.github.com/en/code-security/dependabot
[github actions]: https://docs.github.com/en/actions
[pre-commit]: https://pre-commit.com
[nox]: https://nox.thea.codes
[pybind11]: https://pybind11.readthedocs.io
[scikit-build-core]: https://scikit-build-core.readthedocs.io
[scikit-build (classic)]: https://scikit-build.readthedocs.io
TODO
Loading
Loading