Skip to content

Commit

Permalink
Drop gmpy2 directory & move source files to src/gmpy2/
Browse files Browse the repository at this point in the history
TBD

With this patch:
$ time python -c 'from gmpy2 import *'

real    0m0.065s
user    0m0.050s
sys     0m0.015s

On the master:
$ time python -c 'from gmpy2 import *'

real    0m0.120s
user    0m0.095s
sys     0m0.024s

XXX: patched delocate
  • Loading branch information
skirpichev committed Mar 24, 2024
1 parent 38bf13e commit 0322c26
Show file tree
Hide file tree
Showing 123 changed files with 20 additions and 29 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pip_install_gmpy2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- run: pip install --upgrade pip
- run: pip --verbose install --editable .[tests]
- run: pytest test/
- run: PYTHONPATH=`pwd`/gmpy2 python test_cython/runtests.py
- run: PYTHONPATH=`pwd`/src/gmpy2 python test_cython/runtests.py
if: ${{ matrix.python-version != '3.13' }}

linux:
Expand All @@ -45,7 +45,7 @@ jobs:
- name: Tests
run: |
pytest test/
PYTHONPATH=`pwd`/gmpy2 python test_cython/runtests.py
PYTHONPATH=`pwd`/src/gmpy2 python test_cython/runtests.py
- name: Building docs
if: matrix.python-version == 3.11
run: |
Expand All @@ -60,7 +60,7 @@ jobs:
python setup.py clean
CFLAGS="-coverage" python setup.py develop
pytest test/
PYTHONPATH=`pwd`/gmpy2 python test_cython/runtests.py
PYTHONPATH=`pwd`/src/gmpy2 python test_cython/runtests.py
lcov --capture --directory . --no-external --output-file build/coverage.info
genhtml build/coverage.info --output-directory build/coverage
- name: Upload coverage to Codecov
Expand Down Expand Up @@ -104,4 +104,4 @@ jobs:
- run: pip install --upgrade pip
- run: pip --verbose install -e .[tests]
- run: pytest test/
- run: PYTHONPATH=`pwd`/gmpy2 python test_cython/runtests.py
- run: PYTHONPATH=`pwd`/src/gmpy2 python test_cython/runtests.py
1 change: 0 additions & 1 deletion gmpy2/__init__.pxd

This file was deleted.

10 changes: 0 additions & 10 deletions gmpy2/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion gmpy2/gmpy2.h

This file was deleted.

1 change: 0 additions & 1 deletion gmpy2/gmpy2.pxd

This file was deleted.

10 changes: 6 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ Homepage = 'https://github.com/aleaxit/gmpy'

[tool.setuptools]
zip-safe = false
include-package-data = true

[tool.setuptools.packages]
find = {namespaces = false}
[tool.setuptools.packages.find]
where = ['src']

[tool.setuptools.package-data]
gmpy2 = ['*.pxd', '*.h', '*.dll', '*.lib']
gmpy2 = ['*.pxd', 'gmpy2.h', 'gmp.h', 'mpfr.h', 'mpc.h']

[tool.setuptools.exclude-package-data]
gmpy2 = ['gmpy2.c']

[tool.pytest.ini_options]
addopts = "--durations=10"
Expand Down
2 changes: 1 addition & 1 deletion scripts/cibw_before_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ make install
cd ../

# -- copy headers --
cp $PREFIX/include/{gmp,mpfr,mpc}.h gmpy2/
cp $PREFIX/include/{gmp,mpfr,mpc}.h src/gmpy2/
3 changes: 2 additions & 1 deletion scripts/cibw_repair_wheel_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ LD_LIBRARY_PATH="$(pwd)/.local/lib:$LD_LIBRARY_PATH"

if [[ "$OSTYPE" == "darwin"* ]]
then
delocate-wheel --lib-sdir ../gmpy2.libs -w ${DEST_DIR} -v ${WHEEL}
pip install -U git+https://github.com/skirpichev/delocate.git@fix-lib-sdir
delocate-wheel --lib-sdir .libs -w ${DEST_DIR} -v ${WHEEL}
else
auditwheel repair -w ${DEST_DIR} ${WHEEL}
fi
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

ON_WINDOWS = platform.system() == 'Windows'
_comp_args = ["DSHARED=1"]
sources = ['src/gmpy2.c']
sources = ['src/gmpy2/gmpy2.c']
if os.getenv('CIBUILDWHEEL'):
include_dirs = [os.path.join(os.path.dirname(__file__), '.local', 'include')]
library_dirs = [os.path.join(os.path.dirname(__file__), '.local',
Expand Down Expand Up @@ -71,7 +71,7 @@ def build_extensions(self):
build_ext.build_extensions(self)

extensions = [
Extension('gmpy2.gmpy2',
Extension('gmpy2',
sources=sources,
include_dirs=include_dirs,
libraries=['mpc','mpfr','gmp'],
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.
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.
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.
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.
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.
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.
9 changes: 5 additions & 4 deletions test_cython/setup_cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import gmpy2

gmpy2_packagedir = os.path.dirname(gmpy2.__file__)
library_dirs = sys.path + [gmpy2_packagedir]
include_dirs = sys.path + [os.path.join(gmpy2_packagedir, 'gmpy2')]
library_dirs = include_dirs
libnames = ['mpc','mpfr','gmp']

if platform.system() != 'Windows':
bundled_libs = gmpy2_packagedir+'/../gmpy2.libs/'
bundled_libs = gmpy2_packagedir+'/gmpy2.libs/'
if os.path.isdir(bundled_libs):
library_dirs += [bundled_libs]
if platform.system() == 'Linux':
Expand All @@ -21,12 +22,12 @@

extensions = [
Extension("test_cython", ["test_cython.pyx"],
include_dirs=sys.path + [gmpy2_packagedir],
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=libnames)]

setup(
name="cython_gmpy_test",
ext_modules=cythonize(extensions, include_path=sys.path,
ext_modules=cythonize(extensions, include_path=include_dirs,
compiler_directives={'language_level' : "3"})
)

0 comments on commit 0322c26

Please sign in to comment.