Introduction
I'm creating a package to solve route problems. I'm using Cython in the heavy math parts to increase the speed.
In Linux SO (Ubuntu 18.04) everything works perfect. But in Windows 10 it's impossible to install it via pip install skroute
I'm using Python 3.7.
This is the setup.py file:
import os
from setuptools import setup, find_packages
from setuptools.extension import Extension
from Cython.Build import cythonize
import Cython.Compiler.Options
Cython.Compiler.Options.annotate = True
extensions = cythonize([
Extension(
"skroute.heuristics.brute._base_brute_force._base_brute_force",
sources=["skroute/heuristics/brute/_base_brute_force/_base_brute_force.pyx"]),
Extension(
"skroute.metaheuristics.genetics._base_genetics._utils_genetic",
sources=["skroute/metaheuristics/genetics/_base_genetics/_utils_genetic.pyx"]),
Extension(
"skroute._utils._utils",
sources=["skroute/_utils/_utils.pyx"]),
Extension(
"skroute.metaheuristics.genetics._base_genetics._base_genetic",
sources=["skroute/metaheuristics/genetics/_base_genetics/_base_genetic.pyx"]),
Extension(
"skroute.metaheuristics.simulated_annealing._base_simulated_annealing._base_simulated_annealing",
sources=["skroute/metaheuristics/simulated_annealing/_base_simulated_annealing/_base_simulated_annealing.pyx"]),
Extension(
"skroute.metaheuristics.simulated_annealing._base_simulated_annealing._utils_sa",
sources=["skroute/metaheuristics/simulated_annealing/_base_simulated_annealing/_utils_sa.pyx"]),
])
HERE = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(HERE, "README.md")) as fid:
README = fid.read()
with open(os.path.join(HERE, "requirements.txt")) as f:
REQUIREMENTS = f.read().splitlines()
setup(
name="scikit-route",
version="1.0.0a1 ",
description="Compute Routes easy and fast",
long_description=README,
long_description_content_type="text/markdown",
url="https://github.com/arubiales/scikit-route",
author="Alberto Rubiales",
author_email="al.rubiales.b@gmail.com",
license="MIT",
classifiers=[
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9"
],
packages=find_packages(),
setup_requires=[
'setuptools>=18.0',
"cython"
],
install_requires=REQUIREMENTS,
ext_modules = extensions,
include_package_data=True,
package_data={"": ["datasets/_data/_latitude_longitude/*.tsp", "datasets/*.txt", "datasets/_data/_money_cost/*.pkl"]},
)
Problem
when I try to install the package on Windows 10 from Pypi, I get the following error:
ERROR: Command errored out with exit status 1:
command: 'C:\Users\whast\anaconda3\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\whast\\AppData\\Local\\Temp\\pip-install-dhvqmkkc\\scikit-route\\setup.py'"'"'; _file='"'"'C:\\Users\\whast\\AppData\\Local\\Temp\\pip-install-dhvqmkkc\\scikit-route\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file_, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\whast\AppData\Local\Temp\pip-pip-egg-info-uqcw3lxf'
cwd: C:\Users\whast\AppData\Local\Temp\pip-install-dhvqmkkc\scikit-route\
Complete output (11 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\whast\AppData\Local\Temp\pip-install-dhvqmkkc\scikit-route\setup.py", line 40, in <module>
extensions = cythonize([
File "C:\Users\whast\anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 965, in cythonize
module_list, module_metadata = create_extension_list(
File "C:\Users\whast\anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 815, in create_extension_list
for file in nonempty(sorted(extended_iglob(filepattern)), "'%s' doesn't match any files" % filepattern):
File "C:\Users\whast\anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 114, in nonempty
raise ValueError(error_msg)
ValueError: 'skroute/heuristics/brute/_base_brute_force/_base_brute_force.pyx' doesn't match any files
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Here the installation is trying to cythonize a .pyx file but it doesn't find the path.
Procces to create the package
What I did to create the package is:
- Run
python -m setup.py sdist bdist_wheelto create the.whlfile - Use
auditwheelto repair the file, is necesary to upload a package with Cython module to Pypi and make available the package throug all linux distributions. I runauditwheel reapair dist/scikit_route....whl - I replace the
.whlcreated bysetuptoolswith the reapaired fromauditwheelindistfolder - The last step is upload
distfolder to Pypi, so I runpython -m twine upload dist/*
Tries to solve it
- Append the path to the system while the skroute is installing with
sys.path.append("/".join(os.path.abspath(__file__).split("/")[:-1]))without success - Install the package downloading from git. It works but I want to be able to install it from Pypi.
As I said in the point two, I can install the package in Windows 10, if I donwload from my Github repository and run Python setup.py sdist bdist_wheel and after pip install dist/*.whl so I suspect that the problem is when I use auditwheel to repair the .whl
As I said in "Procces to create the package" point two :
Use
auditwheelto repair the file, is necesary to upload a package with Cython module to Pypi. I runauditwheel reapair dist/scikit_route....whl
If you know anyway to make it works, I will be very grateful for your help.
Possible links of interest: