Skip to content

Commit

Permalink
Merge pull request jpype-project#1133 from pelson/feature/pyproject
Browse files Browse the repository at this point in the history
Make use of pyproject.toml for static project metadata
  • Loading branch information
marscher authored Feb 13, 2024
2 parents df64941 + b9472a3 commit 904fc43
Show file tree
Hide file tree
Showing 15 changed files with 156 additions and 151 deletions.
7 changes: 3 additions & 4 deletions .azure/scripts/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ steps:

- script: |
python setup.py test_java
pip install gcovr pytest-cov jedi
pip install -r test-requirements.txt
pip install numpy typing_extensions
pip install gcovr pytest-cov -r test-requirements.txt
pip install numpy
displayName: 'Install requirements'

- script: |
python setup.py --enable-coverage --enable-build-jar build_ext --inplace
python setup.py develop --enable-coverage --enable-build-jar
displayName: 'Build'

- script: |
Expand Down
3 changes: 1 addition & 2 deletions .azure/scripts/debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ steps:

- script: |
sudo apt install gdb
python setup.py sdist
pip install dist/*
pip install ./
displayName: 'Build module'

- script: python -c "import jpype"
Expand Down
4 changes: 2 additions & 2 deletions .azure/scripts/sdist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ steps:
inputs:
versionSpec: '3.8'
- script: |
python -m pip install setuptools
python setup.py sdist
python -m pip install build
python -m build ./ --sdist
displayName: Build sdist
- task: PublishPipelineArtifact@0
inputs:
Expand Down
2 changes: 1 addition & 1 deletion .azure/scripts/tracing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ steps:
inputs:
versionSpec: '3.8'
- script: |
python setup.py --enable-tracing --enable-build-jar build_ext --inplace
python setup.py develop --enable-tracing --enable-build-jar
displayName: 'Build'

15 changes: 15 additions & 0 deletions doc/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,20 @@ Changelog
This changelog *only* contains changes from the *first* pypi release (0.5.4.3) onwards.

Latest Changes:

- **1.5.1_dev0 - 2023-12-15**
- Use PEP-518 and PEP-660 configuration for the package, allowing editable and
configurable builds using modern Python packaging tooling.
Where before ``python setup.py --enable-tracing develop``, now can be done with
``pip install --editable ./ --config-setting="--install-option=--enable-tracing"``.
The old setup.py usage remains, but is discouraged, and the arguments are now passed
after the command (previously they were specified before).

- Use PEP-518 configuration for the package, allowing
configurable builds using more up-to-date Python packaging tooling.
For editable installs, ``python setup.py --enable-tracing develop``
must now be done with ``python setup.py develop --enable-tracing``.

- **1.5.0 - 2023-04-03**

- Support for Python 3.12
Expand All @@ -18,6 +31,8 @@ Latest Changes:
- Java exceptions that occur in inequality comparisons now map to Python
TypeError.

- **1.4.2_dev0 - 2022-10-26**

- Fixed crash when calling subscript on JArray.

- Fixed direct byte buffers not reporting nbytes correctly when cast to
Expand Down
10 changes: 9 additions & 1 deletion doc/develguide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ must be enabled with a compiler switch to activate. To active the logger, touch
one of the cpp files in the native directory to mark the build as dirty, then
compile the ``jpype`` module with: ::

python setup.py --enable-tracing develop
python setup.py develop --enable-tracing

Once built run a short test program that demonstrates the problem and capture the
output of the terminal to a file. This should allow the developer to isolate
Expand All @@ -959,6 +959,14 @@ To use the Python tracing, start Python with... ::
python -m trace --trace myscript.py


Coverage
--------
Some of the tests require additional instrumentation to run, this can be enabled
with the ``enable-coverage`` option::

python setup.py develop --enable-coverage


Debugging issues
----------------

Expand Down
23 changes: 14 additions & 9 deletions doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,32 @@ from `PyPi <http://pypi.python.org/pypi/JPype1>`__.

**2. Build the source with desired options**

Compile JPype using the included ``setup.py`` script: ::
Compile JPype using the `build <https://pypi.org/project/build/>` module (this will produce a wheel): ::

python setup.py build
python -m build /path/to/source

The setup script recognizes several arguments.
A number of additional argument may be provided.

--enable-build-jar Force setup to recreate the jar from scratch.
--enable-tracing Build a verison of JPype with full logging to the
console. This can be used to diagnose tricky JNI
issues.

For example::

python -m build /path/to/source -C--global-option=build_ext -C--global-option="--enable-tracing"

After building, JPype can be tested using the test bench. The test
bench requires JDK to build.

**3. Test JPype with (optional):** ::
**3. Install the built wheel with:** ::

python setup.py test
pip install /path/to/wheel

**4. Install JPype with:** ::
**4. Test JPype with (optional):** ::

python setup.py test

python setup.py install


If it fails...
Expand All @@ -116,7 +121,7 @@ happens, preform the following steps:
1. Identify the location of your systems JDK installation and explicitly passing
it to setup.py. ::

JAVA_HOME=/usr/lib/java/jdk1.8.0/ python setup.py install
JAVA_HOME=/usr/lib/java/jdk1.8.0/ python -m build .

2. If that setup.py still fails please create an Issue `on
github <https://github.com/jpype-project/jpype/issues?state=open>`__ and
Expand All @@ -138,7 +143,7 @@ Debian/Ubuntu
Debian/Ubuntu users will have to install ``g++`` and ``python-dev``.
Use:

sudo apt-get install g++ python-dev python3-dev
sudo apt-get install g++ python3-dev

Windows
:::::::
Expand Down
58 changes: 57 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,60 @@
[build-system]
requires = [
"setuptools",
]
build-backend = "setuptools.build_meta"


[project]
name = "JPype1"
version = '1.5.0.dev0'
authors = [
{name = "Steve Menard", email = "[email protected]"},
]
maintainers = [
{name = "Luis Nell", email = "[email protected]"},
]
description = "A Python to Java bridge"
readme = "README.rst"
requires-python = ">=3.7"
license = {text = "License :: OSI Approved :: Apache Software License"}
classifiers = [
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Topic :: Software Development',
'Topic :: Scientific/Engineering',
]
dependencies = [
'packaging',
'typing_extensions ; python_version< "3.8"',
]


[project.optional-dependencies]

docs = [
'readthedocs-sphinx-ext',
'sphinx',
'sphinx-rtd-theme',
]
tests = [
"pytest",
]


[project.entry-points.pyinstaller40]
"hook-dirs" = "jpype._pyinstaller.entry_points:get_hook_dirs"
"tests" = "jpype._pyinstaller.entry_points:get_PyInstaller_tests"


[project.urls]
homepage = "https://github.com/jpype-project/jpype"


[[tool.mypy.overrides]]
module = [
"_jpype",
Expand All @@ -9,4 +66,3 @@ module = [
"jedi.access",
]
ignore_missing_imports = true

55 changes: 12 additions & 43 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
from setuptools import Extension
from setuptools import setup

# Add our setupext package to the path, and import it.
sys.path.append(str(Path(__file__).parent))
import setupext

if '--android' in sys.argv:
Expand All @@ -36,9 +38,12 @@
include_dirs=[Path('native', 'common', 'include'),
Path('native', 'python', 'include'),
Path('native', 'embedded', 'include')],
sources=sorted(map(str, list(Path('native', 'common').glob('*.cpp')) +
list(Path('native', 'python').glob('*.cpp')) +
list(Path('native', 'embedded').glob('*.cpp')))), platform=platform,
sources=sorted(
list(Path('native', 'common').glob('*.cpp')) +
list(Path('native', 'python').glob('*.cpp')) +
list(Path('native', 'embedded').glob('*.cpp'))
),
platform=platform,
))
jpypeJar = Extension(name="org.jpype",
sources=sorted(map(str, Path("native", "java").glob("**/*.java"))),
Expand All @@ -48,61 +53,25 @@


