Restructuring for package to submit to PyPA.

This commit is contained in:
Kenneth Jao 2021-09-24 09:42:05 -04:00
parent 4f23f0c43f
commit d748b25040
15 changed files with 1346 additions and 1428 deletions

View File

@ -1,3 +1,3 @@
[build-system] [build-system]
requires = ["setuptools >= 42", "wheel", "Cython", "numpy"] requires = ["setuptools >= 42", "wheel", "numpy"]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"

View File

@ -1,24 +1,40 @@
alabaster==0.7.12 alabaster==0.7.12
Babel==2.9.1 Babel==2.9.1
bleach==4.1.0
build==0.7.0
certifi==2021.5.30 certifi==2021.5.30
cffi==1.14.6
charset-normalizer==2.0.6 charset-normalizer==2.0.6
colorama==0.4.4
cryptography==3.4.8
cycler==0.10.0 cycler==0.10.0
Cython==0.29.24
docutils==0.17.1 docutils==0.17.1
idna==3.2 idna==3.2
imagesize==1.2.0 imagesize==1.2.0
importlib-metadata==4.8.1
jeepney==0.7.1
Jinja2==3.0.1 Jinja2==3.0.1
keyring==23.2.1
kiwisolver==1.3.2 kiwisolver==1.3.2
MarkupSafe==2.0.1 MarkupSafe==2.0.1
matplotlib==3.4.3 matplotlib==3.4.3
numpy==1.21.2 numpy==1.21.2
packaging==21.0 packaging==21.0
pep517==0.11.0
Pillow==8.3.2 Pillow==8.3.2
pkginfo==1.7.1
pycparser==2.20
Pygments==2.10.0 Pygments==2.10.0
pyparsing==2.4.7 pyparsing==2.4.7
python-dateutil==2.8.2 python-dateutil==2.8.2
pytz==2021.1 pytz==2021.1
readme-renderer==29.0
requests==2.26.0 requests==2.26.0
requests-toolbelt==0.9.1
rfc3986==1.5.0
scipy==1.7.1 scipy==1.7.1
SecretStorage==3.3.1
six==1.16.0 six==1.16.0
snowballstemmer==2.1.0 snowballstemmer==2.1.0
Sphinx==4.2.0 Sphinx==4.2.0
@ -29,5 +45,9 @@ sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1 sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3 sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5 sphinxcontrib-serializinghtml==1.1.5
-e git+git@github.com:ksjdragon/packsim.git@e2f25182310c1f9a950df55c0219165366466e9b#egg=squish tomli==1.2.1
tqdm==4.62.3
twine==3.4.2
urllib3==1.26.6 urllib3==1.26.6
webencodings==0.5.1
zipp==3.5.0

View File

@ -1,10 +1,10 @@
[metadata] [metadata]
name = squish-ksjdragon name = squish
version = 0.1 version = 0.1
author = Kenneth Jao author = Kenneth Jao
author_email = ksjdragon@gmail.com author_email = ksjdragon@gmail.com
description = squish is Python program which perform simulations for the flow of 'soft' or 'compressible' objects under some energy in a periodic domain. description = squish is Python program which perform simulations for the flow of 'soft' or 'compressible' objects under some energy in a periodic domain.
long_description = file: README.md long_description = file: README.rst
long_description_content_type = text/markdown long_description_content_type = text/markdown
url = https://github.com/ksjdragon/squish url = https://github.com/ksjdragon/squish
project_urls = project_urls =
@ -18,19 +18,13 @@ classifiers =
[options] [options]
zip_safe = False zip_safe = False
package_dir = packages = squish
= src
pacakges = find:
python_requires = >= 3.8 python_requires = >= 3.8
install_requires = install_requires =
numpy == 1.21.2 numpy == 1.21.2
scipy == 1.7.1 scipy == 1.7.1
matplotlib == 3.4.3 matplotlib == 3.4.3
[options.packages.find]
where = src
[options.entry_points] [options.entry_points]
console_scripts = console_scripts =
squish = squish.squish:pre squish = squish.squish:pre

View File

@ -1,20 +1,31 @@
from setuptools import Extension, setup from setuptools import Extension, setup
from Cython.Build import cythonize
import numpy import numpy
ext_modules = [ try:
Extension( from Cython.Build import cythonize
"_squish", USE_CYTHON = True
["src/_squish/_squish.pyx"], except ImportError:
extra_compile_args=['-fopenmp'], USE_CYTHON = False
extra_link_args=['-fopenmp']
) if USE_CYTHON:
ext_modules = cythonize([
Extension(
"_squish",
["squish/_squish/_squish.pyx"],
extra_compile_args=['-fopenmp'],
extra_link_args=['-fopenmp']
)
],
compiler_directives={
'language_level': 3, 'boundscheck' : False, 'wraparound': False, 'cdivision' : True
})
else:
ext_modules = [
Extension('squish._squish', ["squish/_squish/_squish.c"])
] ]
#annotate='fullc'
setup( setup(
name="squish", ext_modules = ext_modules,
ext_modules = cythonize(ext_modules, compiler_directives={ include_dirs = [numpy.get_include()]
'language_level': 3, 'boundscheck' : False, 'wraparound': False, 'cdivision' : True
}),
include_dirs = [numpy.get_include()]
) )

File diff suppressed because it is too large Load Diff

View File

