Skip to content

Commit 681b378

Browse files
committed
Restructure source tree layout
1 parent 005f956 commit 681b378

31 files changed

+54
-42
lines changed

.mypy.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ warn_unused_ignores = True
55
warn_redundant_casts = True
66
show_error_codes = True
77
exclude = (?x)(
8-
^shmem4py/src/.*\.py$ |
8+
^src/.*\.py$ |
99
^demo/api/.*\.py$
1010
)
1111

MANIFEST.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
recursive-include demo *.py makfile
2-
recursive-include shmem4py/src *.h *.c *.py
1+
recursive-include demo *.py makefile
2+
recursive-include src *.py *.h *.c
3+
recursive-include test *.sh

makefile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ OSHRUN := $(firstword \
88

99
.PHONY: build
1010
build:
11-
$(PYTHON) setup.py $(opt) build build_ext --inplace
11+
$(PYTHON) setup.py $(opt) build build_ext --inplace $(opt)
1212

1313
.PHONY: test
1414
test:
@@ -20,8 +20,8 @@ test-%:
2020

2121
.PHONY: lint
2222
lint:
23-
-pycodestyle shmem4py
24-
-flake8 shmem4py
23+
-pycodestyle src/shmem4py
24+
-flake8 src/shmem4py
2525
-pylint shmem4py
2626

2727
.PHONY: cover cover-html
@@ -36,14 +36,20 @@ cover-html: cover
3636

3737
.PHONY: clean
3838
clean:
39-
-$(RM) -r build shmem4py/*.so shmem4py.egg-info
39+
-$(RM) -r build src/shmem4py/*.so src/shmem4py.egg-info
4040
-$(RM) -r */__pycache__ */*/__pycache__
4141
-$(RM) -r .coverage* htmlcov/
4242
-$(RM) -r .mypy_cache
4343

44+
.PHONY: develop develop-uninstall
45+
develop:
46+
$(PYTHON) setup.py develop --prefix='' --user $(opt)
47+
develop-uninstall:
48+
$(PYTHON) setup.py develop --prefix='' --user --uninstall $(opt)
49+
4450
.PHONY: install uninstall
4551
install:
46-
$(PYTHON) setup.py $(opt) install --prefix='' --user
52+
$(PYTHON) setup.py $(opt) install --prefix='' --user $(opt)
4753
uninstall:
4854
-$(RM) -r $(shell $(PYTHON) -m site --user-site)/shmem4py
4955
-$(RM) -r $(shell $(PYTHON) -m site --user-site)/shmem4py-*-py*.egg-info

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
22
requires = [
3-
"setuptools >= 40.9.0",
3+
"setuptools >= 43",
44
"wheel",
55
"cffi >= 1.13",
66
]

setup.cfg

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
11
[metadata]
22
name = shmem4py
33
version = attr: shmem4py.__version__
4-
license = BSD-2-Clause
54
description = Python bindings for OpenSHMEM
65
long_description = file: README.md
76
long_description_content_type = text/markdown
7+
license = BSD-2-Clause
8+
license_files = LICENSE.md
89
url = https://github.comm/mpi4py/shmem4py
910
author = Lisandro Dalcin
1011
author_email = [email protected]
1112

1213
[options]
14+
packages =
15+
shmem4py
16+
package_dir =
17+
=src
1318
setup_requires =
1419
cffi>=1.13
1520
install_requires =
1621
cffi>=1.13
1722
numpy>=1.12
1823
python_requires = >=3.7
19-
20-
21-
[flake8]
22-
exclude = shmem4py/src/*
24+
[options.package_data]
25+
shmem4py =
26+
py.typed
27+
api.pyi
2328

2429

2530
[coverage:run]
2631
parallel = True
2732
branch = True
2833
source = shmem4py
2934
[coverage:paths]
30-
source = */shmem4py
35+
source =
36+
src/shmem4py
37+
*/shmem4py

setup.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
Python bindings for OpenSHMEM
77
"""
88

9-
import sys, os
9+
import os
10+
import sys
1011
from setuptools import setup, Extension
1112
from setuptools.command.build_ext import build_ext as cmd_build_ext
1213
from setuptools.command.install import install as cmd_install
1314

1415
topdir = os.path.abspath(os.path.dirname(__file__))
15-
sys.path.insert(0, os.path.join(topdir, 'shmem4py', 'src'))
16+
sys.path.insert(0, os.path.join(topdir, 'src'))
1617

1718
class build_ext(cmd_build_ext, object):
1819
def build_extensions(self):
@@ -30,17 +31,8 @@ def run(self):
3031
super(install, self).run()
3132

3233
setup(
33-
packages = [
34-
'shmem4py',
35-
],
36-
package_data = {
37-
'shmem4py' : [
38-
'api.pyi',
39-
'py.typed',
40-
],
41-
},
4234
cffi_modules = [
43-
'shmem4py/src/api_build.py:ffibuilder',
35+
'src/ffibuilder.py:ffibuilder',
4436
],
4537
cmdclass = {
4638
'build_ext': build_ext,

shmem4py/src/generate.py renamed to src/apicodegen.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,5 @@ def generate():
303303

304304

305305
if __name__ == '__main__':
306-
import os
307306
for code in generate():
308307
print(code.strip(), end='\n')

shmem4py/src/api_build.py renamed to src/ffibuilder.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
import os
2+
import sys
23
import glob
34
import cffi
45

56
srcdir = os.path.abspath(os.path.dirname(__file__))
6-
with open(os.path.join(srcdir, "generate.py")) as h:
7-
exec(h.read())
7+
if srcdir not in sys.path:
8+
sys.path.insert(0, srcdir)
89

910

10-
def api_build(
11+
def build_api(
1112
module="api",
1213
shmem_h="shmem.h",
1314
shmem_ctx_t='...*',
1415
shmem_team_t='...*',
1516
):
17+
from apicodegen import generate
1618
ffi = cffi.FFI()
1719
with open(os.path.join(srcdir, "libshmem.h")) as h:
1820
code = h.read()
@@ -64,12 +66,17 @@ def api_build(
6466

6567

6668
def ffibuilder():
67-
return api_build()
69+
return build_api()
6870

6971

7072
if __name__ == '__main__':
7173
from fficompiler import fficompiler
7274
cc = fficompiler.search('OSHCC', 'oshcc')
7375
ld = fficompiler.search('OSHLD')
7476
with fficompiler(cc, ld):
75-
ffibuilder().compile()
77+
cwd = os.getcwd()
78+
try:
79+
os.chdir(srcdir)
80+
ffibuilder().compile()
81+
finally:
82+
os.chdir(cwd)
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)