Pip Package With Os Specififc Dependency
Solution 1:
The platform specific dependencies could be kept in separate Python projects (wrappers around data only packages) and then required from the main project like the following:
# setup.cfg# ...
[options]
install_requires =
my_package_win_amd64 ; platform_system=="Windows"and platform_machine=="x86_64"
my_package_linux-x86_64 ; platform_system=="Linux"and platform_machine=="x86_64"
This approach doesn't depend on setuptools and could be used with other build systems.
Solution 2:
First answer is give up and use setuptools
. Look at Platform specific dependencies for a good write up of what to do.
Second answer is to make separate packages such as 'mylib-mac', 'mylib-win', 'mylib-linux'.
Third answer is to use the "console_script" approach. This will break. While it generates .exe files on Windows, it has odd failure modes. Also, some users will not be able to dynamically download files because they work from an internal clone of a repository. Randomly running code from the Internet on production can scare people.
Hope this helps!
Solution 3:
A solution could be to publish platform specific Python wheels of your project. The platform specific files could be added to the pre-built distributions via a custom setuptools command (probably a sub-command of build, or maybe install).
This is not a full solution, but something like this might be a good start:
#!/usr/bin/env python3import distutils.command.build
import setuptools
classbuild_something(setuptools.Command):
user_options = [
('plat-name=', 'p', "platform name to build for"),
]
definitialize_options(self):
self.plat_name = Nonedeffinalize_options(self):
self.set_undefined_options('bdist_wheel', ('plat_name', 'plat_name'))
defrun(self):
print(" *** plat_name: {} ***".format(self.plat_name))
print(" *** download the platform specific bits to 'build' ***")
classbuild(distutils.command.build.build):
sub_commands = [(
'build_something',
None,
)] + distutils.command.build.build.sub_commands
setuptools.setup(
cmdclass={
'build_something': build_something,
'build': build,
},
# ...
)
And then the Python wheels could be built like this:
$ ./setup.py bdist_wheel -p win_amd64
Post a Comment for "Pip Package With Os Specififc Dependency"