Skip to content

Commit

Permalink
Reorganize code into src folder to avoid import issues
Browse files Browse the repository at this point in the history
  • Loading branch information
thalassemia committed Dec 5, 2024
1 parent b6c46a1 commit b2f25fd
Show file tree
Hide file tree
Showing 27 changed files with 19 additions and 29 deletions.
17 changes: 1 addition & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,7 @@ jobs:
CIBW_FREE_THREADED_SUPPORT: ${{ matrix.free_threaded_support }}
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
CIBW_TEST_REQUIRES: pytest psutil
CIBW_TEST_COMMAND: |
mkdir tmp_test_dir
cp -r {project}/stochastic_arrow/test tmp_test_dir/test
cp -r {project}/data tmp_test_dir/data
cd tmp_test_dir
pytest
CIBW_TEST_COMMAND_WINDOWS: |
echo "Starting tests on Windows";
mkdir tmp_test_dir;
echo "Copying test directory";
xcopy /E /I /Y stochastic_arrow\test tmp_test_dir\test;
echo "Copying data directory";
xcopy /E /I /Y stochastic_arrow\data tmp_test_dir\data;
cd tmp_test_dir;
echo "Running pytest on Windows";
pytest -v
CIBW_TEST_COMMAND: pytest -v {project}/test
CIBW_ENVIRONMENT: USE_CYTHON=1
uses: pypa/[email protected]

Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ profile
/.idea/
/tmp/

stochastic_arrow/arrowhead.c
stochastic_arrow/arrowhead.*.pyd
stochastic_arrow/*.html
src/stochastic_arrow/arrowhead.c
src/stochastic_arrow/arrowhead.*.pyd
src/stochastic_arrow/*.html

arrow.egg-info/
stochastic_arrow.egg-info/
Expand Down
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include stochastic_arrow/obsidian.h
include stochastic_arrow/mersenne.h
include src/stochastic_arrow/obsidian.h
include src/stochastic_arrow/mersenne.h
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
.DEFAULT_GOAL := compile

clean:
### Files for older versions of stochastic_arrow are in arrow folder
### Files for older versions of stochastic_arrow are in arrow or stochastic_arrow folder
rm -rf arrow/arrowhead*.so arrow/arrowhead.c arrow/arrowhead.html
rm -rf stochastic_arrow/arrowhead*.so stochastic_arrow/arrowhead.c stochastic_arrow/arrowhead.html build/ dist/ MANIFEST .pytest_cache/ stochastic_arrow.egg-info/
### Newer versions of stochastic_arrow are in src/stochastic_arrow folder
rm -rf src/stochastic_arrow/arrowhead*.so src/stochastic_arrow/arrowhead.c src/stochastic_arrow/arrowhead.html src/stochastic_arrow.egg-info/
find . -name "*.pyc" -delete
find . -name "__pycache__" -delete

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 10 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from setuptools import Extension, setup
from setuptools import Extension, find_packages, setup
import sys
import numpy as np

Expand All @@ -20,28 +20,31 @@

ext = '.pyx' if USE_CYTHON else '.c'

arrow_dir = os.path.join('src', 'stochastic_arrow')

cython_extensions = [
Extension('stochastic_arrow.arrowhead',
sources=[
'stochastic_arrow/mersenne.c',
'stochastic_arrow/obsidian.c',
'stochastic_arrow/arrowhead'+ext,],
include_dirs=['stochastic_arrow', np.get_include()],
os.path.join(arrow_dir, 'mersenne.c'),
os.path.join(arrow_dir, 'obsidian.c'),
os.path.join(arrow_dir, 'arrowhead'+ext),],
include_dirs=[arrow_dir, np.get_include()],
define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')],
)]

if USE_CYTHON:
from Cython.Build import cythonize
cython_extensions = cythonize(
cython_extensions,
include_path=['stochastic_arrow'],
include_path=[arrow_dir],
annotate=True, # to get an HTML code listing
)

setup(
name='stochastic-arrow',
version='1.0.0',
packages=['stochastic_arrow'],
packages=find_packages('src'),
package_dir={'': 'src'},
author='Ryan Spangler, John Mason, Jerry Morrison, Chris Skalnik, Travis Ahn-Horst, Sean Cheah',
author_email='[email protected]',
url='https://github.com/CovertLab/arrow',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit b2f25fd

Please sign in to comment.