@ -40,7 +40,7 @@ cdef class AreaEnergy(VoronoiContainer):
if i < self.n: if i < self.n:
energy += xi.cache.energy(&xi, NAN) energy += xi.cache.energy(&xi, NAN)
for j in prange(xi.edge_num(&xi)): for j in range(xi.edge_num(&xi)):
em, ep = e.prev(&e), e.next(&e) em, ep = e.prev(&e), e.next(&e)
vdiff = em.origin(&em) vdiff = em.origin(&em)
vdiff.self.vsub(&vdiff, ep.origin(&ep)) vdiff.self.vsub(&vdiff, ep.origin(&ep))
@ -71,7 +71,7 @@ cdef class AreaEnergy(VoronoiContainer):
xi = init.Site(i, &info) xi = init.Site(i, &info)
e = xi.edge(&xi) e = xi.edge(&xi)
edge_set = init.BitSet(num_edges) edge_set = init.BitSet(num_edges)
for j in prange(xi.edge_num(&xi)): # Looping through site edges. for j in range(xi.edge_num(&xi)): # Looping through site edges.
f = e f = e
while True: # Circling this vertex. while True: # Circling this vertex.
if not edge_set.add(&edge_set, f.arr_index): if not edge_set.add(&edge_set, f.arr_index):
@ -166,7 +166,7 @@ cdef class RadialTEnergy(VoronoiContainer):
for i in prange(self.sites.shape[0], nogil=True): for i in prange(self.sites.shape[0], nogil=True):
xi = init.Site(i, &info) xi = init.Site(i, &info)
e = xi.edge(&xi) e = xi.edge(&xi)
for j in prange(xi.edge_num(&xi)): for j in range(xi.edge_num(&xi)):
em = e.prev(&e) em = e.prev(&e)
e.cache.H(&e, VoronoiContainer.calc_H(em, e)) e.cache.H(&e, VoronoiContainer.calc_H(em, e))
t = Calc.phi(e) t = Calc.phi(e)
@ -186,7 +186,7 @@ cdef class RadialTEnergy(VoronoiContainer):
# For looping again to calculate integrals. # For looping again to calculate integrals.
em = xi.edge(&xi) em = xi.edge(&xi)
for j in prange(xi.edge_num(&xi)): for j in range(xi.edge_num(&xi)):
e = em.next(&em) e = em.next(&em)
B = em.cache.B(&em, NAN) B = em.cache.B(&em, NAN)
t, tp = em.cache.phi(&em, NAN), e.cache.phi(&e, NAN) t, tp = em.cache.phi(&em, NAN), e.cache.phi(&e, NAN)
@ -234,7 +234,7 @@ cdef class RadialTEnergy(VoronoiContainer):
e = xi.edge(&xi) e = xi.edge(&xi)
edge_set = init.BitSet(num_edges) edge_set = init.BitSet(num_edges)
for j in prange(xi.edge_num(&xi)): # Looping through site edges. for j in range(xi.edge_num(&xi)): # Looping through site edges.
f = e f = e
while True: # Circling this vertex. while True: # Circling this vertex.
fm = f.prev(&f) fm = f.prev(&f)

View File

@ -537,7 +537,7 @@ cdef class VoronoiContainer:
for i in prange(self.sites.shape[0], nogil=True): for i in prange(self.sites.shape[0], nogil=True):
xi = init.Site(i, &info) xi = init.Site(i, &info)
em = xi.edge(&xi) em = xi.edge(&xi)
for j in prange(xi.edge_num(&xi)): for j in range(xi.edge_num(&xi)):
ep = em.next(&em) ep = em.next(&em)
p, q = em.origin(&em), ep.origin(&ep) p, q = em.origin(&em), ep.origin(&ep)
la, da = q.copy.vsub(&q, p), p.copy.vsub(&p, xi.vec(&xi)) # vp - vm, vm - xi la, da = q.copy.vsub(&q, p), p.copy.vsub(&p, xi.vec(&xi)) # vp - vm, vm - xi

View File

@ -2,7 +2,7 @@ from __future__ import annotations
from typing import List, Union, Optional, Iterator, Generator from typing import List, Union, Optional, Iterator, Generator
import pickle, numpy as np import pickle, numpy as np
from pathlib import Path from pathlib import Path
from _squish import AreaEnergy, RadialALEnergy, RadialTEnergy from ._squish import AreaEnergy, RadialALEnergy, RadialTEnergy
OUTPUT_DIR = Path("squish_output") OUTPUT_DIR = Path("squish_output")
OUTPUT_DIR.mkdir(exist_ok=True) OUTPUT_DIR.mkdir(exist_ok=True)

View File

@ -298,7 +298,7 @@ class Search(Simulation):
for i in range(self.count): for i in range(self.count):
# Get to equilibrium. # Get to equilibrium.
sim = Flow(self.domain, self.energy, self.thres, self.step_size, self.accel) sim = Flow(self.domain, self.energy, self.step_size, self.thres, self.accel)
sim.add_frame(new_sites) sim.add_frame(new_sites)
sim.run(False, log, log_steps) sim.run(False, log, log_steps)
@ -382,7 +382,7 @@ class Shrink(Simulation):
while width >= self.stop_width: while width >= self.stop_width:
# Get to equilibrium. # Get to equilibrium.
new_domain = DomainParams(self.domain.n, width, self.domain.h, self.domain.r) new_domain = DomainParams(self.domain.n, width, self.domain.h, self.domain.r)
sim = Flow(new_domain, self.energy, self.thres, self.step_size, self.accel) sim = Flow(new_domain, self.energy, self.step_size, self.thres, self.accel)
sim.add_frame(new_sites) sim.add_frame(new_sites)
sim.run(False, log, log_steps) sim.run(False, log, log_steps)
new_sites = sim[-1].site_arr new_sites = sim[-1].site_arr