3

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:

  1. Run python -m setup.py sdist bdist_wheel to create the .whl file
  2. Use auditwheel to repair the file, is necesary to upload a package with Cython module to Pypi and make available the package throug all linux distributions. I run auditwheel reapair dist/scikit_route....whl
  3. I replace the .whl created by setuptools with the reapaired from auditwheel in dist folder
  4. The last step is upload dist folder to Pypi, so I run python -m twine upload dist/*

Tries to solve it

  1. Append the path to the system while the skroute is installing with sys.path.append("/".join(os.path.abspath(__file__).split("/")[:-1])) without success
  2. 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 auditwheel to repair the file, is necesary to upload a package with Cython module to Pypi. I run auditwheel 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:

Pypi link package

Github link package

Rubiales Alberto
  • 143
  • 3
  • 12
  • 1
    I guess there is something wrong with your upload process, since in the PyPI there is only one version of `skroute` and it is 1.0.0a1. It does not have Windows wheels, so it downloads the `skroute-1.0.0a1.tar.gz`. Or did you remove a windows wheel from PyPI? – Niko Föhr Jan 21 '21 at 14:19
  • 1
    On Linux the wheels are used (at least if you test with Python3.7) yet on Windows it is built from the source-distribution which is lacking pyx-files (you didn't include it in the package I guess) and thus cannot be built. – ead Jan 21 '21 at 14:25
  • Yes I don't have `.zip` file, but is it the problem? is it neccesary? When I make pip install downloading from github I use the `.whl` and the `tar.gz` and everything runs pefectly. I have try to do it creating the `zip` file and have the same error. I think is a problem of `auditwheel` and Windows. – Rubiales Alberto Jan 21 '21 at 16:06
  • 2
    You may want to create a `MANIFEST.in` file next to `setup.py` with content `recursive-include skroute *.pyx\nrecursive-include skroute *.pxd\nrecursive-include skroute *.pxi` and any other source files that may be necessary to build the extensions. Then make the sdist again. – cgohlke Jan 21 '21 at 19:44
  • @cgohlke I was becoming crazy... I completely forgot it!! Thank you very much for your help. If you want you can create and answerd and I will mark as correct and upvote, you deserve it. – Rubiales Alberto Jan 21 '21 at 22:12

0 Answers0