GithubHelp home page GithubHelp logo

kangwonlee / build_utils Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 29 KB

Build (and run) C/C++ files using iPython / Jupyter magic commands

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

build_utils's Issues

python setup.py test does not work yet

$ python setup.py test
running test
running egg_info
writing build_util.egg-info/PKG-INFO
writing dependency_links to build_util.egg-info/dependency_links.txt
writing requirements to build_util.egg-info/requires.txt
writing top-level names to build_util.egg-info/top_level.txt
reading manifest file 'build_util.egg-info/SOURCES.txt'
writing manifest file 'build_util.egg-info/SOURCES.txt'
running build_ext
tests (unittest.loader._FailedTest) ... ERROR

======================================================================
ERROR: tests (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: tests
Traceback (most recent call last):
  File "~/anaconda3/lib/python3.7/unittest/loader.py", line 154, in loadTestsFromName
    module = __import__(module_name)
ModuleNotFoundError: No module named 'build_util.tests'


----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)
Test failed: <unittest.runner.TextTestResult run=1 errors=1 failures=0>
error: Test failed: <unittest.runner.TextTestResult run=1 errors=1 failures=0>

need tests

  • sample ipynb file
  • get c/c++ source code
  • build
  • run + capture output

Custom magic command

Motivation

  • Wouldn't it be nice if we can include some C/C++ source codes in the ipython notebook files?
  • Similar to %%cython
  • Let's call it %%cpp
  • Build options as command line option

Need more info

  • How to set compiler command line options?

How to write a magic command?

How to make it easy to deploy?

  • So that a user does not have to build the whole jupyter notebook?
  • According to kmario23, one could try a custom magic using following command
$ python setup.py develop 

How to test the magic command?

Where to put the custom magic command?

  • As a subtree of a different repository?
  • within a .ipynb file under a subfolder may add the path as follows?
import os
import sys

sys.path.append(
    os.path.abspath(
        os.path.join(os.path.dirname(__file__), os.pardir, <custom magic>)
    )
)
  • setuptools would deal with this problem too

start a package architecture

foo
├── foo
│   ├── data_struct.py
│   ├── __init__.py
│   └── internals.py
├── README
├── requirements.txt
└── setup.py

would translate into

from setuptools import setup

setup(
   name='foo',
   version='1.0',
   description='A useful module',
   author='Man Foo',
   author_email='[email protected]',
   packages=['foo'],  #same as name
   install_requires=['bar', 'greek'], #external packages as dependencies
)
project
├── sample
│   ├── __init__.py
│   ├── core.py
│   └── helpers.py
├── docs
│   ├── conf.py
│   └── index.rst
├── tests
│   ├── test_basic.py
│   └── test_advanced.py
├── README.rst
├── LICENSE
├── setup.py
└── requirements.txt

IMHO this would translate into

from setuptools import setup

setup(
   name='sample',
   version='1.0',
   description='A useful module',
   author='Kenneth Reitz',
   author_email='[email protected]',
   packages=['sample'],  #same as name
   install_requires=['spam', 'egg'], #external packages as dependencies, if any?
)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.