setup(
name='JPype1',
version='1.5.1_dev0',
description='A Python to Java bridge.',
long_description=open('README.rst').read(),
license='License :: OSI Approved :: Apache Software License',
author='Steve Menard',
author_email='[email protected]',
maintainer='Luis Nell',
maintainer_email='[email protected]',
python_requires=">=3.7",
url='https://github.com/jpype-project/jpype',
# Non-standard, and extension behaviour of setup() - project information
# should be put in pyproject.toml wherever possible. See also:
# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#setuptools-specific-configuration
platforms=[
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Operating System :: Unix',
'Operating System :: MacOS',
],
classifiers=[
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Topic :: Software Development',
'Topic :: Scientific/Engineering',
],
packages=['jpype', 'jpype._pyinstaller'],
package_dir={'jpype': 'jpype', },
package_data={'jpype': ['*.pyi']},
install_requires=['typing_extensions ; python_version< "3.8"',
'packaging'],
tests_require=['pytest'],
extras_require={
'tests': [
'pytest',
],
'docs': [
'readthedocs-sphinx-ext',
'sphinx',
'sphinx-rtd-theme',
],
},
cmdclass={
'build_ext': setupext.build_ext.BuildExtCommand,
'develop': setupext.develop.Develop,
'test_java': setupext.test_java.TestJavaCommand,
'sdist': setupext.sdist.BuildSourceDistribution,
'test': setupext.pytester.PyTest,
},
zip_safe=False,
ext_modules=[jpypeJar, jpypeLib, ],
distclass=setupext.dist.Distribution,
entry_points={
'pyinstaller40': [
'hook-dirs = jpype._pyinstaller.entry_points:get_hook_dirs',
'tests = jpype._pyinstaller.entry_points:get_PyInstaller_tests',
],
},
)
3 changes: 1 addition & 2 deletions setupext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
#
# *****************************************************************************

from . import utils
from . import dist
from . import platform
from . import build_ext
from . import develop
from . import test_java
from . import sdist
from . import pytester
Loading

0 comments on commit 904fc43

Please sign in to comment.