I am attempting to build a python wheel using setuptools
. The package needs to include two files:
mymodule.py
- a python module in the same directory assetup.py
myjar.jar
- a java .jar file that exists outside of my package directory
I am building my package using python3 setup.py bdist_wheel
.
If I call setup()
like so:
setup(
name="mypkg",
py_modules=["mymodule"],
data_files=[('jars', ['../target/scala-2.11/myjar.jar'])]
)
then myjar.jar
does successfully get included in the .whl (good so far) however when I pip install mypkg
it places the jar at /usr/local/myjar.jar
(this kinda explains why) which isn't what I want at all, I want it to exist in the same place as mymodule.py
, i.e. /usr/local/lib/python3.7/site-packages/
If I change setup.py
to
setup(
name="mypkg",
py_modules=["mymodule"],
package_data={'jars': '../target/scala-2.11/myjar.jar'}
)
or
setup(
name="mypkg",
py_modules=["mymodule"],
package_data={'jars': ['../target/scala-2.11/myjar.jar']}
)
then myjar.jar
simply doesn't get included in the .whl. I tried copying myjar.jar
into the same directory and changing setup.py
to:
setup(
name="mypkg",
py_modules=["mymodule"],
package_data={'jars': 'myjar.jar'}
)
or
setup(
name="mypkg",
py_modules=["mymodule"],
package_data={'jars': ['myjar.jar']}
)
but still myjar.jar
does not get included in the .whl.
I've been tearing my hair out over this for hours, hence why I'm here.
I've read a myriad of SO posts on this:
- How to include package data with setuptools/distribute?
- MANIFEST.in ignored on "python setup.py install" - no data files installed?
- How do you add additional files to a wheel?
- setuptools: adding additional files outside package
which suggest different combinations of data_files
, package_data
, include_package_data=True
and/or use of a Manifest.in
file but still I can't get this working as I would like, so I'm here hoping someone can advise what I'm doing wrong.