[PYTHON] Convert binary packages for windows to wheel format

I wrote that here doesn't provide the wheel format for some binary packages, so I can't completely migrate from easy_install to pip. Note that there was a tool wininst2wheel that might solve it.

Confirmation repository: https://bitbucket.org/toruuetani/wininst2wheel_test

py2exe

wininst2wheel py2exe-0.6.9.win32-py2.7.exe

The command py2exe-0.6.9-cp27-none-win32.whl was created. Install this with the following command.

pip install py2exe-0.6.9-cp27-none-win32.whl

Try building a simple source to see if it works.

python setup.py py2exe

py2exe_test.py


# -*- coding: utf-8 -*-

if __name__ == "__main__":
    print "hello"

setup.py


# -*- coding: utf-8 -*- 

from distutils.core import setup
import py2exe

option = {
    "compressed": 1,
    "optimize": 2,
    "bundle_files": 1
}

setup(
    options = {
        "py2exe": option
    },

    console = [
        {"script": "py2exe_test.py"}
    ],

    zipfile = None
)

Apparently it's working fine.

$> dist\py2exe_test.exe
hello

psycopg2

wininst2wheel psycopg2-2.5.2.win32-py2.7-pg9.2.6-release.exe

The command psycopg2-2.5.2-cp2.cp3-none-6_release.whl was created. Install this with the following command.

pip install psycopg2-2.5.2-cp2.cp3-none-6_release.whl

failed.

psycopg2-2.5.2-cp2.cp3-none-6_release.whl is not a supported wheel on this platform.
Storing debug log for failure in C:\Users\usename\pip\pip.log

If you look at the error log, is it because it is an unsupported platform? For the time being, the file name is different from other wheels, so try to match it-> psycopg2-2.5.2-cp2.cp3-none-any.whl and the installation was successful. psycopg2-2.5.2-cp2.cp3-none-win32.whl didn't work. A mystery.

python -c "import psycopg2"

Has succeeded, so it seems to be working for the time being. Just in case, check if it works with django.

pip install "django==1.6.2"
python django-admin.py startproject psycopg2test

settings.py


"""
Django settings for psycopg2test project.

For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '*%_gs%bq67g(1eer1yrl0fwya9et8a2=7p*c6afu6z$ke^-nbo'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'psycopg2test.urls'

WSGI_APPLICATION = 'psycopg2test.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': "DBNAME",
        'USER': "USERNAME",
        'PASSWORD': "PASSWORD",
    }
}

# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/

STATIC_URL = '/static/'

I was able to confirm that it works on the development server, so it seems that there is no problem.

pywin32

wininst2wheel pywin32-218.win32-py2.7.exe

The command pywin32-218-cp27-none-win32.whl was created. Install this with the following command.

pip install pywin32-218-cp27-none-win32.whl

At first glance it looks like it was installed, but if you do python -c "import win32api"

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: DLL load failed: %1 is not a valid Win32 application.

Will be displayed. This is because pywintypes27.dll and pythoncom27.dll cannot be loaded. If you run pywin32-218.win32-py2.7.exe directly, you will need to be elevated to administrator privileges and these DLLs have been copied to your system directory. Therefore, it can be imported without any problem. This behavior can be reproduced by executing pywin32_postinstall.py with administrator privileges, but it is difficult to place the DLL in the system directory even in the virtualenv environment. If your goal is to work for the time being, use the above DLL Copy it to % VENV_DIR% \ Lib \ site-packages \ win32.

Recommended Posts

Convert binary packages for windows to wheel format
Convert Qiita articles to Jekyll post format for backup
Convert hexadecimal string to binary
Convert xml format data to txt format data (yolov3)
How to easily convert format from Markdown
Convert matplotlib graphs to emf file format
Convert GFF3 to MSS for DDBJ submission
Convert PDF attached to email to text format
Convert Python date types to RFC822 format
How to convert DateTimeField format in Django
convert youtube playlist to local m3u format file for smplayer (by toy tool)
[Tensorflowjs_converter] How to convert Tensorflow model to Tensorflow.js format
Settings for uploading Python packages locally to PyPI
Convert Windows epoch values to date with python
From ROS for Windows installation to operation check
Convert json format data to txt (using yolo)
String to Unicode Escape Sequence Format for Python
Convert strings to character-by-character list format with python
Steps to build PyTorch 1.5 for CUDA 10.2 on Windows
Convert to HSV
[Python] Convert decimal numbers to binary numbers, octal numbers, and hexadecimal numbers
How to convert Python # type for Python super beginners: str
Convert a text file with hexadecimal values to a binary file
How to convert floating point numbers to binary numbers in Python
I built a Wheel for Windows using Github Actions
Convert / return class object to JSON format in Python
How to convert Json file to CSV format or EXCEL format
Convert translation resource files (.po) to XLIFF format (.xlf)
Convert Pascal VOC format xml file to COCO format json file