Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
add pytorch
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Nov 9, 2017
1 parent 0309a1d commit 10e0521
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
76 changes: 76 additions & 0 deletions _doc/sphinxdoc/source/blog/2017/2017-11-08_setup_site_package.rst
@@ -0,0 +1,76 @@

.. blogpost::
:title: Create a wheel with an installed package
:keywords: setup
:date: 2017-11-08
:categories: wheel

It happens sometimes you install package but you don't remember
exactly you did it. However, you would like to make a wheel
from what is installed in folder ``site-packages``.
There is probably a better way but I created a local
folder orgnized this way:

::

folder
|- setup.py
|- src
|- __init__.py (empty)
|- <__PACKAGE__>
|- ... (the content)

In ``setup.py``, I wrote:

::

import sys
import os
from distutils.core import setup
from setuptools import find_packages

project_var_name = "__PACKAGE__"
version = "0.2.1"
path = "Lib/site-packages/" + project_var_name

# sources
packages = find_packages('src', exclude='src')
package_dir = {k: "src/" + k.replace(".", "/") for k in packages}

# data
package_data = {}
for r, d, f in os.walk('src'):
for a in f:
temp = os.path.join(r, a)
name0 = temp
if "__pycache__" in temp:
continue
if temp.endswith(".py"):
continue
temp = temp.replace("\\", "/")
if not temp.startswith("src/"):
raise ValueError(temp)
fold = os.path.dirname(temp)
init = os.path.join(fold, "__init__.py")
if not os.path.exists(init):
print("adding ", init)
with open(init, "w") as f:
pass
temp = temp[4:]
if temp == "__init__.py":
continue
fold, name = os.path.split(temp)
pack = fold.replace("/", ".")
if pack not in package_data:
package_data[pack] = []
package_data[pack].append(name)

# setup
setup(name=project_var_name,
version=version,
packages=packages,
package_dir=package_dir,
package_data=package_data)

You get a wheel you can install in some other places
and no zip or unzip is needed.
10 changes: 10 additions & 0 deletions _doc/sphinxdoc/source/blog/2017/2017-11-08_torch_windows.rst
@@ -0,0 +1,10 @@

.. blogpost::
:title: Install pytorch on Windows
:keywords: torch
:date: 2017-11-08
:categories: module

You can go there
`peterjc123/pytorch <https://anaconda.org/peterjc123/pytorch/files>`_
or type ``conda install -c peterjc123 pytorch``.
7 changes: 7 additions & 0 deletions src/pymyinstall/packaged/packaged_config_4_ml.py
Expand Up @@ -717,6 +717,13 @@ def ensae_set():
purpose="Matrix completion and feature imputation algorithms"),
ModuleInstall('mnist', 'pip',
purpose="Python utilities to download and parse the MNIST dataset"),
#
# 2017-11
#
ModuleInstall('torch', 'wheel', source="2", usage="DEEP LEARNING",
purpose="PyTorch is a deep learning framework that puts Python first."),
ModuleInstall('torchvision', 'pip', usage="DEEP LEARNING",
purpose="image and video datasets and models for torch deep learning"),
]

if sys.version_info[0] == 2:
Expand Down

0 comments on commit 10e0521

Please sign in to comment.